Step 1: Add a Button widget for buyer authentication
Prerequisite: Complete all requirements in the Prerequisites section before beginning this integration step.
The first widget that you need to embed and present to your buyers is the Amazon Pay button widget. This widget displays the button that lets buyers know that they can use their Amazon credentials (email address and password) to sign in and use Amazon Pay to pay for their order on your site.
The code sample above defines the division in your webpage that is used to render the button. Place this code in the HTML where you want the button to appear.
Button widget parameters
When you add the button code to your site, you need to replace parameters in the code sample with your own values. The following sections describe how to replace text in the code sample:
Related code topics:
Replace YOUR_MERCHANT_ID with your own Merchant-ID, which you received during registration. If you are not sure what your Merchant-ID is, log in to Seller Central and go to Integration > MWS Access Key to view your Merchant ID.
The type parameter is an optional parameter for indicating the type of button image that you want to choose for your webpage. Note that if you decide not to specify a value for type, the Login with Amazon button is set as the default value.
The following table shows the valid type parameter values, button descriptions, and sample button images.
|Type codes||Button description||Button example|
Specifies the Login with Amazon button.
This is the default button if type is not specified.
|PwA||Specifies the Amazon Pay button.|
The color parameter is an optional parameter for choosing a button color. This table shows the valid color code values, color descriptions, and color samples.
|Color codes||Color description||Color example|
The size parameter is an optional parameter for choosing a button size. For more information about button size options, see the Button guidelines.
Valid size code values are:
The actual size rendered depends on the type of button selected:
|LwA - Specifies the Login with Amazon button.||
|PwA - Specifies the Amazon Pay button.||
The value of the parameter scope that you choose influences both the content returned in the response of the call and the type of consent screen Amazon Pay shows to the buyer to secure their permission for sharing their information.
You may use a combination of the following scope parameters:
|profile||Gives access to the full user profile (username, email-address, user-id) after login.|
|profile:user_id||Gives access only to the user-id from the user profile after login.|
|postal_code||Gives the user's zip/postal code number from their primary shipping address.||When you request access to the postal_code scope, alone or in concert with the profile or profile:user_id scope, the user has to consent to share their information.|
|payments:widget||Required to show the Amazon Pay widgets (address and wallet widget) on your page. If used without the parameter below, it gives access to the full shipping address after ConfirmOrderReference call.|
|payments:shipping_address||Gives access to the full shipping address via the GetOrderReferenceDetails API-Call as soon as an address has been selected in the address widget.||Requires scope parameter payments:widget AccessToken set in GetOrderReferenceDetails call.|
Example: scope: profile payments:widget payments:shipping_address
The payments:shipping_address provides access to the buyer's shipping address. To retrieve the full shipping address, you need to call the getOrderReferenceDetails API. For more information, see "Getting the shipping address from Amazon" in Step 2: Add the AddressBook and Wallet widgets or GetOrderReferenceDetails in the Amazon Pay API reference guide.
The popup parameter determines whether the buyer is presented with a pop-up window to authenticate, or if the buyer is instead redirected to an Amazon Pay page to authenticate.
Use one of the following popup parameters:
- true - An Amazon Pay authentication screen is presented in a pop-up dialog where buyers can authenticate without ever leaving your website. This value is recommended for desktops where the button widget is presented on a secure page. Note that this option requires that the button resides on an HTTPS page with a valid TLS/SSL certificate.
- false - The buyer is redirected to an Amazon Pay page within the same browser window. This value is recommended for smartphone optimized devices or if you are rendering the button widget on a non-secure page. Note that the redirect URL must use HTTPS protocol and have a valid SSL certificate. For more information, see Use redirect authentication experience.
Default: popup: true
When you embed an Amazon Pay button with the pop-up parameter set to true, the buyer is asked for their Amazon credentials (email address and password):
As you can see in the previous screenshot, you can add your company logo to the authentication window. You can do this on Seller Central by clicking Settings and then clicking Integration Settings.
The redirect URL is a parameter that determines which page the buyer is redirected to after successfully authenticating. For example, after a successful authentication, you might want to take the buyer to the next page in your checkout pipeline to collect their shipping address and/or payment method details. Note that in case you use "popup:false" in your button code, which means you use the redirect login experience, you have to whitelist all the redirect URLs in Seller central in the Login with Amazon settings for your application.
We also recommend that you implement an onError handler in your code. The onError code is optional, but it can save you considerable effort with troubleshooting integration issues. For more information, see Testing your integration in the Sandbox environment .
After a user has signed in, you should add a logout option (often a hyperlink) to your website. The logout option should delete any cached tokens and remove the user's profile information (like their name) from your website, and then your website can present the Login button again.
Subsequent calls to amazon.Login.authorize present the login screen, by default.