Integrate Swish using the Orders API

DocsCurrent

Last updated: Mar 31st, 10:36am

Set up

Before you onboard Swish, verify you have completed the following PayPal integration steps:

  1. Sign up for a PayPal developer account. On successful signup, PayPal automatically creates your sandbox environment. The sandbox environment mimics real-world transactions and includes both business and personal accounts by default. Use the personal account to approve payments and the business account to receive money. You can create additional business and personal accounts as needed.
  2. Set up the sandbox environment.
  3. Configure a webhook listener for the app and subscribe to events:
    • In the app details page, go to Sandbox Webhooks.
    • Select Add Webhook.
    • Enter a Webhook URL (your server endpoint for PayPal notifications), select the events to subscribe to, and select Save.

    The webhook listener is now configured, and a Webhook ID is displayed. Store the ID for verification in your app code. For more information, see Use webhooks.

  4. Retrieve sandbox app credentials.
  5. Retrieve sandbox account credentials.
  6. Set up the development environment.
  7. Set up your production environment.

Onboard Swish payments

After you complete your PayPal account setup, enable Swish as a payment method.

You can enable Swish using one of the following methods:

Enable Swish from your PayPal dashboard

If you have an eligible PayPal business account, you can enable Swish directly from your dashboard:

  1. Log in to your PayPal business account.
  2. Go to Account Settings > Products & Services > Payment Methods.
  3. Find Swish and select Get Started.
  4. Follow the on-screen prompts to complete onboarding and activate Swish payments.

After enabling, go to Payment Options to manage your Swish settings.

Request approval to enable Swish

If you don't see Swish in your dashboard, request approval by visiting the links below:

  • Sandbox:
  • Live:

Swish payments are activated after PayPal verifies eligibility and completes a compliance review.

1

Create order

Create an order to begin the Swish payment process. You can configure the order by following these steps:

  1. Choose buyer flow: Select QR code flow for desktop or mobile app switch for mobile devices.
  2. Set capture method: Choose automatic for immediate capture or manual for delayed capture.
  3. Create the order: Make the POST call to /v2/checkout/orders endpoint with one of the following configurations:
  4. Handle the response: Use the order response based on your integration pattern.

Create order with QR code flow

Use this flow for desktop browsers where buyers scan a QR code with their mobile device. Use a valid access token and make the POST call to /v2/checkout/orders endpoint with request body parameters including intent set to CAPTURE, purchase_units with amount and currency_code, payment_source.swish object, and the PayPal-Request-Id header for idempotency.

Automatic capture

Set processing_instruction to ORDER_COMPLETE_ON_PAYMENT_APPROVAL. Funds are captured immediately after buyer approval.

  1. Sample request
  2. Sample response
1curl -v -L -s -X POST https://api.paypal.com/v2/checkout/orders \
2 -H 'Content-Type: application/json' \
3 -H 'Authorization: Bearer ACCESS-TOKEN' \
4 -H 'PayPal-Request-Id: UNIQUE-REQUEST-ID' \
5 -d '{
6 "intent": "CAPTURE",
7 "processing_instruction": "ORDER_COMPLETE_ON_PAYMENT_APPROVAL",
8 "payment_source": {
9 "swish": {
10 "name": "Jhon Doe",
11 "country_code": "SE",
12 "experience_context": {
13 "locale": "sv-SE",
14 "return_url": "http://www.bing.com",
15 "cancel_url": "http://www.google.com"
16 }
17 }
18 },
19 "payer": {
20 "email_address": "aisjdi@paypal.com",
21 "first_name": "John1",
22 "last_name": "Doe1",
23 "country_code": "SE",
24 "phone": {
25 "phone_type": "MOBILE",
26 "phone_number": {
27 "national_number": "1238712837"
28 }
29 }
30 },
31 "purchase_units": [
32 {
33 "invoice_id": "Invoice-123456",
34 "custom_id": "Custom-12345",
35 "amount": {
36 "currency_code": "SEK",
37 "value": "100"
38 }
39 }
40 ]
41 }'

After receiving the response, redirect the buyer to complete payment approval. The payment captures automatically after buyer approval.

Manual capture

For manual capture, exclude the processing_instruction parameter or set it to NO_INSTRUCTION. When the buyer approves the payment, capture the payment to complete the transaction.

  1. Sample request
  2. Sample response
