AfterPay

Besides basic order data, for an AfterPay order the following extra details are required:

  • Order lines data – will indicate quantities, type of article and prices of distinct articles of an order.
  • Customer data – will be used by AfterPay system for screening.

Example of a minimally required payload:

{
  "amount": 100,
  "currency": "EUR",
  "customer": {
    "additional_addresses": [
      {
        "address": "Donauweg 10\n1043AJ Amsterdam",
        "address_type": "billing",
        "country": "NL"
      }
    ],
    "address": "Donauweg 8\n1043AJ Amsterdam",
    "address_type": "customer",
    "birthdate": "1990-07-10",
    "country": "NL",
    "email_address": "email@example.com",
    "first_name": "First",
    "gender": "female",
    "ip_address": "127.0.0.1",
    "last_name": "Last",
    "locale": "nl",
    "phone_numbers": [
      "0612345678"
    ]
  },
  "description": "Example AfterPay order",
  "order_lines": [
    {
      "type": "digital",
      "amount": 100,
      "currency": "EUR",
      "merchant_order_line_id": "0001",
      "name": "Example article",
      "quantity": 1,
      "type": "physical",
      "vat_percentage": 2100
    }
  ],
  "transactions": [
    {
      "payment_method": "afterpay"
    }
  ]
}

Customer data should include preferred locale, possible locales are: nl, de, nl-BE, fr-BE, en-GB. The order line type must be one of physical, discount, shipping_fee, sales_tax, digital, gift_card, store_credit or surcharge.

AfterPay screening and order statuses

AfterPay will use the basic customer data to decide if an order could be created. If AfterPay will decline certain payment of a customer, then created order will have status cancelled. If customer will successfully pass the screening, then created order will have status accepted.

AfterPay transactions capturing

It is possible to use API to capture AfterPay orders. You need to send a request after you have shipped the goods to the customer.

Request example:

POST /v1/orders/<order_id>/transactions/<transaction_id>/captures/ HTTP/1.1
Authorization: Basic aHVudGVyMjo=

When you create a new AfterPay order, in the response you have list of transactions, which contains one transaction. You need to use ID of this transaction to send the capture request.

Body for this request should be left empty.

Requesting refunds for AfterPay

Request for AfterPay refund differs from other payment methods – it is necessary to provide order_lines data.

Example:

POST /v1/orders/4c6afd74-a840-4aab-b411-1e6e0636d341/refunds/ HTTP/1.1
Authorization: Basic aHV0dGVyMgo=

{
  "order_lines": [
    {
      "merchant_order_line_id": "0001",
      "quantity": 1
    }
  ]
}

Please see the general refunds reference for the request schema and a response example.

Note: It is possible to refund an AfterPay order only if it has been captured previously. Before capturing, instead of refund, it’s possible to cancel an order. Please see the general reference for the order cancellation example (/orders/ endpoint DELETE method).

Testing

When your project is configured for testing you can test Afterpay with the examples.