Payment-method icon

AfterPay for API only

Add AfterPay to an existing API-only integration.

Accept AfterPay payments using our APIs, and build your own payment form to have full control over the look and feel of your checkout page.

Before you begin

Before starting your integration:

  1. Contact AfterPay to get access to your test credentials.
  2. Make sure that you have set up your back end implementation.
  3. Add AfterPay in your test Customer Area.

Build your payment form for AfterPay

To make an AfterPay payment, you need to collect the following shopper details:

Name Description
firstName Shopper's first name.
lastName Shopper's last name.
gender Shopper's gender.
dateOfBirth Shopper's date of birth.
telephoneNumber Shopper's phone number.
shopperEmail Shopper's email address.
billingAddress The address where to send the invoice.
deliveryAddress The address where the purchased goods should be delivered.

We provide an AfterPay logo which you can use in your payment form. For more information, refer to Downloading logos.

Make a payment

From your server, make a /payments request, specifying:

  • paymentMethod.type: afterpay_default
  • shopperName.firstName: Shopper's first name.
  • shopperName.lastName: Shopper's last name.
  • shopperName.gender: Shopper's gender: MALE or FEMALE
  • telephoneNumber: Shopper's telephone number.
  • shopperEmail: Shopper's email address.
  • dateOfBirth: Shopper's date of birth.
  • billingAddress: The address where to send the invoice.
  • deliveryAddress: The address where the purchased goods should be delivered.
  • shopperIP: The shopper's IP address. AfterPay uses this for risk checks.
  • lineItems: Price and product information about the purchased items. This is included on the invoice that AfterPay sends to the shopper.

The /payments response contains:

  • resultCode: Use this to present the payment result to your shopper.
  • pspReference: Our unique reference for the payment.
  • merchantReference: Your reference from the /payments request.

Present the payment result

Use the  resultCode that you received in the /payments response to present the payment result to your shopper.

The resultCode values you can receive for AfterPay are:

resultCode Description Action to take
Authorised The payment was successfully authorised. Inform the shopper that the payment was successful.
After the goods have been sent, you also need to capture the payment.
Cancelled The shopper cancelled the payment. Ask the shopper whether they want to continue with the order, or ask them to select a different payment method.
Pending The shopper has completed the payment but the final result is not yet known. Inform the shopper that you've received their order, and are waiting for the payment to be completed.
To know the final result of the payment, wait for the AUTHORISATION webhook.
Refused The payment was refused by AfterPay. Ask the shopper to try the payment again using a different payment method.

Capture the payment

After the goods have been sent, you also need to capture the payment. All AfterPay payments have to be manually captured, even if you have enabled automatic capture for other payment methods. Capturing the payment is what triggers the invoice to be sent to the shopper.

If you want to set up automatic capture for AfterPay payments, contact our Support Team.

Partial captures

To partially capture an AfterPay payment, specify in your /capture request:

  • modificationAmount: The amount that the shopper should pay. 
  • additionalData.openinvoicedata: Price and product information for the items that the shopper should pay for.

Although the field names are different, the information in additionalData.openinvoicedata is the same as what you provided in lineItems when making a /payments request:

openinvoicedata lineItems Description
itemAmount amountExcludingTax The price for one item, without the tax, in minor units.
itemVatAmount taxAmount The tax amount for one item, in minor units.
itemVatPercentage taxPercentage The tax percentage, in minor units.

The following example shows how to make a partial capture request if the shopper only kept one pair of socks from the two included in the original payment request.

Any unclaimed amount that is left over after partially capturing a payment is automatically cancelled. When your account is enabled for multiple partial captures, the unclaimed amount after an initial capture is not automatically cancelled.

To set up multiple partial captures, contact our Support Team . Multiple partial captures will create a new invoice for each capture. 

If you are using partial captures for AfterPay, include the acquirer reference in your standard webhooks. You will then receive the acquirerReference in the additionalData of a CAPTURE webhook. Store this reference, as you will need it when making a (partial) refund request.

Refunds and cancellations

If an AfterPay payment has not yet been captured, you can cancel it. If the AfterPay payment has already been captured and you want to return the funds to the shopper, you need to refund it.

Partial refunds

To partially refund an AfterPay payment, specify in your /refund request:

  • modificationAmount: The amount to be refunded to the shopper.
  • additionalData.acquirerReference: The acquirerReference of the capture. This is needed if there are multiple partial captures available for the payment. When refunding in your Customer Area, you can add the acquirerReference manually as well.
  • additionalData.openinvoicedata: Price and product information about the returned items.

Although the field names are different, the information in additionalData.openinvoicedata is the same as what you provided in lineItems when making a /payments request:

openinvoicedata lineItems Description
itemAmount amountExcludingTax The price for one item, without the tax, in minor units.
itemVatAmount taxAmount The tax amount for one item, in minor units.
itemVatPercentage taxPercentage The tax percentage, in minor units.

The following example shows how to make a partial refund request if the shopper returned the shoes included in the original payment request.

Test and go live

To receive your test credentials, contact AfterPay. After reviewing your test transactions, AfterPay will provide you with the credentials for processing live transactions.

Before you can accept live AfterPay payments, you need to submit a request for AfterPay in your live Customer Area, and provide us your AfterPay live credentials.

You can check the status of the test payments in your Customer Area > Transactions > Payments.

See also