Skip to content
Create account
or
Sign in
The Stripe Docs logo
/
Ask AI
Create account
Sign in
Get started
Payments
Revenue
Platforms and marketplaces
Money management
Developer resources
Overview
About Stripe payments
Upgrade your integration
Payments analytics
Online payments
OverviewFind your use caseManaged Payments
Use Payment Links
Build a checkout page
Build an advanced integration
Build an in-app integration
Payment Methods
Add payment methods
    Overview
    Payment method integration options
    Manage default payment methods in the Dashboard
    Payment method types
    Cards
    Pay with Stripe balance
    Crypto
    Bank debits
    Bank redirects
    Bank transfers
    Credit transfers (Sources)
    Buy now, pay later
    Real-time payments
      Pay by Bank
      PayNow
      PayTo
      Pix
      PromptPay
      Swish
        Accept a payment
    Vouchers
    Wallets
    Enable local payment methods by country
    Custom payment methods
Manage payment methods
Faster checkout with Link
Payment interfaces
Payment Links
Checkout
Web Elements
In-app Elements
Payment scenarios
Handle multiple currencies
Custom payment flows
Flexible acquiring
Orchestration
In-person payments
Terminal
Beyond payments
Incorporate your company
Crypto
Financial Connections
Climate
Understand fraud
Radar fraud protection
Manage disputes
Verify identities
HomePaymentsAdd payment methodsReal-time paymentsSwish

Swish paymentsInvite only

Learn how to accept Swish, a popular payment method in Sweden.

Swish is a single-use payment method used in Sweden. It allows customers to authenticate and approve payments using the Swish mobile app and the Swedish BankID mobile app.

You get immediate notification on whether the payment succeeded or failed.

Required notices

To comply with Swish rules, you must display the following text in your payment flow on the screen before the customer authorises the Swish payment:

  • For English localisations: “Stripe Technology Europe Limited (“Stripe”) has acquired the claim for payment. Therefore, your payment will be made to Stripe.”
  • For Swedish localisations: “Stripe Technology Europe Limited (“Stripe”) har övertagit fordran på betalning. Din betalning görs därför till Stripe.”
  • For other languages, an equivalent translation of the above.

If you integrate Swish through a Stripe-hosted payment form or UI component such as Checkout or the Payment Element, Stripe displays this notice for you.

Set up Stripe
Server-side

Use our official libraries for access to the Stripe API from your application:

Command Line
Ruby
Python
PHP
Java
Node
Go
.NET
No results
# Available as a gem sudo gem install stripe
Gemfile
Ruby
Python
PHP
Java
Node
Go
.NET
No results
# If you use bundler, you can add this line to your Gemfile gem 'stripe'

Create a PaymentIntent
Server-side

A PaymentIntent is an object that represents your intent to collect a payment from a customer and tracks the lifecycle of the payment process through each stage. First, create a PaymentIntent on your server and specify the amount to collect and the currency. If you already have an integration using the Payment Intents API, add swish to the list of payment method types for your PaymentIntent.

Command Line
cURL
Stripe CLI
Ruby
Python
PHP
Java
Node
Go
.NET
No results
curl https://api.stripe.com/v1/payment_intents \ -u "
sk_test_BQokikJOvBiI2HlWgH4olfQ2
:"
\ -d amount=6000 \ -d currency=sek \ -d "payment_method_types[]"=swish \ -d "payment_method_data[type]"=swish \ -d "payment_method_options[swish][reference]"=Order-123

Note

You can set the order reference to display to your customer in the Swish application.

Response

{ "id": "pi_12345", "amount": 6000, "client_secret": "pi_12345_secret_abcdef", "currency": "sek", "payment_method": "pm_12345", "payment_method_types": [ "swish" ], "payment_method_options": { "swish": { "reference": "Order-123", }, }, "status": "requires_confirmation" }

Retrieve the client secret

