Airwallex logo

Accept Recurring Payments - Touch 'n Go

Copy for LLMView as Markdown

Set up recurring payments with Touch 'n Go eWallet by first linking with the shopper's account through payment consent, then using that consent for future payments without requiring the shopper to re-authenticate each time.

Recurring payments is currently not available for AWX MY merchants.

Linking with the shopper's Touch 'n Go eWallet app for the first time

Step 1: Create a Customer (Optional)

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

Shell
1curl -X POST https://api-demo.airwallex.com/api/v1/pa/customers/create \
2 -H 'Content-Type: application/json' \
3 -H 'Authorization: Bearer {{ACCESS_TOKEN}}' \
4 -d '{
5 "request_id": "2ed2d823-f8b3-416e-86db-ced8770ce217",
6 "merchant_customer_id": "9fafc2fb-4262-4ff8-a205-d60fb4781cb0",
7 "first_name": "John",
8 "last_name": "Doe",
9 "email": "[email protected]",
10 "phone_number": "+60123456789"
11 }'

Example response:

JSON
1{
2 // ... other fields omitted.
3 "id": "cus_uspd6m9zph9g2fjvn1r",
4 "request_id": "2ed2d823-f8b3-416e-86db-ced8770ce217",
5 "merchant_customer_id": "c9fafc2fb-4262-4ff8-a205-d60fb4781cb0",
6 "first_name": "John",
7 "last_name": "Doe",
8 "email": "[email protected]",
9 "phone_number": "+60123456789",
10 "created_at": "2024-01-15T10:30:00Z"
11}

Create a Payment Consent with the Create a Payment Consent API API.

Shell
1curl -X POST https://api-demo.airwallex.com/api/v1/pa/payment_consents/create \
2 -H 'Content-Type: application/json' \
3 -H 'Authorization: Bearer {{ACCESS_TOKEN}}' \
4 -d '{
5 "request_id": "ed11e38a-7234-11ea-aa94-7fd44ffd1b89",
6 "customer_id": "cus_uspd6m9zph9g2fjvn1r",
7 "next_triggered_by": "merchant",
8 "merchant_trigger_reason": "unscheduled"
9 }'

Example response:

JSON
1{
2 // ... other fields omitted.
3 "id": "cst_sgstjgzhsh7hhmj8hr0",
4 "request_id": "ed11e38a-7234-11ea-aa94-7fd44ffd1b89",
5 "customer_id": "cus_uspd6m9zph9g2fjvn1r",
6 "next_triggered_by": "merchant",
7 "status": "REQUIRES_PAYMENT_METHOD",
8 "merchant_trigger_reason": "unscheduled",
9 "created_at": "2024-01-15T10:35:00Z"
10}

Verify the Payment Consent with the Verify a Payment Consent API API to authorize the shopper's Touch 'n Go eWallet for future payments.

Shell
1curl -X POST https://api-demo.airwallex.com/api/v1/pa/payment_consents/{{PAYMENT_CONSENT_ID}}/verify \
2 -H 'Content-Type: application/json' \
3 -H 'Authorization: Bearer {{ACCESS_TOKEN}}' \
4 -d '{
5 "request_id": "139b8ee8-e306-47d6-8d6a-fa586967e5a9",
6 "payment_method": {
7 "type": "tng",
8 "tng": {
9 "flow": "mobile_web",
10 "os_type": "ios"
11 }
12 },
13 "return_url": "https://www.airwallex.com"
14 }'
  • The flow parameter can be "qrcode", "mobile_web", or "mobile_app". When flow is "mobile_web" or "mobile_app", os_type should be "ios" or "android".

Example response:

JSON
1{
2 // ... other fields omitted.
3 "id": "cst_sgstjgzhsh7hhmj8hr0",
4 "request_id": "139b8ee8-e306-47d6-8d6a-fa586967e5a9",
5 "status": "REQUIRES_CUSTOMER_ACTION",
6 "next_action": {
7 "type": "redirect",
8 "method": "GET",
9 "url": "https://cdn.tngdigital.com.my..."
10 }
11}

On mobile, the link will attempt to redirect users to their Touch 'n Go eWallet App. If redirect to an app fails, it will redirect shoppers to bind their account in a mobile web browser login instead.

Redirect the shopper to the URL found in the next_action field so they can complete authorization in their Touch 'n Go eWallet app. After the shopper finishes authorization, the Payment Consent will be automatically verified. Airwallex will notify you asynchronously of the Payment Consent status via webhook. Please refer to the webhook documentation to set up your webhook properly. Be sure to save the id returned in the response, as you will use this verified Payment Consent for future payments.

Initiating future payments

Step 1: Create a Payment Intent

When you are ready to process a 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": "2c343609-5561-4c39-b055-bdaf89176555",
6 "amount": 1,
7 "currency": "MYR",
8 "merchant_order_id": "order_67890",
9 "return_url": "https://www.airwallex.com"
10 }'

Example response:

JSON
1{
2 // ... other fields omitted.
3 "id": "int_hkdmr7v9rg1j58ky8re",
4 "request_id": "2c343609-5561-4c39-b055-bdaf89176555",
5 "amount": 1,
6 "currency": "MYR",
7 "merchant_order_id": "order_67890",
8 "status": "REQUIRES_PAYMENT_METHOD",
9 "created_at": "2024-01-15T11:00:00Z"
10}

Confirm the payment with the verified Payment Consent by calling the Confirm a Payment Intent API API. This allows you to charge the shopper using their previously authorized Touch 'n Go eWallet without requiring them to re-authenticate.

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 "payment_consent_id": "cst_sgstjgzhsh7hhmj8hr0",
6 "request_id": "a7f3e2d1-9c4b-4e8a-b5f6-3d2c1a0e9f8b"
7 }'
Was this page helpful?