Airwallex logo

Afterpay / Clearpay recurring payments

Copy for LLMView as Markdown

When processing a payment for the first time

Step 1: Create a Customer

Create a customer with the Create a Customer API API if the customer is new. Otherwise, this step is optional.

Step 2: Create a Payment Intent

Create a Payment Intent with the Create a Payment Intent API API.

Shell
1curl -X POST https://api-demo.airwallex.com/api/v1/pa/payment_intents/create \
2 -H 'Content-Type: application/json' \
3 -H 'Authorization: Bearer {{ACCESS_TOKEN}}' \
4 -d '{
5 "request_id": "82b8e8b9-795a-4ca2-94e2-76fbc5417d05",
6 "amount": 0,
7 "currency": "AUD",
8 "merchant_order_id": "85d7b0e0-7235-11ea-862e-9f6aa1adfca6",
9 "return_url": "https://www.airwallex.com"
10 }'

If the payment is not intended to charge the shopper for the first time, such as a subscription with a free trial, please set the amount to zero.

You are strongly suggested to send any available order details (including order.shipping) on the Payment Intent to increase the success rate of Afterpay payments. See Desktop/Mobile Website Browser - Afterpay / Clearpay for a sample request body.

Step 3: Confirm the Payment Intent With Consent Info

When you want to redirect the shopper to authorize the consent with Afterpay / Clearpay, call the Confirm a Payment Intent API API with the Payment Consent info to get a redirect URL.

payment_consent.terms_of_use.payment_amount_type must be either FIXED or VARIABLE.

  • If payment_amount_type is FIXED, you must also pass fixed_payment_amount, payment_currency, payment_schedule, and billing_cycle_charge_day.
  • If payment_amount_type is VARIABLE, do not pass those fields.

payment_consent.next_triggered_by must be merchant or customer. payment_consent.merchant_trigger_reason must be scheduled or unscheduled.

payment_method.afterpay.shopper_email is required. payment_method.afterpay.billing is optional; when present you can include fields such as date_of_birth, email, first_name, last_name, phone_number, and address.

By default, auto_capture is true. To set it to false, pass payment_method_options.afterpay.auto_capture.

Example: payment_amount_type is FIXED

Shell
1curl -X POST https://api-demo.airwallex.com/api/v1/pa/payment_intents/{{PAYMENT_INTENT_ID}}/confirm \
2 -H 'Content-Type: application/json' \
3 -H 'Authorization: Bearer {{ACCESS_TOKEN}}' \
4 -d '{
5 "request_id": "fb66c21a-946d-4ed6-869e-3352b44c9cc2",
6 "customer_id": "cus_sgstnkfm8hh1c67xex6",
7 "payment_method": {
8 "type": "afterpay",
9 "afterpay": {
10 "shopper_email": "[email protected]",
11 "billing": {
12 "date_of_birth": "1990-05-15",
13 "email": "[email protected]",
14 "first_name": "Test",
15 "last_name": "Person",
16 "phone_number": "+61412345678",
17 "address": {
18 "country_code": "AU",
19 "state": "NSW",
20 "city": "Sydney",
21 "street": "100 George Street",
22 "postcode": "2000"
23 }
24 }
25 }
26 },
27 "payment_consent": {
28 "next_triggered_by": "merchant",
29 "merchant_trigger_reason": "unscheduled",
30 "terms_of_use": {
31 "payment_amount_type": "FIXED",
32 "payment_currency": "AUD",
33 "fixed_payment_amount": 100,
34 "payment_schedule": {
35 "period": 7,
36 "period_unit": "WEEK"
37 },
38 "billing_cycle_charge_day": 12
39 }
40 },
41 "payment_method_options": {
42 "afterpay": {
43 "auto_capture": false
44 }
45 }
46 }'

Example: payment_amount_type is VARIABLE

