Search

Are you looking for test card numbers?

Would you like to contact support?

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

These instructions explain how to add AfterPay to your existing API-only integration. The API-only integration works the same way for all payment methods. If you haven't done this integration yet, refer to our API-only integration guide.

Before starting your integration:

  1. Make sure that you have set up your back end implementation.
  2. 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 Optional 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 Optional 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.

You can also get the required fields from the /paymentMethods response as explained in our API-only integration guide.

In your /paymentMethods request, specify one of the following combinations of countryCode and amount.currency:

Country countryCode amount.currency
The Netherlands NL EUR
Belgium BE EUR

The required fields for AfterPay are included in the object with type: afterpay_default.

Make a payment

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

  • paymentMethod.type: afterpay_default
  • paymentMethod.personalDetails: Shopper details that you collected in your payment form.
  • paymentMethod.billingAddress: The address where to send the invoice.
  • paymentMethod.separateDeliveryAddress: Set to true to specify a deliveryAddress that is different from the billingAddress.
  • 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.

    {
      "merchantAccount":"YOUR_MERCHANT_ACCOUNT",
      "countryCode":"NL",
      "amount":{
         "currency":"EUR",
         "value":"1000"
      },
      "shopperReference":"YOUR_UNIQUE_SHOPPER_ID",
      "reference":"YOUR_ORDER_NUMBER",
      "channel":"Web",
      "paymentMethod":{
         "type":"afterpay_default",
         "personalDetails":{
            "firstName":"EndToEnd",
            "lastName":"lasTName",
            "gender":"M",
            "dateOfBirth":"2000-02-02",
            "telephoneNumber":"+31612345678",
            "shopperEmail":"test@tester.com"
         },
         "billingAddress":{
            "street":"Simon Carmiggeltstraat",
            "houseNumberOrName":"136",
            "city":"Amsterdam",
            "postalCode":"1011DJ",
            "country":"NL"
         },
         "separateDeliveryAddress":"false"
      },
      "shopperIP":"192.0.2.1",
      "lineItems":[
         {
            "quantity":"1",
            "amountExcludingTax":"331",
            "taxPercentage":"2100",
            "description":"Shoes",
            "id":"Item #1",
            "taxAmount":"69",
            "amountIncludingTax":"400",
            "taxCategory":"High"
         },
         {
            "quantity":"2",
            "amountExcludingTax":"248",
            "taxPercentage":"2100",
            "description":"Socks",
            "id":"Item #2",
            "taxAmount":"52",
            "amountIncludingTax":"300",
            "taxCategory":"High"
         }
      ]
    }

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.

{
   "pspReference":"881567437271705K",
   "resultCode":"Authorised",
   "merchantReference":"YOUR_ORDER_NUMBER"
}

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 request that they 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 notification.
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.

{
   "originalReference":"COPY_PSP_REFERENCE_FROM_AUTHORISE_RESPONSE",
   "merchantAccount":"YOUR_MERCHANT_ACCOUNT",
   "modificationAmount":{
      "currency":"EUR",
      "value":"700"
   },
   "additionalData":{
      "openinvoicedata.numberOfLines":"2",
      "openinvoicedata.line1.currencyCode":"EUR",
      "openinvoicedata.line1.description":"Shoes",
      "openinvoicedata.line1.itemAmount":"331",
      "openinvoicedata.line1.itemVatAmount":"69",
      "openinvoicedata.line1.itemVatPercentage":"2100",
      "openinvoicedata.line1.numberOfItems":"1",
      "openinvoicedata.line1.vatCategory":"High",
      "openinvoicedata.line2.currencyCode":"EUR",
      "openinvoicedata.line2.description":"Socks",
      "openinvoicedata.line2.itemAmount":"248",
      "openinvoicedata.line2.itemVatAmount":"52",
      "openinvoicedata.line2.itemVatPercentage":"2100",
      "openinvoicedata.line2.numberOfItems":"1",
      "openinvoicedata.line2.vatCategory":"High"
   },
   "reference":"YOUR_CAPTURE_REFERENCE"
}

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 notifications. You will then receive the acquirerReference in the additionalData of a CAPTURE notification. 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.

{
   "merchantAccount":"YOUR_MERCHANT_ACCOUNT",
   "originalReference":"COPY_PSP_REFERENCE_FROM_AUTHORISE_RESPONSE",
   "modificationAmount":{
      "currency":"EUR",
      "value":"400"
   },
   "additionalData":{
      "openinvoicedata.numberOfLines":"1",
      "openinvoicedata.line1.currencyCode":"EUR",
      "openinvoicedata.line1.description":"Shoes",
      "openinvoicedata.line1.itemAmount":"331",
      "openinvoicedata.line1.itemVatAmount":"69",
      "openinvoicedata.line1.itemVatPercentage":"2100",
      "openinvoicedata.line1.numberOfItems":"1",
      "openinvoicedata.line1.vatCategory":"High"
   },
   "reference":"YOUR_REFUND_REFERENCE"
}

Test and go live

You need to contact AfterPay to get access to test credentials. After reviewing your test transactions, AfterPay will provide you with the credentials for processing live transactions.

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

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.

See also