Airwallex logo
Airwallex logoAirwallex logo

Desktop/Mobile Website Browser - GrabPay

Copy for LLMView as Markdown

Step 1. Initialize a payment intent

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

POST /api/v1/pa/payment_intents/create

The currency field must be one of: SGD or MYR.

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": 20,
7 "currency": "SGD",
8 "merchant_order_id": "85d7b0e0-7235-11ea-862e-9f6aa1adfca6",
9 "return_url": "https://www.airwallex.com"
10 }'

Step 2. Confirm the intent to redirect

When a shopper selects to pay with GrabPay on their desktop/mobile browser, call the Confirm a Payment Intent API API to get a redirect URL that directs shoppers to GrabPay.

Example request for desktop. For mobile web and mobile app, use "flow": "mobile_web" and "flow": "mobile_app" respectively:

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": "ed11e38a-7234-11ea-aa94-7fd44ffd1b89",
6 "payment_method": {
7 "type": "grabpay",
8 "grabpay": {
9 "flow": "qrcode"
10 }
11 }
12 }'

Example response:

JSON
1{
2 // ... other fields omitted.
3 "next_action": {
4 "type": "redirect",
5 "method": "GET",
6 "url": "https://api-demo.airwallex.com/pa/redirect/sg/sgstzhcbchcxzwiuvd8_w9a1j6?checksum=724f920e47be"
7 }
8}

You can use the url returned in the confirm Payment Intent response to redirect the shopper to a separate browser. Shoppers will complete payment in the browser

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 Intent API API. You may start polling the Payment Intent status after the shopper is redirected back to your website or mobile app, i.e., the return_url passed when creating the Payment Intent.

In addition, Airwallex will notify you of the payment result asynchronously via the webhooks. Please refer to 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 the order.

Was this page helpful?