For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
HomeGuides
HomeGuides
  • About Afterpay
    • What Is Afterpay?
    • How Does Afterpay Work?
  • Afterpay Button
    • Afterpay Messaging
  • Express Checkout
    • Express Checkout Overview
    • Adding the Afterpay Express Checkout Button
    • Process The Credit Card
    • Complete the Express Checkout Process
    • Integrated Shipping
    • Checkout Widget
  • Cash App Pay
    • Using the Cash App Pay Button
    • Getting Started
    • Advanced Rendering Control
    • Mobile Redirection
    • Customer On-File Payments
LogoLogo
On this page
  • The onComplete Callback
  • Data Objects
Express Checkout

Process the Credit Card

Was this page helpful?
Previous

Complete the Express Checkout Process

Next
Built with

When the customer clicks the Afterpay, or Clearpay (UK), or Cash App Afterpay (US) checkout button, a popup appears and they are prompted to login and review their order details. They can choose a payment method and delivery address, and, if you are using Integrated Shipping, they see shipping options for that address.

Once the customer confirms their details, the popup closes and the customer returns to your site. Your page is notified of the completion through the onComplete callback.

The onComplete Callback

This property allows you to define a custom function that is called when the Afterpay or Clearpay (UK), or Cash App Afterpay (US) checkout is completed. This function is passed an event with a data property. This property contains the virtual card object and status as sub-properties.

All successful checkouts have a status of “SUCCESS”.

event.data.status = "SUCCESS".

Customer Experience Notes

The best customer experience comes from hiding the credit card information and auto-submitting the order within the onComplete function.

You will need to modify the code sample below to match your credit card fields.

1onComplete: function (event) {
2 const { status, virtualCard, token, authToken } = event.data;
3 // The customer confirmed the payment schedule.
4 // The virtualCard details can be inserted into your checkout
5 if (status === 'SUCCESS') {
6 const { cardNumber, cvc, expiryMonth, expiryYear } = virtualCard;
7 document.getElementById('creditCardNumber').value = cardNumber;
8 document.getElementById('creditCardCvc').value = cvc;
9 document.getElementById('creditCardExpiryMonth').value = expiryMonth;
10 document.getElementById('creditCardExpiryYear').value = expiryYear;
11 // Trigger the submit of your credit card form for the customer
12 document.getElementById('creditCardForm').submit()
13 } else {
14 // The customer cancelled the payment or closed the popup window.
15 }
16};

Authorize the virtual card less than 60 minutes after the card is returned to the merchant.

Note

Billing Address - You can use the customer’s address as the Billing Address for the credit card.

Data Objects

Virtual Card Object

AttributeTypeDescription
cardTypestringVisa (US, UK, CA) or Mastercard (AU)
cardNumberstring16 digit card number
e.g. 4111 1111 1111 1111
cvcstringe.g. 123
expiryMonthStringe.g. 12
expiryYearStringe.g. 2022

Checkout Tokens

AttributeTypeDescription
tokenstringThe Afterpay, Clearpay, or Cash App Afterpay Order Token
authTokenstringThe Virtual Card Auth Token
Note

The information on this page also applies to Cash App Afterpay (US) and Clearpay (UK).