This feature improves the customer experience by embedding your shipping options directly into the Express Checkout flow. It streamlines the checkout process and can be combined with the buyNow flag to create a one-step checkout that immediately precedes the order confirmation page.
We recommend the Integrated Shipping flow for merchants with:
It requires shippingOptionRequired to be true (enabled by default) and an onShippingAddressChange callback must be defined:
Integrated Shipping is enabled by default for Express orders. To disable it, shippingOptionRequired must be set to false.
The shipping address change callback is required:
You, the merchant, manage how the shipping options are calculated. Javascript can calculate the options, or you can pass them to an internal API.
If shipping options are available for the given address, use the resolve action to return them to Afterpay, Clearpay (UK) or Cash App Afterpay (US) - see the code example below. Similarly, use the reject action when shipping is unavailable.
Afterpay calls your onShippingAddressChange function when:
Afterpay provides the following parameters to your onShippingAddressChange function:
data parameter: This contains the customer’s selected address with fields:
suburb, state, postcode, and countryCodeaction parameter: This object is used to return your response to the Afterpay checkout. It consists of the following methods:
resolve : Call this method to provide the shipping options applicable to the customers address. Takes an array of Shipping Option objects.reject : Call this method when you are unable to handle the request. Do not throw an error, instead call this method with a Shipping Constant as the first argument to indicate a status, e.g.:To indicate a number of error scenarios, actions.reject() may be invoked with a provided constant.
These are of the form AfterPay.constants.<NAME>, where <NAME> is one of:
Afterpay Express Checkout does not perform any arithmetic. It is the responsibility of your web app to calculate the correct total. Each shipping option must have a total order amount including taxes and shipping.
The onShippingOptionChange callback allows a merchant to track the customer’s chosen shipping option as it changes. It is optional, and is called each time a customer selects a shipping option. This function is passed one argument: data
data parameter (object): This contains the customer’s selected shipping option, as provided in the response from onShippingAddressChange, with fields:
When the Express Checkout is complete, you may either authorize the virtual credit card provided by Afterpay or continue checkout on your review page. If you completing the order immediately, set the buyNow flag to true - this shows the customer a “Buy Now” button at the end of their Afterpay journey.
You can modify the Express Checkout experience for Click & Collect and other pickup flows by following these steps:
Allow your customers the ability to choose pickup options before they select Afterpay Express. This should include any decisions that may affect the cost of delivery, for instance pickup location and date.
If the customer has opted for pickup, provide the chosen pickup address when adding the shipping attributes.
When you include the expressCheckout object attribute:
Set the pickup flag to true.
Configure your onShippingAddressChange handler to return the name and description of their pickup choice. This will likely mean returning only a single option — e.g
You can collect additional information regarding the pickup, e.g. selecting another person to pick up the order, at your order review page. These details must not increase the order total.
The information on this page also applies to Cash App Afterpay (US) and Clearpay (UK).