Express checkout has similar behaviour across both deferred and integrated shipping. The sequence diagram below shows a high-level checkout sequence for a customer using integrated shipping.
afterpay.js to direct the customer through the Afterpay Express checkout flow using the popup method.onShippingAddressChange() callback function on the merchant site to retrieve all shipping options and taxes for the chosen address.onComplete() callback function.Integrated Shipping is enabled by default for Express orders. To disable it, set shippingOptionRequired to false.
Integrated and Deferred Shipping
Flow Diagram Key
InitializeForPopup only
addressMode: ADDRESS_WITH_SHIPPING_OPTIONS - no widget needed.
This is the default configuration.
Within the Afterpay Checkout flow, the customer can:
The merchant must:
onShippingAddressChange and provide the relevant shipping options.Recommended: for orders that need to be shipped to the customer’s address and have up to five simple shipping options
addressMode: PICKUP_FROM_ORDER_ADDRESS - no widget needed.
Within the Afterpay Checkout flow, the customer can:
The merchant must:
Send pickup address when creating an order token
Listen to the onShippingAddressChange and provide the relevant pickup options
Recommended for orders picked up at a specific location (e.g. your physical store)
addressMode: SHIP_TO_ORDER_ADDRESS - no widget needed.
Within the Afterpay Checkout flow, the customer can:
See their chosen order address from the merchant site (but not change it)
View shipping options from the merchant and select one Complete the order
The merchant must:
Send shipping address when creating an order token
Listen to the onShippingAddressChange and provide the relevant shipping options
Recommended for orders to be shipped to the customer’s address chosen on your site (before launching Express Checkout). In this case, the address displayed within the Afterpay checkout flow is locked and customers cannot change it.
initializeForPopup or initializeForRedirect
addressMode: NO_ADDRESS - no widget needed.
Within the Afterpay Checkout flow, the customer can:
Customers cannot do the following actions within the Afterpay checkout flow
Recommended for when there is no shipping or pickup needed (eg.digital goods or services).
addressMode: SHIP_TO_ORDER_ADDRESS_WITHOUT_SHIPPING_OPTIONS - no widget needed.
Within the Afterpay Checkout flow, the customer can:
Customer cannot do the following actions within the Afterpay checkout flow:
The merchant must:
Recommended for orders that must be shipped to the customer’s address chosen on your site (before launching Express Checkout), and there are no shipping options available for customers to choose from.
afterpay.js uses the HTML postMessage() API to exchange information between the Afterpay checkout popup and the page that spawned it. This allows Javascript code running on different origins to communicate with each other in a bidirectional manner.
The bidirectional communication allows a merchant to dynamically update shipping options and transaction information based on a chosen shipping address.
afterpay.js hides this complexity and restricts the use of postMessage() to ensure a secure environment. Specifically:
Afterpay’s checkout window only receives messages from the merchant window, and vice versa
Correctly handles multiple concurrent, and possibly out-of-order requests
Message data is validated and sanitized
Using postMessage() in this way is considered very secure. For more information please refer to the specification.