我在 $client->createCheckoutSession($payload, $headers):\'{\'reasonCode\':\'InvalidRequestSignature\',\'message\':\'Unable to verify signature, 之后收到此错误
我收到此错误后 $client->createCheckoutSession($payload, $headers)
:
"{"reasonCode":"InvalidRequestSignature","message":"Unable to verify signature, signing String [AMZN-PAY-RSASSA-
我的客户 public_key_id
通过亚马逊卖家中心给了我,这 pem file
是 public_key_id
正确的。
此错误可能是由不正确的 PEM 文件引起的吗?我是否应该要求客户验证 PEM 文件是否是从 Amazon Seller Central 下载的?
我已经在两台不同的设备上运行了同一段代码,确认环境满足SDK要求。
谢谢。
我的代码:
<?php
require __DIR__ . '/vendor/autoload.php';
$amazonpay_config = array(
'public_key_id' => 'SANDBOX-XXXXXXX',
'private_key' => './private.pem',
'region' => 'US',
'algorithm' => 'AMZN-PAY-RSASSA-PSS-V2',
);
$payload = array(
'webCheckoutDetails' => array(
'checkoutReviewReturnUrl' => 'https://localhost/store/checkout_review',
'checkoutResultReturnUrl' => 'https://localhost/store/checkout_result'
),
'storeId' => 'amzn1.application-oa2-client.XXXXXXXXXXX'
);
$headers = array('x-amz-pay-Idempotency-Key' => uniqid());
$client = new Amazon\Pay\API\Client($amazonpay_config);
$resultCheckOut = $client->createCheckoutSession($payload, $headers);
var_dump($resultCheckOut);exit;
[\'request\']=> string(242) \'{\'webCheckoutDetails\':{\'checkoutReviewReturnUrl\':\'https:\/\/localhost\/store\/checkout_review\',\'checkoutResultReturnUrl\':\'https:\/\/localhost\/store\/checkout_result\'},\'storeId\':\'amzn1.application-oa2-client.XXXX\'}\' [\'response\']=> string(545) \'{\'reasonCode\':\'InvalidRequestSignature\',\'message\':\'无法验证签名,签名字符串 [AMZN-PAY-RSASSA-PSS-V2\XXXXX],签名 [XXXXX\'}\' [\'request_id\']=> string(36) \'XXXXX\' [\'重试\']=> int(0) [\'持续时间\']=> int(859)