Desktop/Mobile Website Browser/Mobile App - Scalapay
Step 1. Initialize a Payment Intent
Create a Payment Intent with the Create a Payment IntentAPI API.
Scalapay encourages passing the shopper's shipping address in the order.shipping object and billing address in the order.billing object when creating the Payment Intent, to improve the checkout success rate for Scalapay payments.
1curl -X POST https://api.sandbox.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": "d917ad44-6ae4-447e-a534-cce4ceebfd2e",6 "amount": 100,7 "currency": "EUR",8 "order": {9 "shipping": {10 "first_name": "Marco",11 "last_name": "Rossi",12 "address": {13 "country_code": "IT",14 "city": "Milan",15 "postcode": "20121",16 "street": "Via Dante 1"17 }18 },19 "billing": {20 "first_name": "Marco",21 "last_name": "Rossi",22 "address": {23 "country_code": "IT",24 "city": "Milan",25 "postcode": "20121",26 "street": "Via Dante 1"27 }28 }29 },30 "merchant_order_id": "85d7b0e0-7235-11ea-862e-9f6aa1adfca6",31 "return_url": "https://www.airwallex.com"32 }'
Step 2. Confirm the Payment Intent to obtain the redirect link
When a shopper selects to pay with Scalapay, call the Confirm a Payment IntentAPI API to get a redirect URL. Scalapay only supports completing payment via redirect.
1curl -X POST https://api.sandbox.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": "d917ad44-6ae4-447e-a534-cce4ceebfd2e",6 "payment_method": {7 "type": "scalapay",8 "scalapay": {9 "shopper_name": "Marco Rossi",10 "shopper_phone": "+393401234567"11 }12 }13 }'
You will get a response similar to the following.
1{2 // ... other fields omitted.3 "next_action": {4 "type": "redirect",5 "method": "GET",6 "url": "https://api.sandbox.airwallex.com/pa/redirect/hk/hkpdxjqhmgsyvijy6hz_bwvqvc?checksum=1c11d21315c1"7 }8}
Step 2a. (Optional) Set Scalapay payments to be manually captured later
By default, Scalapay payments are automatically captured. If you want to capture payments at a later date, pass auto_capture as false when calling the Confirm a Payment IntentAPI API.
1curl -X POST https://api.sandbox.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 // ...other fields omitted.6 "payment_method_options": {7 "scalapay": {8 "auto_capture": false9 }10 }11 }'
Step 2b. Manually capture Scalapay payments
You must manually capture Scalapay payments within 7 days after authorization. You can call the Capture a PaymentIntentAPI API to capture the payment. Partial captures are supported. If you perform a partial capture, the remaining amount is released back to the shopper.
1curl -X POST https://api.sandbox.airwallex.com/api/v1/pa/payment_intents/{{PAYMENT_INTENT_ID}}/capture \2 -H 'Content-Type: application/json' \3 -H 'Authorization: Bearer {{ACCESS_TOKEN}}' \4 -d '{5 "request_id": "2c53861f-ce66-4054-880e-6c0901a15d29",6 "amount": 107 }'
If an authorized Scalapay payment is not captured within 7 days, the remaining amount is automatically voided.
Step 3. Query the payment result status
To get the payment result, we suggest you poll the status of the Payment Intent via the Retrieve a Payment IntentAPI API. You may start polling the Payment Intent status after the shopper is redirected back to your website, that is, the return_url passed when creating the Payment Intent.
GET /api/v1/pa/payment_intents/{id}
In addition, Airwallex will notify you of the payment result asynchronously via webhooks. See the webhook documentation to set up your webhook accordingly. Although subscribing to webhook events is optional, it is recommended to subscribe to the payment_intent.succeeded webhook which indicates that the shopper has paid for the order.