Buy with Prime UI Library Reference
Buy with Prime API is now available for early access
Sign up for early access to the Buy with Prime API using the 'Sign Up' button below. The API may change as Amazon receives feedback and iterates on it.
Buy with Prime offers a UI library that includes ready-to-use custom web components that you can use to incorporate Buy with Prime into your website. The library contains two main modules: the delivery card and the Prime benefit card. This topic describes the fields of the delivery-card
and prime-benefit-card
components.
Incorporate the library into your web application and populate the components with information that you get by using Buy with Prime interfaces. To provide a consistent display of Buy with Prime features, you must use the Buy with Prime UI library instead of creating your own UI elements.
To use the Buy with Prime UI library, you must first integrate Login with Amazon (LWA) with your site.
delivery-card
delivery-card
You use the delivery-card
component to render a delivery card on your site. Delivery cards display shopper-level information such as the shopper’s name, a delivery estimate, the number of items that are eligible for Buy with Prime, and a sign-in link to let the shopper sign in using their Amazon account credentials through Login with Amazon (LWA).
You can use this delivery cards in cart pages and checkout pages.
For delivery card code examples, see Delivery Card Examples.
Fields
Field | Type | Required | Description |
---|---|---|---|
lwaConfig | LwAConfig | No | The LWA configuration for integrating LWA into your site. You must provide an lwaConfig to the delivery-card both before and after a shopper signs in. For details about how to integrate Login with Amazon into your site, see Integrate Login with Amazon with Your Site. |
shopperInfo | ShopperInfo | No | The shopper's Amazon customer profile data. You must have this information if you want to personalize the delivery card for the shopper after they sign in. Examples of this information are their name and whether they are a Prime member. For details about how to get shopper information from LWA, see Customer Profile. |
deliveryOffers | DeliveryOffer | No | The delivery offers for the items in the cart or order, which you use to show the delivery estimate information in the delivery card. If multiple deliveryOffers are present in deliveryGroups , the delivery card doesn’t render the delivery estimate message. |
numberOfPrimeItems | Int | No | The number of items in the cart or order that are eligible for Buy with Prime. |
loading | Boolean | No | A flag that indicates whether the delivery card shows a loading widget to shopper. The default value is false. |
showAuthenticatedCard | Boolean | No | A flag that indicates whether to display the delivery card on the site after the shopper signs in. If true, the delivery card is displayed. The default value is true. |
clickStreamTenantId | String | No | An ID, if you want to track metrics. |
prime-benefit-card
prime-benefit-card
The Prime benefit card displays item-level information such as returnability, a delivery estimate, and whether the item is eligible for Buy with Prime. You can use this component to render the Prime benefit card in cart or checkout pages on your site.
For Prime benefit card code examples, see the following topics:
- Prime Benefit Card Examples for Signed-In Prime Members
- Prime Benefit Card Examples for Other Scenarios
Fields
Field | Type | Required | Description |
---|---|---|---|
isShopperPrime | Boolean | No | A flag that indicates whether the shopper is a Prime member. This field can have the following values:
The shopper is considered to be a Prime member if the |
isItemBuyable | Boolean | No | A flag that indicates if the item or group of items is eligible for Buy with Prime. This field can have the following values:
To determine whether an item is eligible for Buy with Prime, you use the Buy with Prime Catalog interface. For an example, see Get the buyability status of a product. An item is considered eligible for Buy with Prime if the buyability status is |
isItemReturnable | Boolean | No | A flag that indicates if the Buy with Prime item or group of items is returnable.
To determine whether an item is returnable, you use the Buy with Prime Return interface. For examples, see Get Reversal Offers. An item is considered returnable if the title in |
deliveryOffer | DeliveryOffer | No | The delivery offer for the item or items in the same group. If a delivery estimate message is present, the Prime benefit card displays the message. |
loading | Boolean | No | A flag that indicates whether the Prime benefit card shows a loading widget to the shopper. This field can have the following values:
|
clickStreamTenantId | String | No | An ID, if you want to track metrics. |
Types
The following section describes types that the delivery-card
component or prime-benefit-card
component use.
LwAConfig
LwAConfig
This type contains the LWA configuration for integrating LWA into your site. You must provide an lwaConfig
to the delivery-card
both before and after a shopper signs in. For details about how to integrate Login with Amazon into your site, see Integrate Login with Amazon with Your Site.
Field | Type | Required | Description |
---|---|---|---|
clientId | String | Yes | The merchant's LWA client ID. You can find this in the merchant's LWA security profile. |
redirectUrl | String | Yes | The URL where shoppers are redirected after they successfully sign in. Note that LWA only allows redirection to fully qualified URLs that you add as Allowed Return URLs to your LWA security profile. If you attempt to use a non-allowlisted |
signOutCallback | Callback function | Yes | A callback function that is run when the shopper signs out. You can use this function to handle sign-out logic, such as clearing any shopper state stored on the merchant's side. |
state | String | No | An opaque value used by the client to maintain the state between this request and the response. The authorization service includes this value when redirecting the user back to the client. It is also used to prevent cross-site request forgery (CSRF). |
showSignInWindowAsPopup | Boolean | No | A flag that indicates whether the LWA sign-in window uses a popup or redirects the shopper to a new page (the If you choose to enable popups, be aware that not all browsers support popups. We therefore recommend that you use a redirect mechanism. For details, see Handle redirects. Be sure to set the domain of the site where the pop-up window is shown as an Allowed Origin in your security profile. |
codeChallenge | String | No | A parameter that you can use to secure authorization code grants through Proof Key for Code Exchange (PKCE). |
codeChallengeMethod | String | No | A parameter that you can use to specify what method you used to encode the code_verifier , which is passed through the codeChallenge . Don't provide this value if you didn't provide a codeChallenge . |
ShopperInfo
ShopperInfo
This type represents the shopper’s Amazon customer profile data, including the shopper's name, email, and Prime membership status. This information personalizes the delivery card for the shopper, such as displaying their name after they sign in.
For details on how to get this shopper information, see Customer Profile.
Field | Type | Required | Description |
---|---|---|---|
name | String | Yes | The shopper's name. |
email | String | Yes | The shopper's email address. This email address is displayed in a sign-out modal. |
isPrime | Boolean | Yes | A flag that indicates whether the shopper is a Prime member. |
The following image shows some examples of how shopper information is displayed.
DeliveryOffer
DeliveryOffer
This type represents a delivery offer that includes a delivery estimate message or an error code from the deliveryPreview
query. For an example, see Sign-in link, number of items offered through Buy with Prime, and a delivery estimate.
Field | Type | Required | Description |
---|---|---|---|
message | String | No | The delivery estimate message for the item. |
errorCode | String | No | The error code, such as InvalidDestination and InvalidAddress , returned from the deliveryPreview query. You can use this code to identify specific errors related to the delivery estimate, which enables you to render the appropriate error message. |
The following example shows an error response from the deliveryPreview
query, which shows the code
you should use.
{
"type": "ValidationError",
"code": "InvalidDestination",
"details": {
"field": null,
"violations": []
},
"errorType": "ValidationException",
"errorCode": 400
}
The following image shows some examples of delivery offers.
Related topics
Updated 9 days ago