# Swish for Payment Setup API
To accept Swish payments, you must:
1. Create a payment setup.
2. Confirm the payment.
3. Redirect the customer to Swish.
---
## Create a payment setup
Call the [Create a payment setup](https://api-reference.checkout.com/tag/Payment-Setups/#operation/createAPaymentSetup) endpoint.
> **Information**
>
> Your base URL's `{prefix}` value is unique to your account and environment. To learn how to retrieve your base URLs for the sandbox and production environments, see [API endpoints](https://www.checkout.com/docs/developer-resources/api/api-endpoints.md).
**Production**
`POST` `https://{prefix}.api.checkout.com/payments/setups`
**Sandbox**
`POST` `https://{prefix}.api.sandbox.checkout.com/payments/setups`
### Request example
```json
{
"amount": 1000,
"currency": "SEK",
"processing_channel_id": "pc_wzjki6hw5puepb5fnvqlizj2e4",
"customer": {
"country": "SE"
},
"payment_methods": {
"swish": {
"billing_descriptor": "Swish payment",
"account_holder": {
"first_name": "Hannah",
"last_name": "Bret"
}
}
}
}
```
In the request body, provide the following:
| Field | Description |
| --- | --- |
| `amount`
`number` | The payment amount, in the [minor currency unit](https://www.checkout.com/docs/payments/accept-payments/format-the-amount-value).
Minimum: 1
**Required** |
| `currency`
`string` | Three-letter ISO 4217 [currency code](https://www.checkout.com/docs/developer-resources/codes/currency-codes.md). Must be `SEK`.
**Required** |
| `customer`
`object` | The customer's details.
**Required** |
| `customer.country`
`string` | The two-letter ISO 3166 country code of the customer. Must be `SE`.
**Required** |
| `payment_methods.swish.billing_descriptor`
`string` | A description that appears on the customer's billing statement.
**Required** |
| `payment_methods.swish.account_holder`
`object` | **Required** |
| `payment_methods.swish.account_holder.first_name`
`string` | The account holder's first name.
Min length: 1
**Required** |
| `payment_methods.swish.account_holder.last_name`
`string` | The account holder's last name.
Min length: 1
**Required** |
| `processing_channel_id`
`string` | The [processing channel's](https://www.checkout.com/docs/business-operations/use-the-dashboard/manage-processing-channels.md) unique identifier.
**Required** |
| `description`
`string` | A description of the payment.
Max length: 100 |
| `reference`
`string` | A reference you can use to identify the payment. For example, an order number.
Max length: 80 |
### Response example
```json
{
"id": "set_rcmepwrchqab2wsergcafvijfy",
"processing_channel_id": "pc_wzjki6hw5puepb5fnvqlizj2e4",
"amount": 1000,
"currency": "SEK",
"payment_type": "Regular",
"reference": "ORDER_01234",
"description": "Swish payment",
"payment_methods": {
"swish": {
"status": "ready",
"flags": []
}
},
"available_payment_methods": [
"swish"
]
}
```
The response returns a `payment_methods` object, which contains the payment methods enabled on your account.
Providing all required fields sets the `payment_methods.swish` object to a `ready` [status](https://www.checkout.com/docs/payments/accept-payments/accept-a-payment-using-the-payment-setup-api.md#Payment_method_status).
---
## Confirm the payment
Confirm the payment by calling the [Confirm a payment setup](https://api-reference.checkout.com/tag/Payment-Setups/#operation/confirmAPaymentSetup) endpoint and provide:
- The payment setup `id` as the `{id}` path parameter.
- `swish` as the `{payment_method_name}` path parameter.
### Request example
**Production**
`POST` `https://{prefix}.api.checkout.com/payments/setups/{id}/confirm/swish`
**Sandbox**
`POST` `https://{prefix}.api.sandbox.checkout.com/payments/setups/{id}/confirm/swish`
### Response example
If you receive a `202 Success` response with a payment `id` and a `status` field set to `Pending`, your request was successful.
```json
{
"id": "pay_3j4564ofxydevmruz6amur7djq",
"status": "Pending",
"reference": "ORDER_01234",
"payment_type": "Regular",
"_links": {
"self": {
"href": "https://{prefix}.api.sandbox.checkout.com/payments/pay_3j4564ofxydevmruz6amur7djq"
},
"redirect": {
"href": "https://authman.sandbox.lp-pl.ppro.com/v0/pages/?redirection_token=eyJhbGciOiJIUzUxMiJ9...",
"qr_code": {
"text": "iVBORw0KGgoAAAANSUhEUgAAASwAAAEsCAYAAAB5fY51AAAsNklEQVR4Xu2d..."
},
"mobile": {
"android": {
"href": "swish://paymentrequest?token=AAAAAAAAAAAAABUCIDZXYpP3hM2Mx1Le&callbackurl=..."
},
"ios": {
"href": "swish://paymentrequest?token=AAAAAAAAAAAAABUCIDZXYpP3hM2Mx1Le&callbackurl=..."
}
}
}
}
}
```
---
## Redirect the customer
The redirection step varies depending on whether you request the payment from a desktop browser or a mobile app.
### Desktop
To request a payment from a desktop browser:
1. Ensure that the Swish app is installed on your customer's phone.
2. Redirect your customer to the `_links.redirect.href` URL provided in the response. The URL displays a QR code.
3. Your customer must scan the code using their Swish app and authorize the payment on their device.
4. After authorizing the payment, the customer is redirected to either your success or failure URL.
### Mobile
To request a payment from a mobile app:
1. Ensure that the Swish app is installed on your customer's phone. If the application is not installed, instruct the customer to install it.
2. Get the necessary token from the `redirect.mobile` object in the response:
- For Android – Pass the deeplink provided in `redirect.mobile.android` to open the Swish app on your customer's phone.
- For iOS – Pass the deeplink provided in `redirect.mobile.ios` to open the Swish app on your customer's phone.
3. The Swish app launches on your customer's phone, where they can authorize the payment.