Create a Checkout
There are three steps to create a Clearpay checkout:
- Call Get Configuration to retrieve your order limits
- Call Create Checkout to generate a checkout token
- Redirect the customer to Clearpay to complete the checkout flow
Retrieve your order limits
Call the Get Configuration endpoint to retrieve your minimum and maximum Clearpay order amounts.
We recommend calling this endpoint once a day as part of a scheduled background process, and storing the minimumAmount and maximumAmount values on your server.
Use these values to determine:
- The correct Clearpay Messaging to show on the Product Detail pages
- Whether Clearpay should be presented as an available payment method
A request to create a checkout will be declined if the order grand total is less than the minimum or more than the maximum Clearpay amount. To change your minimum and maximum order values, contact Clearpay.
Create a checkout
Call the Create Checkout endpoint to communicate the order details to Clearpay. Your request should include:
- Customer information
- Order details
- Order total
- Shipping details
- Redirect URLs
Clearpay responds with a token used to identify this checkout.
For example, 002.5lmerr3k945d00c7htvcrdff83q36kp10a247m212fjpa5ju. This token is used to launch the Clearpay checkout flow using Afterpay.js.
Afterpay.js
Set up your checkout experience
Use the redirect method to launch the Clearpay checkout flow. Customers are redirected from your website to Clearpay to complete their payment. At the end of the Clearpay checkout flow, the customer is redirected back to your website.
Implement the redirect method
To use the redirect method, call the following two JavaScript functions, in order:
Afterpay.initialize: Prepares the JavaScript to start the Clearpay screenflow in the appropriate geographical region.- Accepts an object with a required
countryCode(use “GB” for United Kingdom)
- Accepts an object with a required
Afterpay.redirect: Redirects the customer’s browser from your website to Clearpay.- Accepts an object with a required
token(the checkout token returned by the Create Checkout API call)
- Accepts an object with a required
If the customer successfully completes the checkout flow, they’re returned to your redirectConfirmUrl with a checkout token and a SUCCESS status appended as HTTP query parameters: www.merchant-example.com/confirm?&status=SUCCESS&orderToken=002.5lmerr3k945d00c7htvcrdff83q36kp10a247m212fjpa5ju
If the customer cancels the checkout, they’re returned to your redirectCancelUrl with a checkout token and a CANCELLED status appended as HTTP query parameters: www.merchant-example.com/confirm?&status=CANCELLED&orderToken=002.5lmerr3k945d00c7htvcrdff83q36kp10a247m212fjpa5ju