Use the Buy with Prime UI Library

📘

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.

If you integrate Login with Amazon (LWA) with your site, you can use the Buy with Prime UI library to render Buy with Prime UI elements instead of creating your own UI elements. For details, see Buy with Prime UI Library Reference.

The Buy with Prime UI library offers ready-to-use custom web components in two main modules: the delivery card and the Prime benefit card. You incorporate the library into your web application and populate the components with information that you get by using Buy with Prime interfaces.

To learn how to use the UI library, see Steps to Use the UI Library. For an example of a shopper journey through a site that uses the UI library, see Experience the Shopper Journey with the Buy with Prime UI Library.

Terminology

When you use the Buy with Prime UI library to add Buy with Prime to your checkout flow, you encounter the following terms.

Login with Amazon

Login with Amazon (LWA) allows users to log in to third-party websites and apps by using their Amazon account credentials and grant those third-party websites and apps access to their Amazon customer profile data. LWA is based on the OAuth 2.0 authentication framework.

When you add Buy with Prime to your checkout flow, you use LWA to request access the shopper's profile data. You use this information to call the Buy with Prime API to populate delivery cards, Prime benefit cards, and prefill checkout fields.

For details about how to set up LWA to work with Buy with Prime, see Integrate Login with Amazon with Your Site.

Redirect URL

A redirect URL is the URL to which LWA returns the shopper after they sign in using their Amazon account credentials. You specify the redirect URL in the delivery card and allow-list it as an Allowed Return URL in your LWA security profile. There are two types of redirect URLs:

  • A static URL that doesn’t have any parameters, such as https://www.example.com/checkout.
  • A dynamic URL that has parameters that change, such as for a product detail page (https://www.example.com/product/red-shirt-1) or a cart page with a cart ID in the URL (https://www.example.com/cart/cart-id).

When the shopper is redirected to your site, the redirect URL includes an authorization code that you exchange for an access token. You use the access token to call the Buy with Prime API (for example, to create a delivery preview) and the LWA profile API (to get a shopper token).

For details on handling redirects, see Handle redirects.

Delivery card

A delivery card is an element of the Buy with Prime UI library that displays shopper-level information. The information may include the shopper’s name, a delivery estimate, and the number of items in their order that are eligible for Buy with Prime. It also provides a "Sign in" link to let the shopper sign in to their Amazon account by using LWA. The delivery card also manages requesting access to all the access scopes required to fetch and render details like the shopper’s name and email.

You can display delivery cards in cart or checkout pages. For details about a custom web component that you can use to render delivery cards on your site, see delivery-card.

The following examples show some delivery cards.

  • Before a shopper signs in: The following delivery card displays a sign-in link, a delivery estimate, and the number of items on the page that are eligible for Buy with Prime.

  • After a Prime member signs in: If the shopper is a Prime member, the delivery card displays a Prime badge and the shopper's name.


  • After a shopper without a Prime membership signs in: If the shopper doesn't have an active Prime membership, the delivery card doesn't display a Prime badge.




Prime benefit card

A Prime benefit card is an element of the Buy with Prime UI library that displays item-level information. This information includes the item’s eligibility for Buy with Prime and an item-level delivery estimate.

You can display Prime benefit cards in cart or checkout pages. For information about a custom web component that you can use to render Prime benefit cards on your site, see prime-benefit-card.

The following examples show some Prime benefit cards.

  • Before a shopper signs in: The following Prime benefit card displays a Prime badge that indicates that the item is eligible for Buy with Prime.

  • After a Prime member signs in: If the shopper is a Prime member, the Prime benefit card displays a Prime badge, a delivery estimate, and an indication that returns are free.




Access scope

Access scopes define the types of Amazon customer profile data that a site is requesting. The first time a shopper signs in, they see a list of the items in the access scope and must agree to provide the data to the site in order to proceed. An access token is then granted, which you can use to call the Buy with Prime API to retrieve the customer profile data.

How to get the UI library

Ask your Buy with Prime solutions architect for the Buy with Prime UI library. The library is a pre-built, single-file bundle. The bundle is a standard JavaScript module with no dependencies.

After you receive the pni-web-components.js (for HTML frameworks) or pni-react-components.js file (for React frameworks), put it in your project directory. Ideally, choose a folder that's designated for third-party libraries, such as a ./lib or ./vendor folder.

Related topics