微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

我正在使用 Apple Pay JS 将其集成到我的网站中我应该发送什么 onMerchantValidate

如何解决我正在使用 Apple Pay JS 将其集成到我的网站中我应该发送什么 onMerchantValidate

到目前为止我所知道的是我必须向苹果服务器发送一个 POST 请求。

我如何或在哪里可以获得 merchIdentityCert 证书和密钥?

注意:我将从 PHP 发送 post 请求

   const options= {
       url: endpointURL,cert: merchIdentityCert,key: merchIdentityCert,method: 'post',body:{
               merchantIdentifier: "merchant.com.example.mystore",displayName: "MyStore",initiative: "web",initiativeContext: "mystore.example.com"
             },json: true,}

解决方法

我想出了如何连接到苹果服务器并为 POST 请求创建所需的证书。

这些步骤必须在 mac 上完成

  1. 转到 Apple Developer -> 创建证书 -> Apple Pay Merchant Identity

  2. 从您的 Mac 转到 KeyChain Access-> 在右上角选择 Keychain Access-> Certificate Assistant -> 从证书颁发机构请求证书

  3. 选择保存到磁盘并让我指定密钥对信息

  4. 密钥大小 = 2048 位 / 算法 = RSA

  5. 将 CSR 上传到您的 Apple Pay 商家身份

  6. 下载 Apple Pay 提供的证书并将其上传到您的 Keychain Access

  7. 从 Keychain Access 导出证书为 .p12 格式

  8. 打开终端将其定向到带有导出的 .p12 证书的文件夹

  9. 运行这些命令 “openssl pkcs12 -in ApplePayMerchantIdentity_and_privatekey.p12 -out ApplePay.crt.pem -clcerts -nokeys” “openssl pkcs12 -in ApplePayMerchantIdentity_and_privatekey.p12 -out ApplePay.key.pem -nocerts”

    $path = "yourPath/ApplePay.crt.pem"; $path_key = "你的路径/ApplePay.key.pem";

    // 创建一个新的 cURL 资源 $ch = curl_init();

    $data = 数组( "merchantIdentifier" => "您的商家名称","displayName" => "您的店铺名称","initiative" => "web",// 如果你打算在 web 上使用它 “initiativeContext” => “域” );

    $data = json_encode($data);

    $header = 数组( '内容类型:应用程序/json' );

    curl_setopt($ch,CURLOPT_URL,$url); curl_setopt($ch,CURLOPT_SSLCERT,$path); curl_setopt($ch,CURLOPT_SSLCERTPASSWD,""); // 对于证书密码 curl_setopt($ch,CURLOPT_SSLKEY,$path_key); curl_setopt($ch,CURLOPT_POST,1); curl_setopt($ch,CURLOPT_POSTFIELDS,$data); curl_setopt($ch,CURLOPT_HTTPHEADER,$header);

    $serverOutput = curl_exec($ch);

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。