Payment-method icon

Swish for API only

Add Swish to an existing API-only integration.

Accept Swish payments using our APIs, and build your own payment form to have full control over the look and feel of your checkout page.

Before you begin

These instructions explain how to add Swish to your existing API-only integration. The API-only integration works the same way for all payment methods. If you haven't yet done this integration, refer to our API-only integration guide.

Before starting your Swish integration:

  1. Make sure that you have set up your back end implementation.
  2. Add Swish in your test Customer Area.

Build your payment form for Swish

Show Swish as an available payment method in your payment form. You don't need to collect any information from the shopper in your payment form.

We provide a Swish logo which you can use on your payment form. For more information, refer to Downloading logos.

You can also submit a /paymentMethods request specifying:

  • countryCode: SE
  • amount.currency: SEK.

In the response, you receive paymentMethod.type: swish.

Make a payment

When a shopper chooses to pay with Swish mobile, you need to redirect them to the Swish app, depending on how they are accessing your site:

  • For shoppers on desktop or laptop, present a QR code.
  • For shoppers on mobile, present a button that redirects to the Swish app.
  • For shoppers on tablet, you can present a QR code or a button that redirects to the Swish app, or both.

We recommend that you use screen size to determine whether the shopper is accessing your site on mobile, desktop, or tablet.

  1. From your server, make a /payments request, providing:

    • paymentMethod.type: swish
    • returnUrl : The URL where the shopper is redirected back to after completing the payment.

    The following code sample is a /payments request for a Swish payment.

    The /payments response contains:

    • action.qrCodeData: Use this to present the QR code.
    • action.url: Use this to redirect the shopper to the Swish app.

Present QR code

  1. Use the qrCodeData from the action object to render the QR code on your checkout page.
  2. When the shopper completes the payment, we'll send a webhook informing you of the payment result.

Redirect shopper

  1. Use the url from the action object to redirect the shopper to the Swish app.
  2. When the shopper completes the payment, we'll send a webhook informing you of the payment result.

Test and go live

When you make a Swish payment in the test environment, the payment is authorised within 15 seconds. You can simulate different refusal scenarios, as outlined in the Merchant Swish Simulator, by adding the error code to the shopperStatement property. For example, "shopperStatement": "FF08".

Check the status of Swish test payments in your Customer Area > Transactions > Payments.

To accept live Swish payments, you must submit a request for Swish in your live Customer Area.

See also