Mobile Payments UI Integration GuideBeta
Beta info
- The latest iOS release is beta-2. The latest Android release is beta-1. Beta program members will be notified about new releases by email.
- Don’t hesitate to get in touch by emailing
mobile-payments-ui-beta@stripe.com
if you have any questions or feedback!
This guide shows you how to:
- Install the Stripe Mobile SDK (Private Beta)
- Set up your server
- Add a prebuilt payment sheet to accept payments in your mobile app
Add a server endpoint
This integration uses three Stripe API objects:
A PaymentIntent. Stripe uses this to represent your intent to collect payment from a customer, tracking your charge attempts and payment state changes throughout the process.
A Customer (optional). To set up a card for future payments, it must be attached to a Customer. Create a Customer object when your customer creates an account with your business. If your customer is making a payment as a guest, you can create a Customer object before payment and associate it with your own internal representation of the customer’s account later.
A Customer Ephemeral Key (optional). Information on the Customer object is sensitive, and cannot be retrieved directly from an app. An Ephemeral Key grants the SDK temporary access to the Customer.
If you never save cards to a Customer and don’t allow returning Customers to reuse saved cards, you can omit the Customer and Customer Ephemeral Key objects from your integration.
For security, your app cannot create these objects. Instead, add an endpoint on your server that:
- Retrieves the Customer, or creates a new one.
- Creates an Ephemeral Key for the Customer.
- Creates a PaymentIntent, passing the Customer id.
- Returns the Payment Intent’s
clientSecret
, the Ephemeral Key’ssecret
, and the Customer’sid
to your app.
A running implementation in Node is available on Glitch for quick testing.
Integrate the payment sheet
Currently, PaymentSheet
does not support collecting shipping details. If you need to collect shipping details, collect them in your checkout before displaying the payment sheet.
Before getting started, your checkout page should:
- Show the products being purchased and the total amount
- Collect any shipping information required
- Include a checkout button to present Stripe’s UI
Next, integrate Stripe’s prebuilt payment UI in your app’s checkout using use the PaymentSheet
class. PaymentSheet
guides the customer through the payment process, combining all the steps required — collecting payment details, billing details, and confirming the payment — into a single sheet. If you prefer a more customized checkout experience, consider using the Custom integration.
You’re done! Read on to learn more about the Custom integration style and integrating Apple Pay and Google Pay.
Custom integration
If you prefer a more customized checkout experience, you can use the Custom integration style. Choose this style if:
- Your checkout screen has a “Choose payment method” button to collect payment details, and a separate “Buy” button to complete the payment.
- You want your customer to complete the payment on your checkout screen instead of our payment sheet.
If you choose this integration, you’ll use the PaymentSheet.FlowController
class. PaymentSheet.FlowController
breaks down PaymentSheet
into its individual steps, and lets you control when those steps happen. For example, your checkout page can display a “Choose payment method” button to collect payment details, and a separate “Buy” button to finalize the payment.
Apple Pay
If your checkout page has a dedicated Apple Pay button, follow our Apple Pay guide and use ApplePayContext
to collect payment from your Apple Pay button. You can use PaymentSheet
to handle other payment method types.
First, follow steps 1–3 in our Accept Apple Pay in your iOS app guide. Once you’ve finished adding the Apple Pay capability in Xcode, return to this guide.
Next, set applePay
after initializing PaymentSheet.Configuration
with your merchant ID and the country code of your business (check your account details here):
var configuration = PaymentSheet.Configuration() configuration.applePay = .init(merchantId: "merchant.com.your_app_name", merchantCountryCode: "US")
Google Pay
First, follow step 1 in our Accepting Google Pay in your Android app guide. Once you’ve finished updating your AndroidManifest.xml
, return to this guide.
When you configure PaymentSheet
or PaymentSheet.FlowController
, provide a PaymentSheet.GooglePayConfiguration
with your Google Pay environment (production or test) and country code.
Card scanning
To enable card scanning support, set the NSCameraUsageDescription
(“Privacy - Camera Usage Description”) in your application’s Info.plist, and provide a reason for accessing the camera (e.g. “To scan cards”). Card scanning is supported on devices with iOS 13 or higher.
Customization
All customization is configured via the PaymentSheet.Configuration
object.
Merchant display name
You can specify your own customer-facing business name instead of your app’s name. This is used to display a “Pay (merchantDisplayName)” line item in the Apple Pay sheet.
UserInterfaceStyle
PaymentSheet
automatically adapts to the user’s system-wide appearance settings (light & dark mode). If your app doesn’t support dark mode, you can set PaymentSheet.Configuration.style
to alwaysLight
or alwaysDark
mode.