1curl -v -L -s -X POST https://api.paypal.com/v2/checkout/orders \
2 -H 'Content-Type: application/json' \
3 -H 'Authorization: Bearer ACCESS-TOKEN' \
4 -H 'PayPal-Request-Id: UNIQUE-REQUEST-ID' \
5 -d '{
6 "intent": "CAPTURE",
7 "payment_source": {
8 "swish": {
9 "name": "Jhon Doe",
10 "country_code": "SE",
11 "experience_context": {
12 "locale": "sv-SE",
13 "return_url": "http://www.bing.com",
14 "cancel_url": "http://www.google.com"
15 }
16 }
17 },
18 "payer": {
19 "email_address": "aisjdi@paypal.com",
20 "first_name": "John1",
21 "last_name": "Doe1",
22 "country_code": "SE",
23 "phone": {
24 "phone_type": "MOBILE",
25 "phone_number": {
26 "national_number": "1238712837"
27 }
28 }
29 },
30 "purchase_units": [
31 {
32 "invoice_id": "Invoice-123456",
33 "custom_id": "Custom-12345",
34 "amount": {
35 "currency_code": "SEK",
36 "value": "100"
37 }
38 }
39 ]
40 }'

After receiving the response, redirect the buyer to complete payment approval, then capture the payment after buyer approval.

Create order with mobile app switch flow

Use this flow for mobile browsers where buyers switch to the Swish app on the same device. Use a valid access token and make the POST call to /v2/checkout/orders with request body parameters including intent set to CAPTURE, purchase_units with amount and currency_code, payment_source.swish object with country_code set to SE and redirect_to_app set to true, and the PayPal-Request-Id header for idempotency.

Automatic capture

Set processing_instruction to ORDER_COMPLETE_ON_PAYMENT_APPROVAL. Funds are captured immediately after buyer approval.

  1. Sample request
  2. Sample response
1curl -v -L -s -X POST https://api.paypal.com/v2/checkout/orders \
2 -H 'Content-Type: application/json' \
3 -H 'Authorization: Bearer ACCESS-TOKEN' \
4 -H 'PayPal-Request-Id: UNIQUE-REQUEST-ID' \
5 -d '{
6 "intent": "CAPTURE",
7 "processing_instruction": "ORDER_COMPLETE_ON_PAYMENT_APPROVAL",
8 "payment_source": {
9 "swish": {
10 "name": "Jhon Doe",
11 "country_code": "SE",
12 "experience_context": {
13 "locale": "sv-SE",
14 "return_url": "http://www.bing.com",
15 "redirect_to_app": true
16 }
17 }
18 },
19 "payer": {
20 "email_address": "aisjdi@paypal.com",
21 "first_name": "John1",
22 "last_name": "Doe1",
23 "country_code": "SE",
24 "phone": {
25 "phone_type": "MOBILE",
26 "phone_number": {
27 "national_number": "1238712837"
28 }
29 }
30 },
31 "purchase_units": [
32 {
33 "invoice_id": "Invoice-123456",
34 "custom_id": "Custom-12345",
35 "amount": {
36 "currency_code": "SEK",
37 "value": "100"
38 }
39 }
40 ]
41 }'

After receiving the response, redirect the buyer to complete payment approval. The payment captures automatically after buyer approval.

Manual capture

For manual capture, exclude the processing_instruction parameter or set it to NO_INSTRUCTION. When the buyer approves the payment, capture the payment to complete the transaction.

  1. Sample request
  2. Sample response
1curl -v -L -s -X POST https://api.paypal.com/v2/checkout/orders \
2 -H 'Content-Type: application/json' \
3 -H 'Authorization: Bearer ACCESS-TOKEN' \
4 -H 'PayPal-Request-Id: UNIQUE-REQUEST-ID' \
5 -d '{
6 "intent": "CAPTURE",
7 "payment_source": {
8 "swish": {
9 "name": "Jhon Doe",
10 "country_code": "SE",
11 "experience_context": {
12 "locale": "sv-SE",
13 "return_url": "http://www.bing.com",
14 "redirect_to_app": true
15 }
16 }
17 },
18 "payer": {
19 "email_address": "aisjdi@paypal.com",
20 "first_name": "John1",
21 "last_name": "Doe1",
22 "country_code": "SE",
23 "phone": {
24 "phone_type": "MOBILE",
25 "phone_number": {
26 "national_number": "1238712837"
27 }
28 }
29 },
30 "purchase_units": [
31 {
32 "invoice_id": "Invoice-123456",
33 "custom_id": "Custom-12345",
34 "amount": {
35 "currency_code": "SEK",
36 "value": "100"
37 }
38 }
39 ]
40 }'

After receiving the response, redirect the buyer to complete payment approval, then capture the payment after buyer approval.

Parameter name Description
processing_instruction
string
Specifies how the order is processed.

