1

我想实施亚马逊支付。该按钮工作正常,但我想限制除德国以外的每个国家

这是我的代码片段。我尝试了几种 addressRestriction 格式:

$client = new Client($amazonPayConfig);
$amazonPayPayload['storeId'] = $amazonPayStoreId;
$amazonPayPayload['webCheckoutDetails']['checkoutReviewReturnUrl'] = $checkoutReviewReturnUrl;
$amazonPayPayload['deliverySpecifications']['addressRestrictions']['type'] = 'Allowed';
$amazonPayPayload['deliverySpecifications']['addressRestrictions']['restrictions'][] = ['DE'];
$amazonPayPayloadJson = json_encode($amazonPayPayload);
$amazonPaySignature = $client->generateButtonSignature($amazonPayPayloadJson);

Error Code: InvalidRequestFormat Error Message: Invalid request format, check fields are in correct format.单击按钮时收到错误消息。如果我删除这些行:

$amazonPayPayload['deliverySpecifications']['addressRestrictions']['type'] = 'Allowed';
$amazonPayPayload['deliverySpecifications']['addressRestrictions']['restrictions'][] = ['DE'];

有用...

有什么提示吗?

4

1 回答 1

2

地址限制的格式与预期的略有不同。你可能想试试这个:

$amazonPayPayload['deliverySpecifications']['addressRestrictions']['restrictions'] = ['DE'=>new \stdClass()];

国家不是数组值而是数组键。

于 2020-11-18T15:00:29.110 回答