View on GitHub

Amazon Pay SDK Samples

Amazon Pay Recurring Payments

Test Cart

This is a test cart to show which calls need to be made to allow a buyer to make a purchase.

Note: This is a sandbox transaction. Your payment method will not be charged.

Product Description Quantity Billing Cycle Total
The Daily Developer Subscription
The Daily Developer magazine subscription.
1 Every 10 seconds 2.00/cycle

When logging in, use the following credentials.

Email address: payment-test@amazon.com
Password:      test123

Create the button container.

<div id="AmazonPayButton"></div>

Add script to set the client Id.

<script type='text/javascript'>
    window.onAmazonLoginReady = function () {
        amazon.Login.setClientId('CLIENT_ID');
    };
</script>

Import widgets javascript. This must be loaded after you set the client Id above.

USA
<script type='text/javascript' src='https://static-na.payments-amazon.com/OffAmazonPayments/us/sandbox/js/Widgets.js'></script>
UK
<script type='text/javascript' src='https://static-eu.payments-amazon.com/OffAmazonPayments/uk/sandbox/js/Widgets.js'></script>

Render the button. Note: You will need to add your domain to 'Allowed JavaScript Origins' in Seller Central. If you are testing locally you can use 'http://localhost'. Production sites must have a valid certificate and use https.

<script type='text/javascript'>
    var authRequest;
    OffAmazonPayments.Button("AmazonPayButton", "MERCHANT_ID", {
        type: "PwA",
        authorization: function () {
            loginOptions = { scope: "profile postal_code payments:widget payments:shipping_address", popup: true };
            authRequest = amazon.Login.authorize(loginOptions, "https://amzn.github.io/amazon-pay-sdk-samples/set_recurring.html");
        },
        onError: function (error) {
            // something bad happened
        }
    });
</script>