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 | Total |
---|---|---|---|
Baldwin Entry Door Knob
Baldwin's Classic knob gives a comforting and invitingly warm impression. Clean lines and simple, architecturally-inspired designs exemplify timeless sophistication.
|
1 | 175.00 |
When logging in, you must use a sandbox test account. To create a 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="AmazonPayButton"></div>
Add script to set the client Id.
<script>
window.onAmazonLoginReady = function () {
amazon.Login.setClientId('CLIENT_ID');
};
window.onAmazonPaymentsReady = function() {
showButton();
};
</script>
Import widgets javascript. This must be loaded after you set the client Id above.
USA
<script async='async' src='https://static-na.payments-amazon.com/OffAmazonPayments/us/sandbox/js/Widgets.js'></script>
UK
<script async='async' src='https://static-eu.payments-amazon.com/OffAmazonPayments/uk/sandbox/lpa/js/Widgets.js'></script>
DE
<script async='async' src='https://static-eu.payments-amazon.com/OffAmazonPayments/de/sandbox/lpa/js/Widgets.js'></script>
JP
<script async='async' src='https://origin-na.ssl-images-amazon.com/images/G/09/EP/offAmazonPayments/sandbox/prod/lpa/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>
function showButton() {
var authRequest;
OffAmazonPayments.Button("AmazonPayButton", "MERCHANT_ID", {
type: "PwA",
color: "Gold",
size: "large",
language: "en-UK",
authorization: function () {
loginOptions = { scope: "profile payments:widget payments:shipping_address", popup: true };
authRequest = amazon.Login.authorize(loginOptions, "https://amzn.github.io/amazon-pay-sdk-samples/set.html");
},
onError: function(error) {
// your error handling code.
// alert("The following error occurred: "
// + error.getErrorCode()
// + ' - ' + error.getErrorMessage());
}
});
};
</script>