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
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.

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 Stripe
Server-side
Client-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:

Command Line
Ruby
# Available as a gem sudo gem install stripe
Gemfile
Ruby
# If you use bundler, you can add this line to your Gemfile gem 'stripe'

Client-side

The Stripe iOS SDK is open source, fully documented, and compatible with apps supporting iOS 13 or above.

To install the SDK, follow these steps:

  1. In Xcode, select File > Add Package Dependencies… and enter https://github.com/stripe/stripe-ios-spm as the repository URL.
  2. Select the latest version number from our releases page.
  3. Add the StripePaymentsUI product to the target of your app.

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.

AppDelegate.swift
Swift
import UIKit import StripePaymentsUI @main class AppDelegate: UIResponder, UIApplicationDelegate { func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { StripeAPI.defaultPublishableKey =
"pk_test_TYooMQauvdEDq54NiTphI7jx"
// do any other necessary launch configuration return true } }

Note

Use your test keys while you test and develop, and your live mode keys when you publish your app.

Create a PaymentIntent
Server-side
Client-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 your PaymentIntent. Make sure Swish is enabled in the Dashboard.
  • Set payment_method_data[type] to swish to create a PaymentMethod and immediately use it with this PaymentIntent.
Command Line
cURL
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 \ --data-urlencode return_url="payments-example://stripe-redirect"

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.

CheckoutViewController.swift
Swift
View full sample
class CheckoutViewController: UIViewController { var paymentIntentClientSecret: String? // ...continued from previous step override func viewDidLoad() { // ...continued from previous step startCheckout() } func startCheckout() { // Request a PaymentIntent from your server and store its client secret // Click View full sample to see a complete implementation } }

Submit the payment to Stripe
Client-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.

Swift
// This method handles opening custom URL schemes (for example, "your-app://stripe-redirect") func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey: Any] = [:]) -> Bool { let stripeHandled = StripeAPI.handleURLCallback(with: url) if (stripeHandled) { return true } else { // This was not a Stripe url – handle the URL normally as you would } return false } // This method handles opening universal link URLs (for example, "https://example.com/stripe_ios_callback") func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool { if userActivity.activityType == NSUserActivityTypeBrowsingWeb { if let url = userActivity.webpageURL { let stripeHandled = StripeAPI.handleURLCallback(with: url) if (stripeHandled) { return true } else { // This was not a Stripe url – handle the URL normally as you would } } } return false }

Pass the URL as the return_url when you confirm the PaymentIntent. After webview-based authentication finishes, Stripe redirects the user to the return_url.

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.

Swift
let paymentIntentParams = STPPaymentIntentParams(clientSecret: paymentIntentClientSecret) // Swish does not require additional parameters so we only need to pass the initialized // STPPaymentMethodSwishParams instance to STPPaymentMethodParams let swish = STPPaymentMethodSwishParams() let paymentMethodParams = STPPaymentMethodParams(swish: swish, billingDetails: nil, metadata: nil) paymentIntentParams.paymentMethodParams = paymentMethodParams paymentIntentParams.returnURL = "payments-example://stripe-redirect" STPPaymentHandler.shared().confirmPayment(paymentIntentParams, with: self) { (handlerStatus, paymentIntent, error) in switch handlerStatus { case .succeeded: // Payment succeeded // ... case .canceled: // Payment canceled // ... case .failed: // Payment failed // ... @unknown default: fatalError() } }

OptionalHandle post-payment events

OptionalTest the 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