Learn how to specify Afterpay as a payment source in a Square Payments API (CreatePayment endpoint) request.
Payments API

Afterpay and Clearpay Payments

Applications can take Afterpay payments (Clearpay in the UK) using the Web Payments SDK or any of the in-person payment solutions and the Payments API. Square facilitates the payment with Afterpay and deposits the funds in the Square Balance of the seller. The seller receives the full amount without having to wait for the buyer to pay all Afterpay installments.

This topic explains how to use the Payments API (CreatePayment endpoint) to accept Afterpay payments.

In a CreatePayment request, you specify a payment token that represents Afterpay as the payment source. You get this token from the Square Web Payments SDK. Therefore, creating a payment is a two-step process:

  1. Generate a payment token. Web applications integrate the Web Payments SDK client-side library to take payment information from buyers and generate a secure payment token. When the buyer chooses Afterpay as the payment method, the SDK provides the necessary UI for the buyer to log in to Afterpay and obtains the necessary information for authorization. For more information about how to generate a payment token, see Take an Afterpay Payment.

    Note

    The Square Web Payments SDK displays the Afterpay payment option only if the seller is eligible. Eligibility can be checked using the Web Payments SDK. For more information, see Check for eligibility and limitations.

  2. Charge the payment token. The application makes a server-side CreatePayment call to charge the payment token. The amount you charge must be equal to the Afterpay checkout amount (the Web Payments SDK shares the cart information and checkout amount with AfterPay). This is the amount your application must specify when calling CreatePayment.

    The following is an example CreatePayment request. The request charges $100 USD to Afterpay. The source_id you specify identifies Afterpay as the payment source.

    The following is an example response:

    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    {
      "payment": {
        "id": "LdEGliYQbua2JINaY5npuXBnD6JZY",
        "created_at": "2021-11-30T16:54:22.271Z",
        "updated_at": "2021-11-30T16:54:22.492Z",
        "amount_money": {
          "amount": 10000,
          "currency": "USD"
        },
        "status": "COMPLETED",
        "delay_duration": "PT168H",
        "source_type": "BUY_NOW_PAY_LATER",
        "location_id": "7WQ0KXC8ZSD90",
        "order_id": "86wAYurd4ugT2BpnNptXanXnVhdZY",
        "total_money": {
          "amount": 10000,
          "currency": "USD"
        },
        "approved_money": {
          "amount": 10000,
          "currency": "USD"
        },
        "receipt_number": "LdEG",
        "receipt_url": "https://squareupsandbox.com/receipt/preview/LdEGliYQbua2JINaY5npuXEXAMPLE",
        "delay_action": "CANCEL",
        "delayed_until": "2021-12-07T16:54:22.271Z",
        "application_details": {
          "square_product": "ECOMMERCE_API",
          "application_id": "sq0ids-cH-HBFPwv9peECeXONN_uw"
        },
        "buy_now_pay_later_details": {
          "brand": "AFTERPAY",
          "afterpay_details": {
            "email_address": "user@email.com"
          }
        },
        "version_token": "3SM0bM7g6eZlfhgAOZV9kL8sgoGDBDOcA2VnkiHRnjx6o"
      }
    }
    

    In the response, note the following:

    • source_type. Indicates the payment source as "BUY_NOW_PAY_LATER".

    • buy_now_pay_later_details. This object appears in the resulting Payment only for the Afterpay payments.

    • The email_address is the email of the Afterpay account holder (the buyer making the purchase).

When charging Afterpay using CreatePayment, the following apply:

  • Application developers should ensure that Afterpay supports their merchant category code (MCC). Each seller location has an MCC that describes the types of goods or services sold at that location. Certain MCCs are not supported by Afterpay (see Check for eligibility and limitations). In such cases, the Web Payments SDK does not display Afterpay as a payment option.

  • The Web Payments SDK shows the Afterpay payment option only if the following is true:

    • The seller is eligible for Afterpay. For more information, see Check for eligibility and limitations.

    • The checkout amount is within the min/max limit set by Afterpay. Afterpay sets a min/max payment limit for each seller. This limit applies to each checkout amount. When a buyer is ready to check out, the Web Payments SDK shows the Afterpay payment option only if the checkout amount is within this range.

  • Currently, only the Web Payments SDK supports Afterpay as a payment source. Your web application must integrate the SDK to take Afterpay payments.

  • There are Afterpay-specific payment size limits, which differ by region. For more information, see Monetary amount limits.

  • For credit card payments, authorization indicates that the buyer has enough funds on the card (credit cards have limits). In the case of card payments, authorization puts a hold on the specific amount.

    In the context of an Afterpay payment, authorization means that the buyer is charged the first installment by Afterpay and the installment plan is started.

  • Afterpay allows refunds up to 120 days from the date of purchase.

  • Afterpay is currently available in the United States and Australia.

You have the following options for testing Afterpay in the Square Sandbox:

  • Test only the server-side Payments API. Square provides fake payment tokens that represent the Afterpay payment source (see Payment tokens for Afterpay payments). You can provide a fake payment token in a CreatePayment request in the Square Sandbox. The resulting Payment object includes details specific to the Afterpay payment.

  • Test the end-to-end application flow. In this case, do the following:

    1. Create an Afterpay test customer account. Use this test account to log in to Afterpay. For more information about creating an Afterpay test account and fake credit card, see Afterpay Sandbox Guide.

    2. Set up a web application. In the web application, you integrate the Web Payments SDK. For more information, see Take an Afterpay Payment.

    3. Use the Afterpay-provided fake credit card to make a card payment to Afterpay. After the buyer confirms the entire installment plan and provides a credit card for the first installment, Afterpay returns the confirmation to the Web Payments SDK. The SDK then generates a payment token.

    4. Create a payment using the Payments API. The application calls CreatePayment (Payments API) in the Square Sandbox by specifying the payment token.

Note

These Sandbox payments can be captured, voided, and refunded in the Square Sandbox. However, the Afterpay Sandbox environment does not reflect these updates.

If you need more assistance, contact Developer Support or ask for help in the Developer Forums.