Desktop/Mobile Website Browser - SPayLater
Step 1. Initialize a payment intent
Create a Payment Intent with the Create a Payment Intent API API.
The currency field must be one of: IDR, MYR, SGD, THB, PHP, or VND.
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": 200,7 "currency": "IDR",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 SPayLater on their desktop/mobile browser, call the Confirm a Payment Intent API API to get a redirect URL that directs shoppers to ShopeePay.
Example request for desktop. For mobile web, use "flow": "mobile_web":
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": "spaylater",8 "spaylater": {9 "flow": "qrcode"10 }11 }12 }'
Example response:
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 the ShopeePay app (or Shopee app in SG and VN). Shoppers will complete payment in the ShopeePay mobile app. The following app schemes should be whitelisted:
| ID | MY | PH | SG | TH | VN | |
|---|---|---|---|---|---|---|
| Shopee App | shopeeid:// | shopeemy:// | shopeeph:// | shopeesg:// | shopeeth:// | shopeevn:// |
| ShopeePay App | shopeepayid:// | shopeepaymy:// | - | - | shopeepayth:// | shopeepayvn:// |
To redirect to ShopeePay or Shopee App on Android, you will need to use the package names com.shopeepay.id (Indonesia), com.beeasy.airpay (Thailand), com.beeasy.toppay (Vietnam), and com.shopeepay.my (Malaysia). Singapore and Philippines do not have the ShopeePay app and will return the package com.shopee.sg (Singapore) and com.shopee.ph (Philippines).
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.