Shell
1curl -X POST https://api-demo.airwallex.com/api/v1/pa/payment_intents/{{PAYMENT_INTENT_ID}}/confirm \
2 -H 'Content-Type: application/json' \
3 -H 'Authorization: Bearer {{ACCESS_TOKEN}}' \
4 -d '{
5 "request_id": "fb66c21a-946d-4ed6-869e-3352b44c9cc2",
6 "customer_id": "cus_sgstnkfm8hh1c67xex6",
7 "payment_method": {
8 "type": "afterpay",
9 "afterpay": {
10 "shopper_email": "[email protected]",
11 "billing": {
12 "first_name": "Jim",
13 "last_name": "Shopper",
14 "phone_number": "+61470123456",
15 "address": {
16 "country_code": "AU",
17 "state": "VIC",
18 "city": "Melbourne",
19 "street": "250 Collins Street",
20 "postcode": "3000"
21 }
22 }
23 }
24 },
25 "payment_consent": {
26 "next_triggered_by": "merchant",
27 "merchant_trigger_reason": "unscheduled",
28 "terms_of_use": {
29 "payment_amount_type": "VARIABLE"
30 }
31 }
32 }'

Once the shopper completes the payment, the Payment Consent will be verified automatically, and Airwallex will notify you of the Payment Consent status asynchronously via the webhook. Please refer to the webhook documentation to set up your webhook accordingly.

Sample response (first payment / consent flow):

JSON
1{
2 "id": "int_sgsthdj5ghhnow9qovr",
3 "request_id": "91a84dcb-aa7f-4815-be4a-e94558591f3b",
4 "amount": 0,
5 "currency": "AUD",
6 "payment_consent_id": "cst_sgstwg7b7hhnow9wc5l",
7 "status": "REQUIRES_CUSTOMER_ACTION",
8 "captured_amount": 0,
9 "created_at": "2026-04-16T10:18:21+0000",
10 "updated_at": "2026-04-16T10:18:29+0000",
11 "payment_consent": {
12 "initial_payment": false,
13 "next_triggered_by": "merchant",
14 "merchant_trigger_reason": "unscheduled",
15 "terms_of_use": {
16 "payment_amount_type": "VARIABLE"
17 }
18 },
19 "next_action": {
20 "type": "redirect",
21 "method": "GET",
22 "url": "https://api-demo.airwallex.com/pa/redirect/sg/sgst6bnpxhhnoweanu0_w9qovr?checksum=fb73cc594cb2"
23 },
24 "return_url": "https://www.airwallex.com/"
25}

When initiating a subsequent transaction

Step 1: Initialize a Payment Intent

When you are ready to process the subsequent recurring payment, create a Payment Intent with the Create a Payment Intent API API.

Shell
1curl -X POST https://api-demo.airwallex.com/api/v1/pa/payment_intents/create \
2 -H 'Content-Type: application/json' \
3 -H 'Authorization: Bearer {{ACCESS_TOKEN}}' \
4 -d '{
5 "request_id": "ed11e38a-7234-11ea-aa94-7fd44ffd1b89",
6 "amount": 100,
7 "currency": "AUD",
8 "merchant_order_id": "85d7b0e0-7235-11ea-862e-9f6aa1adfca6",
9 "return_url": "https://www.airwallex.com"
10 }'

Step 2. Complete payment with verified consent

Confirm the subsequent payment with the verified Payment Consent by calling the Confirm a Payment Intent API API.

Sample request:

Shell
1curl -X POST https://api-demo.airwallex.com/api/v1/pa/payment_intents/{{PAYMENT_INTENT_ID}}/confirm \
2 -H 'Content-Type: application/json' \
3 -H 'Authorization: Bearer {{ACCESS_TOKEN}}' \
4 -d '{
5 "request_id": "b9c01d9f-493d-4362-a7f2-c46989814b24",
6 "payment_consent_id": "cst_sgstwg7b7hhnow9wc5l"
7 }'

Sample response:

JSON
1{
2 "id": "int_sgst7h5p4hh1e9dhcvo",
3 "request_id": "b9c01d9f-493d-4362-a7f2-c46989814b24",
4 "amount": 100,
5 "currency": "AUD",
6 "merchant_order_id": "bae8fca0-c571-4cc3-9a74-af197835ebff",
7 "status": "PENDING",
8 "captured_amount": 0,
9 "created_at": "2026-03-27T04:58:57+0000",
10 "updated_at": "2026-03-27T04:59:00+0000",
11 "return_url": "https://www.airwallex.com/",
12 "base_amount": 100,
13 "base_currency": "AUD"
14}
Was this page helpful?