Test Login
This is a test log in to show how quickly customers can login or create an account.
Note: This is a sandbox and does not use actual Amazon accounts. To create a sandbox test account:
- Login to Seller Central
- Select "Amazon Pay (Sandbox View)" from the picklist at the top of the screen
- Hover over the "Integration" option at the top of the screen
- Select "Test Accounts" from the Integration menu
- Click the "Create a new test account" button and follow the instructions
Code
Create the button container.
<div id="AmazonLoginButton"></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/gbp/sandbox/js/Widgets.js'></script>
DE/EUR
<script type='text/javascript' src='https://static-eu.payments-amazon.com/OffAmazonPayments/eur/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("AmazonLoginButton", "MERCHANT_ID", {
type: "LwA",
color: "Gold",
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/login_and_pay/lpa-login-cart.html");
},
onError: function (error) {
// something bad happened
}
});
</script>