Amazon Pay and Login with Amazon integration guide

Integrating without the AddressBook widget

In some cases, such as when you are selling digital products or want to collect a buyer's address on your own, you might not want to collect the buyer's address from the AddressBook widget.

Note: If you do not use the Amazon AddressBook widget to collect an address from the buyer, the transaction is not covered under the Amazon Pay Payment Protection Policy. For more information about the Amazon Pay Payment Protection Policy, see the Amazon Pay User Agreement.

When an AddressBook widget is shown, an Order Reference object is created. When you integrate without an AddressBook widget, you need to create an Order Reference object by specifying an onOrderReferenceCreate callback function as one of the parameters in the Wallet widget call.

The onOrderReferenceCreate function is called with an Order Reference object when the widget renders. You can get the orderReferenceId by calling the getAmazonOrderReferenceId() function on the Order Reference object. You must store the Order Reference ID as you will need it throughout transaction processing.

The following example shows how to render the Wallet widget when you do not use the AddressBook widget:

<div id="walletWidgetDiv"></div> 

<script>
  window.onAmazonLoginReady = function() {amazon.Login.setClientId('YOUR-CLIENT-ID'); };
  window.onAmazonPaymentsReady = function() {

    var orderReferenceId = null;

    new OffAmazonPayments.Widgets.Wallet({ 
      sellerId: 'YOUR_SELLER_ID_HERE',
      // Add the onOrderReferenceCreate function to 
      // generate an Order Reference ID. 
      onOrderReferenceCreate: function(orderReference) {
        // Use the following cod to get the generated Order Reference ID.
        orderReferenceId = orderReference.getAmazonOrderReferenceId();
      },
      design: {
        designMode: 'responsive'
      },
      onPaymentSelect: function(orderReference) {
        // Replace this code with the action that you want to perform
        // after the payment method is selected.

        // Ideally this would enable the next action for the buyer
        // such as a "Continue" or "Place Order" button.
      },
      onError: function(error) {
        // Your error handling code.
        // During development you can use the following
        // code to view error messages:
        // console.log(error.getErrorCode() + ': ' + error.getErrorMessage());
        // See "Handling Errors" for more information.
      }
    }).bind('walletWidgetDiv');
  };
</script>

<script async="async" 
  src='https://static-eu.payments-amazon.com/OffAmazonPayments/gbp/sandbox/lpa/js/Widgets.js'>
    new OffAmazonPayments.Widgets.Wallet({ 

You must specify width and height parameters. Otherwise, the widgets don't render. For more information, see the "CSS code for payment widgets" section of Payment widgets.


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.