Accept Swish payments
You can accept Swish in three simple steps:
- Initialize a Payment Intent
- Specify the payment flow with qrcode (desktop) or mobile_web (mobile)
- Query the payment status
Step 1. Initialize a Payment Intent
Create a Payment Intent with the Create a Payment Intent API API.
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": 100,7 "currency": "SEK",8 "merchant_order_id": "85d7b0e0-7235-11ea-862e-9f6aa1adfca6",9 "return_url": "https://www.airwallex.com"10 }'
Example response:
1{2 "id": "int_hkdmtp6o2a3E3p8Oqxfkg00",3 "request_id": "unique-request-id",4 "amount": 100,5 "currency": "SEK",6 "merchant_order_id": "your-order-id",7 "status": "REQUIRES_PAYMENT_METHOD",8 "client_secret": "eyJxxxxxx"9}
Step 2. Generate and render the QR code to the shopper
Swish supports two separate flows for desktop and mobile. When a shopper selects Swish, call the Confirm a Payment Intent API API and specify the appropriate flow:
-
On desktop: qrcode flow. We return:
- A string representation of the QR code
- A fallback URL
-
On mobile: mobile_web flow:
- A redirect link to the shopper's Swish app is returned
Desktop flow - sample request
1{2 "request_id": "ed11e38a-7234-11ea-aa94-7fd44ffd1b89",3 "payment_method": {4 "type": "swish",5 "swish": {6 "flow": "qrcode"7 }8 }9}
Desktop flow - sample response
1{2 "id": "int_hkdmtp6o2a3E3p8Oqxfkg00",3 "status": "REQUIRES_CUSTOMER_ACTION",4 "next_action": {5 "type": "render_qrcode",6 "render_qrcode": {7 "qr_code": "D:///swish-qr-code-string",8 "url": "https://app.swish.nu/...",9 "expires_at": "2026-06-09T12:03:00+0000"10 }11 }12}
We recommend converting the next_action.qrcode value into a QR code for direct display to the shopper.
The QR code expires in 3 minutes. If the shopper does not complete the payment within this time, you need to re-confirm the Payment Intent to generate a new QR code. Re-confirming invalidates any previously generated QR code.
Mobile flow - sample request
1{2 "request_id": "ed11e38a-7234-11ea-aa94-7fd44ffd1b89",3 "payment_method": {4 "type": "swish",5 "swish": {6 "flow": "mobile_web"7 }8 }9}
Mobile flow - sample response
1{2 "id": "int_hkdmtp6o2a3E3p8Oqxfkg00",3 "status": "REQUIRES_CUSTOMER_ACTION",4 "next_action": {5 "type": "redirect",6 "redirect": {7 "method": "GET",8 "url": "https://app.swish.nu/..."9 }10 }11}
On mobile, the shopper is redirected to the Swish app to authenticate and confirm the payment. After completing (or cancelling) the payment, the shopper is redirected back to the return_url specified when creating the Payment Intent.
Step 3. Query the payment result status
To get the payment result, we suggest polling the Payment Intent status via the Retrieve a Payment Intent API API.
-
If you directly render and present the QR code to the shopper, start polling the status immediately.
-
If you redirect the shopper to the Swish app, you may start polling the Payment Intent status after the shopper is redirected back to your website (that is, the
return_urlpassed when creating the Payment Intent).
A successful payment returns "status": "SUCCEEDED".
Airwallex also notifies you of payment results asynchronously via webhooks. Refer to the webhook documentation to set this up. Although subscribing to webhook events is optional, we recommend subscribing to the payment_intent.succeeded webhook. You can also subscribe to the payment_intent.succeeded webhook event to receive real-time notifications when a payment is completed, instead of polling.