Re-rendering Wallet widgets | Amazon Pay EU

Re-rendering Wallet widgets

In most cases, you don't need to refresh the Wallet widget as it automatically refreshes when a buyer chooses an address from the AddressBook widget. Frequent re-rendering of the Wallet widget affects website performance and causes a poor buyer experience.

But sometimes the re-rendering of the Wallet widget is actually required when certain constraints are returned in the checkout flow. Here are some examples:

  • PaymentMethodNotAllowed - Amazon Pay might not allow all payment methods for a given transaction. After calling either the SetOrderReferenceDetails or GetOrderReferenceDetails operation, you might see a PaymentMethodNotAllowed constraint in the response. Attempting to confirm an Order Reference that has constraints also returns the error code ConstraintsExist.
  • InvalidPaymentMethod - If there are problems with a buyer's payment method, it might be declined. If so, after making a GetAuthorizationDetails API call, you see a response with a Declined state with a InvalidPaymentMethod reason code.

As a best practice, you should re-render the Wallet widget and request that the buyer choose a different payment method.

For more information about constraints, see OrderReferenceConstraints in the Amazon Pay API reference guide.

Procedure

To re-render the Wallet widget, bind the order reference Id, which was created from the AddressBook widget, to the Wallet widget.

 
<script>
  // re-render the wallet widget after saving new currencyCode.
  // set to GBP for UK integrations
  walletWidget.setPresentmentCurrency("EUR").bind("walletWidgetDiv");
</script>
    

Finally, reload the page, or call your JavaScript function to render the wallet widget.