Skip to content
Create account
or
Sign in
The Stripe Docs logo
/
Ask AI
Create account
Sign in
Get started
Payments
Finance automation
Platforms and marketplaces
Money management
Developer tools
Get started
Payments
Finance automation
Get started
Payments
Finance automation
Platforms and marketplaces
Money management
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
    Bank debits
    Bank redirects
    Bank transfers
    Credit transfers (Sources)
    Buy now, pay later
    Real-time payments
    Vouchers
    Wallets
      Alipay
      Amazon Pay
      Apple Pay
      Cash App Pay
      Google Pay
      GrabPay
      Link
      MB WAY
      MobilePay
        Accept a payment
      PayPal
      PayPay
      Revolut Pay
      Satispay
      Secure Remote Commerce
      Vipps
      WeChat Pay
    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
Custom payment flows
Flexible acquiring
Orchestration
In-person payments
Terminal
Other Stripe products
Financial Connections
Crypto
Climate
HomePaymentsAdd payment methodsWalletsMobilePay

MobilePay payments

Learn how to accept MobilePay, a popular payment method in Denmark and Finland.

Copy page

MobilePay is a single-use card wallet payment method used in Denmark and Finland. It allows your customer to authenticate and approve payments using the MobilePay app.

When your customer pays with MobilePay, Stripe performs a card transaction using the card data we receive from MobilePay. The processing of the card transaction is invisible to your integration, and Stripe immediately notifies you whether the payment succeeded or failed.

Stripe recommends using the Mobile Payment Element, an embeddable payment form, to add MobilePay and other payment methods to your integration with the least amount of effort.

This guide covers how to accept MobilePay from your native mobile application using your own custom payment form. Your native mobile application redirects your customer to the MobilePay mobile application to complete the payment. Completing the purchase requires no additional action in the MobilePay mobile application.

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 a supported currency (eur, dkk, sek, or nok).
  • Add mobilepay to the list of payment method types for your PaymentIntent. Make sure that you enable MobilePay in the Dashboard.
  • Set payment_method_data[type] to mobilepay 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=1099 \ -d currency=dkk \ -d "payment_method_types[]"=mobilepay \ -d "payment_method_data[type]"=mobilepay \ --data-urlencode return_url="payments-example://stripe-redirect"

The PaymentIntent includes a client secret. Send the client secret to the client to confirm the PaymentIntent 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 MobilePay, 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 because 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 customer might navigate away from your app to authenticate (for example, in Safari or their banking app). To allow them to automatically return to your app after authenticating, configure a custom URL scheme and set up your app delegate to forward the URL to the SDK. Stripe doesn’t support universal links.

SceneDelegate.swift
Swift
// This method handles opening custom URL schemes (for example, "your-app://stripe-redirect") func scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>) { guard let url = URLContexts.first?.url else { return } let stripeHandled = StripeAPI.handleURLCallback(with: url) if (!stripeHandled) { // This was not a Stripe url – handle the URL normally as you would } }

Confirm the payment

Use the PaymentIntent client secret from step 2 to confirm the PaymentIntent using STPPaymentHandler.shared.confirmPayment(). This opens the MobilePay application directly (if present) or a webview showing the MobilePay landing page. After the customer authorizes the payment, the completion block contains the status of the payment.

Swift
let paymentIntentParams = STPPaymentIntentParams(clientSecret: paymentIntentClientSecret) paymentIntentParams.paymentMethodParams = STPPaymentMethodParams( mobilePay: STPPaymentMethodMobilePayParams(), billingDetails: nil, metadata: nil ) paymentIntentParams.returnURL = "your-app://stripe-redirect" // Set returnURL to your app's return URL that you set up in the previous step 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() } }

Your customer has 5 minutes to authorize the payment in the MobilePay app. If the underlying card charge fails, your customer can choose a different card and retry in the MobilePay app.

Handle post-payment events

Stripe sends a payment_intent.succeeded event when the payment completes. Use the Dashboard, a custom webhook, or a partner solution to receive these events and run actions, like sending an order confirmation email to your customer, logging the sale in a database, or starting a shipping workflow.

Listen for these events rather than waiting on a callback from the client. On the client, the customer could close the browser window or quit the app before the callback executes, and malicious clients could manipulate the response. Setting up your integration to listen for asynchronous events also helps you accept more payment methods in the future. Learn about the differences between all supported payment methods.

Manually

Use the Stripe Dashboard to view all your Stripe payments, send email receipts, handle payouts, or retry failed payments.

  • View your test payments in the Dashboard

Custom code

Build a webhook handler to listen for events and build custom asynchronous payment flows. Test and debug your webhook integration locally with the Stripe CLI.

  • Build a custom webhook

Prebuilt apps

Handle common business events, like automation or marketing and sales, by integrating a partner application.

Test the integration

Use your test API keys to create a PaymentIntent. After confirming the PaymentIntent, follow the next_action redirect URL to a test page with options to authorize or fail the payment.

  • Click Authorize test payment to test the case when the payment is successful. The PaymentIntent’s status transitions from requires_action to succeeded.
  • Click Fail test payment to test the case when the customer fails to authenticate. The PaymentIntent’s status transitions from requires_action to requires_payment_method.

OptionalCancellation

Failed payments

MobilePay transactions can fail if the underlying card transaction is declined. Learn more about card declines. In this case, the PaymentMethod is detached and the PaymentIntent’s status automatically transitions to requires_payment_method.

When the PaymentIntent’s status is requires_action, your customer must authenticate the payment within 5 minutes. If no action is taken after 5 minutes, the PaymentMethod detaches and the PaymentIntent’s status automatically transitions to requires_payment_method.

Refunds and disputes

Stripe performs a card transaction using standard card rails as part of a MobilePay transaction. Refunds and disputes are subject to the Visa and Mastercard network rules.

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