1

I'd like to implement amazon pay. The button works fine, but I would like to restric every country EXCEPT e.g. germany

Here is my code snippet. I tried several addressRestriction formats:

$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);

I receive the error Error Code: InvalidRequestFormat Error Message: Invalid request format, check fields are in correct format. when clicking on the button. If I remove the lines:

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

It works...

Any hints?

aynber
  • 22,380
  • 8
  • 50
  • 63
Christian
  • 152
  • 1
  • 11

1 Answers1

2

The address restrictions have a format that is a little different from what one would expect. You might want to try this:

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

The country is not the array value but the array key.

marcus.kreusch
  • 648
  • 5
  • 15