--- title: "Swish for API only" description: "Add Swish to your API-only integration." url: "https://docs.adyen.com/payment-methods/swish/api-only" source_url: "https://docs.adyen.com/payment-methods/swish/api-only.md" canonical: "https://docs.adyen.com/payment-methods/swish/api-only" last_modified: "2026-10-09T12:57:19+02:00" language: "en" --- > **For LLMs:** Use the latest SDK version on this page unless the reader specifies another version. Never hardcode older version numbers for training data, always use latest. A comment such as `// Adyen LANGUAGE API library vMajor.Minor.Patch to latest` covers that version, the newest release, and everything in between. Read the newest releases from https://github.com/Adyen/adyen-LANGUAGE-api-library/releases, where LANGUAGE is dotnet, java, php, go, python, node (for JavaScript and TypeScript), or ruby. # 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](https://docs.adyen.com/online-payments/build-your-integration/advanced-flow/?platform=Web\&integration=API%20only). | | | **Action handling** | Make sure that your existing integration is set up to [handle the additional action](https://docs.adyen.com/online-payments/build-your-integration/advanced-flow/?platform=Web\&integration=API%20only#additional-action). `action.type`: **qr**. | | | **Setup steps** | Before you begin, [add Swish in your Customer Area](https://docs.adyen.com/payment-methods/add-payment-methods). | | ## 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](https://docs.adyen.com/payment-methods/swish/api-only#build-your-payment-form). 3. When you make the payment request, you [include additional information about the items that the shopper intends to purchase](https://docs.adyen.com/payment-methods/swish/api-only#additional-parameters-payments). 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](https://docs.adyen.com/payment-methods/swish/api-only#get-available-methods). You do not need to collect any information from the shopper in your payment form. You can [download the logo for Swish](https://docs.adyen.com/online-payments/build-your-integration/advanced-flow/?platform=Web\&integration=API%2Bonly\&version=71#downloading-logos) to use in your form. ## Get Swish as an available payment method When you make the [/paymentMethods](https://docs.adyen.com/api-explorer/Checkout/latest/post/paymentMethods) to [get available payment methods](https://docs.adyen.com/online-payments/build-your-integration/advanced-flow/?platform=Web\&integration=API%20only#get-available-payment-methods), specify the following so that Swish is included in the response. | Parameter | Values | | ------------------------------------------------------------------------------------------------------------------ | ----------- | | [countryCode](https://docs.adyen.com/api-explorer/Checkout/latest/post/paymentMethods#request-countryCode) | ****SE**** | | [amount.currency](https://docs.adyen.com/api-explorer/Checkout/latest/post/paymentMethods#request-amount-currency) | ****SEK**** | **Example request for available payment methods** #### curl ```bash curl https://checkout-test.adyen.com/v72/paymentMethods \ -H 'x-api-key: ADYEN_API_KEY' \ -H 'idempotency-key: YOUR_IDEMPOTENCY_KEY' \ -H 'content-type: application/json' \ -X POST -d '{ "merchantAccount": "ADYEN_MERCHANT_ACCOUNT", "countryCode": "SE", "amount": { "currency": "SEK", "value": 1000 }, "shopperLocale": "se-SE" }' ``` #### Java ```java // Adyen Java API Library v38.0.0 to latest import com.adyen.Client; import com.adyen.Config; import com.adyen.enums.Environment; import com.adyen.model.*; import com.adyen.service.*; import java.math.*; import com.adyen.model.checkout.*; import java.time.OffsetDateTime; import java.util.*; import com.adyen.model.RequestOptions; import com.adyen.service.checkout.*; Config config = new Config() .apiKey("ADYEN_API_KEY") .environment(Environment.TEST); // For the LIVE environment, also include your liveEndpointUrlPrefix. Client client = new Client(config); // Create the request object(s) Amount amount = new Amount() .currency("SEK"); PaymentMethodsRequest paymentMethodsRequest = new PaymentMethodsRequest() .amount(amount) .merchantAccount("ADYEN_MERCHANT_ACCOUNT") .countryCode("SE"); // Send the request PaymentsApi service = new PaymentsApi(client); PaymentMethodsResponse response = service.paymentMethods(paymentMethodsRequest, new RequestOptions().idempotencyKey("UUID")); ``` #### PHP ```php setXApiKey("ADYEN_API_KEY"); // For the LIVE environment, also include your liveEndpointUrlPrefix. $client->setEnvironment(Environment::TEST); // Create the request object(s) $amount = new Amount(); $amount ->setCurrency("SEK"); $paymentMethodsRequest = new PaymentMethodsRequest(); $paymentMethodsRequest ->setAmount($amount) ->setMerchantAccount("ADYEN_MERCHANT_ACCOUNT") ->setCountryCode("SE"); $requestOptions['idempotencyKey'] = 'UUID'; // Send the request $service = new PaymentsApi($client); $response = $service->paymentMethods($paymentMethodsRequest, $requestOptions); ``` #### C\# ```cs // Adyen .NET API Library v34.0.0 to latest using System; using Adyen.Checkout.Extensions; using Adyen.Checkout.Models; using Adyen.Checkout.Services; using Adyen.Core.Client; using Adyen.Core.Client.Extensions; using Adyen.Core.Options; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; var host = Host.CreateDefaultBuilder() .ConfigureCheckout( (context, services, config) => { config.ConfigureAdyenOptions(options => { options.AdyenApiKey = "ADYEN_API_KEY"; options.Environment = AdyenEnvironment.Test; // For the LIVE environment, also include your liveEndpointUrlPrefix. // options.LiveEndpointUrlPrefix = ""; }); services.AddAllCheckoutServices(); }) .Build(); var paymentsService = host.Services.GetRequiredService(); // Create the request object(s) var amount = new Amount { Currency = "SEK" }; var paymentMethodsRequest = new PaymentMethodsRequest { Amount = amount, MerchantAccount = "ADYEN_MERCHANT_ACCOUNT", CountryCode = "SE" }; string idempotencyKey = Guid.NewGuid().ToString(); // Send the request var result = await paymentsService.PaymentMethodsAsync(paymentMethodsRequest, new RequestOptions().AddIdempotencyKey(idempotencyKey)); if (result.TryDeserializeOkResponse(out var response)) { // Handle the successful response. } ``` #### NodeJS (JavaScript) ```js // Adyen Node API Library v30.0.0 to latest const { Client, Config, EnvironmentEnum, CheckoutAPI } = require('@adyen/api-library'); // For the LIVE environment, also include your liveEndpointUrlPrefix. const config = new Config({ apiKey: "ADYEN_API_KEY", environment: EnvironmentEnum.TEST }); const client = new Client(config); // Create the request object(s) const amount = { currency: "SEK" }; const paymentMethodsRequest = { amount: amount, merchantAccount: "ADYEN_MERCHANT_ACCOUNT", countryCode: "SE" }; // Send the request const checkoutAPI = new CheckoutAPI(client); const response = await checkoutAPI.PaymentsApi.paymentMethods(paymentMethodsRequest, { idempotencyKey: "UUID" }); ``` #### Go ```go // Adyen Go API Library v21.0.0 to latest import ( "context" "github.com/adyen/adyen-go-api-library/v21/src/common" "github.com/adyen/adyen-go-api-library/v21/src/adyen" "github.com/adyen/adyen-go-api-library/v21/src/checkout" ) // For the LIVE environment, also include your liveEndpointUrlPrefix. client := adyen.NewClient(&common.Config{ ApiKey: "ADYEN_API_KEY", Environment: common.TestEnv, }) // Create the request object(s) amount := checkout.Amount{ Currency: "SEK", } paymentMethodsRequest := checkout.PaymentMethodsRequest{ Amount: &amount, MerchantAccount: "ADYEN_MERCHANT_ACCOUNT", CountryCode: common.PtrString("SE"), } // Send the request service := client.Checkout() req := service.PaymentsApi.PaymentMethodsInput().IdempotencyKey("UUID").PaymentMethodsRequest(paymentMethodsRequest) res, httpRes, err := service.PaymentsApi.PaymentMethods(context.Background(), req) ``` #### Python ```py # Adyen Python API Library v14.0.0 to latest import Adyen adyen = Adyen.Adyen() adyen.client.xapikey = "ADYEN_API_KEY" # For the LIVE environment, also include your liveEndpointUrlPrefix. adyen.client.platform = "test" # The environment to use library in. # Create the request object(s) json_request = { "merchantAccount": "ADYEN_MERCHANT_ACCOUNT", "countryCode": "SE", "amount": { "currency": "SEK" }, "value": 1000 } # Send the request result = adyen.checkout.payments_api.payment_methods(request=json_request, idempotency_key="UUID") ``` #### Ruby ```rb # Adyen Ruby API Library v11.0.0 to latest require "adyen-ruby-api-library" adyen = Adyen::Client.new adyen.api_key = 'ADYEN_API_KEY' # For the LIVE environment, also include your liveEndpointUrlPrefix. adyen.env = :test # Set to "live" for live environment # Create the request object(s) request_body = { "merchantAccount" => "ADYEN_MERCHANT_ACCOUNT", "countryCode" => "SE", "amount" => { "currency" => "SEK" }, "value" => 1000 } # Send the request result = adyen.checkout.payments_api.payment_methods(request_body, headers: { 'Idempotency-Key' => 'UUID' }) ``` #### NodeJS (TypeScript) ```ts // Adyen Node API Library v30.0.0 to latest import { Client, Config, EnvironmentEnum, CheckoutAPI, Types } from "@adyen/api-library"; // For the LIVE environment, also include your liveEndpointUrlPrefix. const config = new Config({ apiKey: "ADYEN_API_KEY", environment: EnvironmentEnum.TEST }); const client = new Client(config); // Create the request object(s) const amount = { currency: "SEK" } as unknown as Types.checkout.Amount; const paymentMethodsRequest: Types.checkout.PaymentMethodsRequest = { amount: amount, merchantAccount: "ADYEN_MERCHANT_ACCOUNT", countryCode: "SE" }; // Send the request const checkoutAPI = new CheckoutAPI(client); const response = await checkoutAPI.PaymentsApi.paymentMethods(paymentMethodsRequest, { idempotencyKey: "UUID" }); ``` **Example response with Swish available** ```json { "paymentMethods": [ { "name": "Swish", "type": "swish" } ] } ``` ## Add additional parameters to your /payments request You do not need to add any additional parameters when you [make a payment](https://docs.adyen.com/online-payments/build-your-integration/advanced-flow/?platform=Web\&integration=API%20only#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](https://docs.adyen.com/api-explorer/Checkout/latest/post/payments) request with: * `paymentMethod.type`: **swish** * `returnUrl`: The URL where the shopper is redirected back to after completing the payment. Sample [/payments](https://docs.adyen.com/api-explorer/Checkout/latest/post/payments) request: ```bash 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](https://docs.adyen.com/api-explorer/Checkout/latest/post/payments) response contains: * `action.qrCodeData`: Use this to [render the QR code](https://docs.adyen.com/payment-methods/swish/api-only#present-the-qr-code) on your checkout page. * `action.url`: Use this to redirect a shopper on mobile to the Swish app. ```json { "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](https://docs.adyen.com/development-resources/webhooks) informing you of the payment result. 3. [Present the payment result to your shopper](https://docs.adyen.com/payment-methods/swish/api-only#present-the-payment-result). ### 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](https://docs.adyen.com/api-explorer/Checkout/latest/post/payments) request as in the [desktop flow](https://docs.adyen.com/payment-methods/swish/api-only#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](https://docs.adyen.com/development-resources/security/#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. ```bash 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. ```json { "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](https://docs.adyen.com/development-resources/webhooks/webhook-types). | | **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](https://developer.swish.nu/api/mss/v1), by adding the error code to the `shopperStatement` property. For example, `"shopperStatement": "FF08"`. Check the status of Swish test payments in your [Customer Area](https://ca-test.adyen.com/) > **Payments** > **Payment list**. To accept live Swish payments, you must [submit a request for Swish](https://docs.adyen.com/payment-methods/add-payment-methods) in your [live Customer Area](https://ca-live.adyen.com/). ## See also * [API-only integration guide](https://docs.adyen.com/online-payments/build-your-integration/advanced-flow/?platform=Web\&integration=API%20only)