Amazon Pay and Login with Amazon integration guide

Handling errors from Amazon Pay widgets

As discussed in Step 3: Add a button widget, you can configure the Button, AddressBook, and Wallet widgets to notify you of error conditions. These widgets send error notifications if certain integration errors are made.

The following code example shows how you can read the errorCode and errorMessage that are associated with the error. These error codes help you debug your integration more quickly and, if logged, can notify you of potential issues on your production site.

      <div id="AmazonPayButton">
      </div>
	  
      <script type="text/javascript">
      function showButton(){
        var authRequest; 
        OffAmazonPayments.Button("AmazonPayButton", "SELLER-ID", { 
          type:  "TYPE", 
          color: "COLOR", 
          size:  "SIZE", 

          authorization: function() { 
            loginOptions = {scope: "SCOPES", 
            popup: "POPUP-PARAMETER"}; 
            authRequest = amazon.Login.authorize (loginOptions, 
              "REDIRECT-URL"); 
          }, 
 
          onError: function(error) { 
            // your error handling code.
            alert("The following error occurred: " 
              + error.getErrorCode() 
              + ' - ' + error.getErrorMessage());
          } 
        });
      }; 
      </script> 

The following table lists the various error codes that are returned from the Amazon Pay widgets and the corresponding error message that the buyer sees within the widget body:

Error code

Description

Error message shown to the buyer

AddressNotModifiable

You cannot modify the shipping address when the order reference is in the given state.

You cannot change the shipping address for this order. Please contact the merchant for assistance.

BuyerNotAssociated

The buyer is not associated with the given order reference. The buyer must sign in before you render the widget.

This session is not valid. Please re-start the checkout process by clicking the Pay with Amazon button.

BuyerSessionExpired

The buyer's session with Amazon has expired. The buyer must sign in before you render the widget.

Your session has expired. Please sign in again by clicking the Amazon Pay button.

InvalidAccountStatus

Your merchant account is not in an appropriate state to execute this request. For example, it has been suspended or you have not completed registration.

If the error happened when showing the Button widget, the widget doesn't appear. There is no error message shown to the buyer. If the error happened when showing the AddressBook or Wallet widgets, the buyer sees this message:

We're sorry, but there's a problem processing your payment from this website. Please contact the merchant for assistance.

InvalidOrderReferenceId

The specified order reference identifier is invalid.

We're sorry, but there's a problem processing your payment from this website. Please contact the merchant.

InvalidParameterValue

The value assigned to the specified parameter is not valid.

If the error happened when showing the Button widget, the widget doesn't appear. There is no error message shown to the buyer. If the error happened when showing the AddressBook or Wallet widgets, the buyer sees this message:

We're sorry, but there's a problem processing your payment from this website. Please contact the merchant for assistance.

InvalidSellerId

The merchant identifier that you have provided is invalid. Specify a valid SellerId.

If the error happened when showing the Button widget, the widget doesn't appear. There is no error message shown to the buyer. If the error happened when showing the AddressBook or Wallet widgets, the buyer sees this message:

We're sorry, but there's a problem processing your payment from this website. Please contact the merchant for assistance.

MissingParameter

The specified parameter is missing and must be provided.

If the error happened when showing the Button widget, the widget doesn't appear. There is no error message shown to the buyer. If the error happened when showing the AddressBook or Wallet widgets, the buyer sees this message:

We're sorry, but there's a problem processing your payment from this website. Please contact the merchant for assistance.

PaymentMethodNotModifiable

You cannot modify the payment method when the order reference is in the given state.

You cannot change the payment method for this order. Please contact the merchant for assistance.

ReleaseEnvironmentMismatch

You have attempted to render a widget in a release environment that doesn't match the release environment of the Order Reference object. The release environment of the widget and the Order Reference object must match.

We're sorry, but there's a problem processing your payment from this website. Please contact the merchant for assistance.

StaleOrderReference

The specified order reference was not confirmed in the allowed time and is now cancelled. You cannot associate a payment method and an address with a cancelled order reference.

Your session has expired. Please sign in again by clicking the Amazon Pay button.

UnknownError

There was an unknown error in the service.

We're sorry, but there's a problem processing your payment from this website. Please contact the merchant.


Copyright © 2009-2017 Amazon.com, Inc. or its affiliates. Amazon and Amazon.com are registered trademarks of Amazon.com, Inc. or its affiliates. All other trademarks are the property of their respective owners.