The PaymentIntent includes a client secret that the client side uses to securely complete the payment process. You can use different approaches to pass the client secret to the client side.

Retrieve the client secret from an endpoint on your server, using the browser’s fetch function. This approach is best if your client side is a single-page application, particularly one built with a modern front-end framework such as React. Create the server endpoint that serves the client secret:

main.rb
Ruby
Python
PHP
Java
Node
Go
.NET
No results
get '/secret' do intent = # ... Create or retrieve the PaymentIntent {client_secret: intent.client_secret}.to_json end

And then fetch the client secret with JavaScript on the client side:

(async () => { const response = await fetch('/secret'); const {client_secret: clientSecret} = await response.json(); // Render the form using the clientSecret })();

Confirm the PaymentIntent

Use the PaymentIntent id from step 2 to confirm the PaymentIntent. This declares that the customer intends to pay with the specified PaymentMethod. After the PaymentIntent is confirmed, it initiates a payment. The return_url indicates where Stripe redirects the user after they complete the payment.

Initiate the Swish payment by confirming the Payment Intent. Include a return_url to redirect your customer to after they complete the payment.

Command Line
cURL
Stripe CLI
Ruby
Python
PHP
Java
Node
Go
.NET
No results
curl https://api.stripe.com/v1/payment_intents/
{{PAYMENT_INTENT_ID}}
/confirm
\ -u "
sk_test_BQokikJOvBiI2HlWgH4olfQ2
:"
\ --data-urlencode return_url="https://example.com/checkout/complete"

Response

{ "id": "pi_12345", "amount": 6000, "currency": "sek", "payment_method": "pm_12345", "next_action": { "swish_handle_redirect_or_display_qr_code": { "hosted_instructions_url": "https://stripe.com/hiu-pi_123", "qr_code": { "data": "abc123", "image_url_png": "https://qr.stripe.com/qr_123.png", "image_url_svg": "https://qr.stripe.com/qr_123.svg" } }, "type": "swish_handle_redirect_or_display_qr_code" }, "payment_method_types": [ "swish" ], "payment_method_options": { "swish": { "reference": "Order-123", }, }, "status": "requires_action" }

To authorise the payment, redirect your customer to the URL in the next_action[swish_handle_redirect_or_display_qr_code][hosted_instructions_url] field or load this page in an iframe. This page presents both QR code and a button to redirect to the Swish app.

  • Desktop users can scan the QR code using the Swish app, after which they can authorise the payment.

  • Users on mobile devices can click a button which redirects to the Swish app, where they can authorise the payment.

Note

Your customer has 3 minutes to authorise the payment in the Swish app, after which the payment fails and the Payment Intent transitions to requires_payment_method.

Fulfill the order
Server-side

Use a method such as webhooks to handle order fulfilment. When a customer completes payment, the status of the PaymentIntent transitions to succeeded and sends the payment_intent.succeeded webhook event. If a customer doesn’t pay, the PaymentIntent sends the payment_intent.payment_failed webhook event and returns to a status of requires_payment_method.

OptionalUse the alternative authorisation method

OptionalHandle post-payment events

OptionalTest your integration

OptionalCancellation

Failed payments

Swish uses multiple data points to decide when to decline a transaction (for example, there aren’t enough funds in the customer’s bank account, or the customer has clicked Cancel in the app).

In these cases, the PaymentMethod is detached and the PaymentIntent object’s status automatically transitions to requires_payment_method.

Other than a payment being declined, for a Swish PaymentIntent with a status of requires_action, customers must complete the payment within 3 minutes. If no action is taken after 3 minutes, the PaymentMethod is detached and the PaymentIntent object’s status automatically transitions to requires_payment_method.

Was this page helpful?
YesNo
  • Need help? Contact Support.
  • Join our early access programme.
  • Check out our changelog.
  • Questions? Contact Sales.
  • LLM? Read llms.txt.
  • Powered by Markdoc