Amazon Pay 仅允许特定国家/地区发货

Amazon Pay allow only specific country for shipping

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

这是我的代码片段。我尝试了几种地址限制格式:

$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'];

有效...

有什么提示吗?

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

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

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