You must show an Afterpay, Clearpay (UK) or Cash App Afterpay (US) checkout button on your cart and/or product pages to enable Express Checkout. When clicked, the checkout button starts the checkout process in a popup flow.
There is a selection of buttons available for each stage of the checkout. Each button clearly shows the customer what the following action is. Examples of these buttons are:
Product Page/Shopping Cart
Order Placement
Product Page/Shopping Cart - US Only
Order Placement - US Only
Product Page/Shopping Cart - UK Only
Order Placement - UK Only
When the text attribute is not provided, the button displays the “Buy now with Afterpay” option, or in the US, “Buy now with Cash App Afterpay.”
Import the AfterpayButton.js script as a script tag.
Insert the following HTML to initialize the afterpay-button element.
You will need your merchant public key, which is provided by Afterpay. Your public key is used solely to identify your account with Afterpay. They aren’t secret. In other words, they can safely be published in places like your JavaScript code, or in an Android or iPhone app.
Afterpay can be launched from different entry points (product-page, mini-cart, cart) in the customer journey. To enable the express checkout flow, set the following attributes:
Before a customer can checkout with Afterpay, we need to know, at a minimum:
Merchant Reference - The merchant’s unique order id/reference that this payment corresponds to. This is used to reconcile orders in the Afterpay merchant portal.Amount - The total amount of the order to be charged to the customer. This includes any shipping and tax, minus any discounts. This is the maximum amount that you can charge to the virtual Visa Card.Currency - The currency in ISO 4217 format. The value provided must correspond to the currency of the Merchant account making the request.Consumer details - The customer’s phone number, name, and email addressShipping details - The shipping name and shipping addressItems - This contains information about the line items in the order.This shows the customer a “Buy Now” button at the end of the Afterpay checkout flow

When this flag is not set the button displays “Confirm”
Increase Conversion Rates
Providing customer details allows new customers to speed through checkout with prepopulated name and address fields.
If the customer has chosen to pick up the order in a store, no shipping address is required, instead, set instorePickup to true.
This contains information about a line item in the order. The value given to the afterpayButton.items is a string. To pass line item details an array of item objects should be provided using JSON.stringify.
afterpayButton.items= JSON.stringify(itemsArray);
Within the listener event, attach an expressCheckout object attribute with the following configurations:
Set region to the two-character ISO 3166-1 country code of the Merchant account
Set the flag shippingOptionRequired to:
false: if shipping options are not required to be displayed in the Express Checkout flowtrue: if you intend to provide shipping options to to the customer within the Express Checkout flow (i.e. Integrated Shipping). This is the default valueHandle lifecycle events:
The information on this page also applies to Cash App Afterpay (US) and Clearpay (UK).