Commerce Payments
This guide covers everything you need to know to integrate Swish commerce payments through the Ping Payments API.
Swish is a Swedish mobile payment system. Commerce payments come in two flavors:
- E-Commerce: The customer provides their phone number at checkout and receives a push notification in the Swish app.
- M-Commerce: The customer is on a mobile device and is redirected directly to the Swish app (or scans a QR code).
Supported Currency
SEK — Swish only supports Swedish Krona.
M-Commerce Payments
In the m-commerce flow, the customer's phone number is not known upfront. Instead, the API returns a URL and token that can be used to open the Swish app directly (via deep link) or to generate a QR code.
Customer on mobile: Use the returned url deep link to open the Swish app directly on the customer's device.
Customer on desktop: Set use_qr_code to true and display the returned QR code. The customer scans it with their phone to open the Swish app.
Flow
- You initiate a payment with
provider: "swish"andmethod: "m_commerce". - The response contains a
url(Swish app deep link) and apayment_request_token. - If the customer is on mobile, redirect them to the
urlto open the Swish app. If the customer is on desktop, display the QR code (requiresuse_qr_code: true). - Customer confirms the payment with BankID in the Swish app.
- Payment status is delivered via the standard Ping Payments callback.
Required Parameters
| Parameter | Type | Description |
|---|---|---|
message | string | Message shown to the payer in the Swish app. Max 50 characters. Allowed characters: 0-9 A-Z a-z Å Ä Ö å ä ö ! ? ( ) , - . : ; " @ and space. |
Optional Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
use_qr_code | boolean | false | Set to true to generate a QR code for the payment |
qr_format | string | "transparent_svg" | QR code image format. One of: transparent_svg, transparent_png, solid_jpg, solid_svg, solid_png |
qr_size | integer | 300 | QR code image size in pixels. Minimum 300 |
qr_border | integer | 1 | QR code border size in pixels. Range: 1–4 |
Example Request
{
"currency": "SEK",
"method": "m_commerce",
"order_items": [
{
"amount": 10000,
"merchant_id": "{{merchantId}}",
"name": "Product A"
}
],
"provider": "swish",
"total_amount": 10000,
"provider_method_parameters": {
"message": "Order #12345",
"use_qr_code": true,
"qr_format": "solid_png",
"qr_size": 400
}
}Example Response
{
"id": "15c44587-7ebb-43a3-b437-8d00e5f8df7a",
"provider_method_response": {
"url": "swish://paymentrequest?token=abc123...",
"payment_request_token": "abc123...",
"qr_code": "<base64-encoded image data>"
}
}| Field | Description |
|---|---|
url | Deep link URL to open the Swish app on the customer's device |
payment_request_token | Token identifying the payment request. Can be used to build custom Swish URLs |
qr_code | Base64-encoded QR code image. Only present if use_qr_code was true |
E-Commerce Payments
In the e-commerce flow, the customer enters their Swish-connected phone number during checkout. A push notification is sent to the customer's Swish app, where they confirm the payment using BankID.
Flow
- Customer enters their phone number at checkout.
- You initiate a payment with
provider: "swish"andmethod: "e_commerce". - Swish sends a push notification to the customer's Swish app.
- Customer opens the Swish app and confirms the payment with BankID.
- Payment status is delivered via the standard Ping Payments callback.
Required Parameters
| Parameter | Type | Description |
|---|---|---|
phone_number | string | Swish-connected phone number of the payer. Swedish format, e.g. "0739000001" or "+46739000001" |
message | string | Message shown to the payer in the Swish app. Max 50 characters. Allowed characters: 0-9 A-Z a-z Å Ä Ö å ä ö ! ? ( ) , - . : ; " @ and space |
Example Request
{
"currency": "SEK",
"method": "e_commerce",
"order_items": [
{
"amount": 10000,
"merchant_id": "{{merchantId}}",
"name": "Product A"
}
],
"provider": "swish",
"total_amount": 10000,
"provider_method_parameters": {
"phone_number": "0739000001",
"message": "Order #12345"
}
}Example Response
{
"id": "15c44587-7ebb-43a3-b437-8d00e5f8df7a"
}The e-commerce response contains no additional provider_method_response fields. The payment is confirmed entirely through the Swish app push notification.
Refunds
Swish commerce payments support refunds through the standard Ping Payments refund flow. Refunds are processed asynchronously.