Airwallex logo
Airwallex logo

Desktop/Mobile Website Browser

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

JSON
1{
2 "request_id": "ed11e38a-7234-11ea-aa94-7fd44ffd1b89",
3 "amount": 200,
4 "currency": "HKD",
5 "merchant_order_id": "85d7b0e0-7235-11ea-862e-9f6aa1adfca6",
6 "return_url": "https://www.airwallex.com"
7}

Step 2. Confirm the intent to redirect

When a shopper selects to pay with Octopus on their desktop/mobile browser, call the Confirm a Payment Intent API API to get a QR code payload.

POST /api/v1/pa/payment_intents/{id}/confirm

Example request on desktop, on mobile web it should be "flow":"mobile_web":

JSON
1{
2 "request_id": "ed11e38a-7234-11ea-aa94-7fd44ffd1b89",
3 "payment_method": {
4 "type": "octopus",
5 "octopus": {
6 "flow": "qrcode"
7 }
8 }
9}

Example response:

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

On Mobile Web (iOS):

JSON
1{
2"next_action": {
3 "type": "redirect",
4 "method": "GET",
5 "url": "https://api.airwallex.com/pa/redirect/sg/sgstnvk4dhcxzxibcbz_w9a1j6?checksum=a24e548a06d3",
6 "data": {
7 "scheme_url": "octopus://payment?token=NDswhHT&return=https%3A%2F%2Fwww.airwallex.com%2F"
8 }
9 }
10}

On Mobile Web (Android):

JSON
1{
2"next_action": {
3 "type": "redirect",
4 "method": "GET",
5 "url": "https://api.airwallex.com/pa/redirect/sg/sgstzhcbchcxzy77esd_w9a1j6?checksum=614947b062b8",
6 "data": {
7 "package_name": "com.octopuscards.nfc_reader",
8 "scheme_url": "octopus://payment?token=6ACBruG&return=https%3A%2F%2Fwww.airwallex.com%2F"
9 }
10 }
11}

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?