Payment-method icon

Swish for API only

Add Swish to your API-only integration.

You can add Swish to your existing integration. The following instructions show only what you must add to your integration specifically for Swish.

If an instruction on this page corresponds with a step in the main integration guide, it includes a link to that corresponding step of the main integration guide.

Requirements

Requirement Description
Integration type Make sure that you have an existing API-only integration.
Action handling Make sure that your existing integration is set up to handle the additional action.
action.type: qr.
Setup steps Before you begin, add Swish in your Customer Area.

How it works

  1. The shopper selects Swish as the payment method.
  2. The shopper enters their details in the payment form that you build.
  3. When you make the payment request, you include additional information about the items that the shopper intends to purchase.
  4. Handle the additional actions:
    • 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.
  5. You fulfill the order by sending items to the shopper.

Build your payment form

Include Swish in the list of available payment methods.

You do not need to collect any information from the shopper in your payment form.

You can download the logo for Swish to use in your form.

Get Swish as an available payment method

When you make the /paymentMethods to get available payment methods, specify the following so that Swish is included in the response.

Parameter Values
countryCode SE
amount.currency SEK

Add additional parameters to your /payments request

You do not need to add any additional parameters when you make a payment.

Make a payment

When a shopper chooses to pay with Swish, you need to direct 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, we recommend to present a QR code and a button that redirects to the Swish app.

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

Desktop flow

Follow this flow to let the shopper pay on a desktop or laptop by scanning a QR code and paying with their Swish app.

When the shopper selects to pay with Swish, make a /payments request with:

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

Sample /payments request:

curl https://checkout-test.adyen.com/v68/payments \
-H 'x-api-key: ADYEN_API_KEY' \
-H 'content-type: application/json' \
-d '{
  "merchantAccount": "ADYEN_MERCHANT_ACCOUNT",
  "reference": "YOUR_ORDER_NUMBER",
  "amount": {
    "currency": "SEK",
    "value": 1000
  },
  "paymentMethod": {
    "type": "swish"
  },
  "returnUrl": "https://your-company.example.com/checkout?shopperOrder=12xy.."
}'

The /payments response contains:

  • action.qrCodeData: Use this to render the QR code on your checkout page.
  • action.url: Use this to redirect a shopper on mobile to the Swish app.
{
  "resultCode": "Pending",
  "action": {
    "paymentData": "Ab02b4c0!BQABAgCpM2q6...==",
    "paymentMethodType": "swish",
    "url": "https://checkoutshopper-test.adyen.com/checkoutshopper/checkoutPaymentRedirect?redirectData=...",
    "qrCodeData": "D3Dv72lxSSjWFIp0xGftVzvMROBmV3M0d",
    "type": "qrCode"
  }
}

After initiating the payment, the shopper has three minutes to complete it. We recommend that you show this timer to the shopper.

Present the QR code

Follow these steps to render the QR code on your checkout page:

  1. Use the qrCodeData from the action object to render the QR code on your checkout page.
  2. After the shopper scans the QR code and completes the payment, we send a webhook informing you of the payment result.
  3. Present the payment result to your shopper.

Mobile flow

Follow this flow to let the shopper pay on mobile with Swish.

When the shopper selects to pay with Swish, make the same /payments request as in the desktop flow. The response is the same and includes action.url.

Redirect the shopper

Follow these steps to redirect the shopper to the Swish app:

  1. Redirect the shopper to the action.url returned in the /payments response.

    For security reasons, when displaying the redirect in the app, we recommend that you use SFSafariViewController for iOS or Chrome Custom Tabs for Android instead of WebView objects. Also refer to the security best practices for WebViews.

  2. After the shopper is redirected back to your app, check the payment result by making a POST /payments/details request with:

    • details: Object that contains the URL-decoded redirectResult returned when the shopper was redirected back to your app.
curl https://checkout-test.adyen.com/v72/payments/details \
-H 'x-api-key: ADYEN_API_KEY' \
-H 'content-type: application/json' \
-d '{
  "details": {
    "redirectResult": "eyJ0cmFuc1N0YXR1cyI6IlkifQ=="
  }
}'

You receive a response containing:

  • resultCode: Use this to present the result to your shopper.
  • pspReference: Our unique identifier for the transaction.
{
  "resultCode": "Authorised",
  "pspReference": "V4HZ4RBFJGXXGN82"
}

Present the payment result

Wait for a webhook to know the outcome of the payment. The webhooks you can receive for Swish are:

eventCode success field Description Action to take
AUTHORISATION false The transaction failed. Do not proceed with the order. Inform the shopper that the payment failed.
AUTHORISATION true The shopper successfully completed the payment. Inform the shopper that the payment has been successful and proceed with the order.

You can also use the resultCode from the /payments/details response to present the payment result to a shopper who completed the mobile flow.

resultCode Description Action to take
Authorised The payment was successful. Inform the shopper that the payment was successful.
Cancelled The shopper cancelled the payment. Ask the shopper whether they want to continue with the order, or ask them to select a different payment method.
Error There was an error when the payment was being processed. For more information, check the additionalData.refusalReasonRaw field. Inform the shopper that there was an error processing the payment.
Pending or Received The payment order was successfully received. Inform the shopper that you have received their order and are waiting for the payment to clear. You receive the final result in an AUTHORISATION webhook.
Refused The payment was refused. For more information, check the additionalData.refusalReasonRaw field. Ask the shopper to try the payment again using a different payment method.

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 > Payments > Payment list.

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

See also