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.
We recommend you use the Mobile Payment Element, an embeddable payment form, to add Swish and other payment methods to your integration with the least amount of effort.
This guide covers how to accept Swish from your native mobile application using your own custom payment form.
If you’re accepting Swish from your native mobile application, your customers are redirected to the Swish mobile application for authentication. The payment is authenticated during the redirect. Completing the purchase requires no additional action in the Swish mobile application, and the customer is redirected back to your site.
Set up StripeServer-sideClient-side
First, you need a Stripe account. Register now.
Server-side
This integration requires endpoints on your server that talk to the Stripe API. Use the official libraries for access to the Stripe API from your server:
Client-side
The Stripe iOS SDK is open source, fully documented, and compatible with apps supporting iOS 13 or above.
Note
For details on the latest SDK release and past versions, see the Releases page on GitHub. To receive notifications when a new release is published, watch releases for the repository.
Configure the SDK with your Stripe publishable key on app start. This enables your app to make requests to the Stripe API.
Create a PaymentIntentServer-sideClient-side
Server-side
A PaymentIntent is an object that represents your intent to collect payment from a customer and tracks the lifecycle of the payment process through each stage.
To create and confirm a PaymentIntent
on your server:
- Specify the amount to collect and the currency.
- Add
swish
to the list of payment method types for yourPaymentIntent
. Make sure Swish is enabled in the Dashboard. - Set
payment_
tomethod_ data[type] swish
to create a PaymentMethod and immediately use it with this PaymentIntent.
The returned PaymentIntent includes a client secret, that you’ll use to confirm the PaymentIntent. Send the client secret back to the client so you can use it in the next step.
Client-side
On the client, request a PaymentIntent from your server and store its client secret.
Submit the payment to StripeClient-side
When a customer taps to pay with Swish, confirm the PaymentIntent
to complete the payment. Configure an STPPaymentIntentParams
object with the PaymentIntent
client secret.
The client secret is different from your API keys that authenticate Stripe API requests. Handle it carefully, as it can complete the charge. Don’t log it, embed it in URLs, or expose it to anyone but the customer.
Set up a return URL
The iOS SDK presents a webview in your app to complete the Swish payment. When authentication is finished, the webview can automatically dismiss itself instead of having your customer close it. To enable this behaviour, configure a custom URL scheme or universal link and set up your app delegate to forward the URL to the SDK.
Pass the URL as the return_
when you confirm the PaymentIntent. After webview-based authentication finishes, Stripe redirects the user to the return_
.
Confirm Swish payment
Complete the payment by calling STPPaymentHandler confirmPayment
. This presents a webview where the customer can complete the payment with Swish. Upon completion, the completion block is called with the result of the payment.
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_
.
Other than a payment being declined, for a Swish PaymentIntent with a status of requires_
, 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_
.