For automatic capture, set to ORDER_COMPLETE_ON_PAYMENT_APPROVAL. For manual capture, exclude this parameter or set to NO_INSTRUCTION.
intent
Required, string
Indicates whether payment is captured immediately or authorized for later capture.

For Swish payments, set to CAPTURE.
purchase_units
Required, array
Lists the items or services the buyer is purchasing in the order.
purchase_units.amount
Required, object
Amount of the order and the currency code.

For Swish payments, use SEK currency.
payment_source
Required, object
Payment method used to fund the order.

For Swish payments, include a swish object with buyer and experience context information.
payment_source.swish.country_code
Required, string
Country code required for Swish payments, specified in the ISO 3166-1 format.

For Swish payments, set to SE.
payment_source.swish.name
Required, object
Name of the buyer.
payment_source.swish.experience_context
object
Context information for the Swish payment experience including locale, return URL, and buyer flow settings.
payment_source.swish.experience_context.locale
string
Locale for buyer’s payment experience. For Swish payments, set to sv-SE.
payment_source.swish.experience_context.return_url
Required, string
URL to redirect the buyer after payment approval.
payment_source.swish.experience_context.cancel_url
Required, string
URL to redirect the buyer if they cancel the payment.
payment_source.swish.experience_context.redirect_to_app
boolean
Indicates whether to use mobile app switch flow.

Set to true for mobile app switch. Omit or set to false for QR code flow.

Default is false.
2

Redirect buyer

After creating an order, redirect the buyer to complete payment approval in the Swish app. The redirect method depends on your integration pattern and the buyer's device.


Redirect using PayPal-hosted integration

For PayPal-hosted integration, redirect the buyer to PayPal's payment page using the payer-action link from the order response.

  1. Extract the payer-action link from the order creation response.
  2. Redirect the buyer to the link URL
  3. PayPal displays the payment page with QR code or triggers the Swish app based on the buyer flow.

PayPal handles the buyer experience and redirects the buyer back to your return_url after payment approval or to your cancel_url if the buyer cancels.


Display QR code using Merchant-hosted integration

For Merchant-hosted integration, display the QR code from the order response on your own page.

  1. Extract the QR code image from qr_details.qr_image in the order response.
  2. Display the base64-encoded image on your checkout page.
  3. Show instructions for buyers to scan the QR code with the Swish app.

For mobile app switch flow with merchant-hosted integration, you can redirect using the payer-action link to trigger the Swish app directly.

After the buyer approves payment:

  • Automatic capture: The payment is captured automatically. Track the payment using webhooks.
  • Manual capture: Capture the payment after buyer approval.

3

Capture payment

For manual capture orders, call the capture endpoint after the buyer approves the payment. Use a valid access token and make the POST call to /v2/checkout/orders/{order_id}/capture endpoint to capture the authorized funds.

  1. Sample request
  2. Sample response
1curl -v -L -s -X POST https://api.paypal.com/v2/checkout/orders/5SJ83317D1020641R/capture \
2 -H 'Content-Type: application/json' \
3 -H 'Authorization: Bearer ACCESS-TOKEN' \
4 -H 'PayPal-Request-Id: UNIQUE-REQUEST-ID'
4

Track payment

After creating the order, you can track the payment status in two ways:

Use webhooks

To track the payment status using webhooks, follow these steps:

  1. Subscribe to webhook events in your PayPal developer dashboard or through the Webhooks API. For example:
    • PAYMENT.CAPTURE.COMPLETED – Successful payment capture
    • PAYMENT.CAPTURE.DENIED – Failed payment capture
  2. Define a webhook handler in your server-side application to:
    1. Listen for incoming webhook events.
    2. Confirm receipt of the event to PayPal.
    3. Verify the source of the event notification.
    4. Complete further actions based on event data.

Extract the order ID from the "rel": "up" link in the webhook payload's resource.links array to correlate the capture to your original order.

Poll for updates

To check the status of an order, you can poll the Orders API:

  1. Use a valid access token and send a GET request to the /v2/checkout/orders/{id} endpoint, replacing {id} with the order ID from your Create order response.
  2. Review the response to determine the current order status and take action as needed.
Parameter name Description
id Unique order ID.
status Current status of the order.
purchase_units List of purchase units for the order, including amount and currency.
payer Information about the buyer, including name and payer ID.

For the comprehensive list of response parameters, see Show order details.

5

Notify buyer of success

After a successful payment, notify the buyer of a successful transaction. You can do this by sending a confirmation email.

Next steps

Required
Test integration

Test the integration in the PayPal sandbox environment.