【问题标题】:I'm using Apple Pay JS to integrate it into my website what should I sent onMerchantValidate我正在使用 Apple Pay JS 将其集成到我的网站中我应该发送什么 onMerchantValidate
【发布时间】:2021-08-23 11:48:08
【问题描述】:

目前我所知道的是我必须向苹果服务器发送一个 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,
   }

【问题讨论】:

    标签: applepay applepayjs


    【解决方案1】:

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

    这些步骤必须在 Mac 上完成

    1. 转到 Apple Developer -> 创建证书 -> Apple Pay 商家身份

    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 = "yourPath/ApplePay.key.pem";

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

      $data = 数组( "merchantIdentifier" => "您的商家名称", "displayName" => "您的店铺名称", "initiative" => "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);

    【讨论】:

      猜你喜欢
      • 2016-10-15
      • 2019-07-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-04-05
      • 2011-03-17
      • 1970-01-01
      相关资源
      最近更新 更多