Weiter zum Inhalt
Konto erstellen
oder
anmelden
Das Logo der Stripe-Dokumentation
/
KI fragen
Konto erstellen
Anmelden
Jetzt starten
Zahlungen
Umsatz
Plattformen und Marktplätze
Geldmanagement
Entwicklerressourcen
Übersicht
Informationen zu Stripe Payments
Aktualisieren Sie Ihre Integration
Zahlungsanalysefunktionen
Online-Zahlungen
ÜbersichtIhren Use case findenZahlungen verwalten
Payment Links verwenden
Bezahlseite erstellen
Erweiterte Integration erstellen
In-App-Integration erstellen
    Übersicht
    Zahlungsformular
    Payment Element
    Ausgehender Link für In-App-Käufe
    Adressen erfassen
    Manage payment methods in settings
    Karten in den USA und Kanada
Zahlungsmethoden
Zahlungsmethoden hinzufügen
Zahlungsmethoden verwalten
Schnellerer Bezahlvorgang mit Link
Zahlungsschnittstellen
Payment Links
Checkout
Web Elements
In-app Payments
Zahlungsszenarien
Umgang mit mehreren Währungen
Nutzerdefinierte Zahlungsabläufe
Flexibles Acquiring
Orchestrierung
Präsenzzahlungen
Terminal
Mehr als Zahlungen
Unternehmensgründung
Krypto
Financial Connections
Climate
Betrug verstehen
Betrugsprävention von Radar
Zahlungsanfechtungen verwalten
Identitäten verifizieren
StartseiteZahlungenBuild an in-app integration

Notiz

Bis jetzt ist diese Seite noch nicht in dieser Sprache verfügbar. Wir arbeiten aber verstärkt daran, unsere Dokumentation in weiteren Sprachen bereitzustellen, und werden die Übersetzung sofort anzeigen, sobald diese verfügbar ist.

Manage payment methods in settings

Use the Payment Method Settings Sheet to let your customers manage their payment methods in your app settings page.

Notiz

The Payment Method Settings Sheet is intended for use on an app settings page. For checkout and payments, use the In-app Payments, which also has built-in support for saving and displaying payment methods and supports more payment methods than the Payment Method Settings Sheet.

Notiz

In code, this component is referenced as CustomerSheet for historical reasons. Throughout the documentation, when you see CustomerSheet in code examples, this refers to the Payment Method Settings Sheet.

The Payment Method Settings Sheet is a prebuilt UI component that lets your customers manage their saved payment methods. You can use the Payment Method Settings Sheet UI outside of a checkout flow, and the appearance and styling is customizable to match the appearance and aesthetic of your app. Customers can add and remove payment methods, which get saved to the customer object, and set their default payment method stored locally on the device. Use both the In-app Payments and the Payment Method Settings Sheet to provide customers a consistent end-to-end solution for saved payment methods.

Screenshot of Payment Method Settings Sheet presenting multiple saved payment methods in an iOS app.

Set up Stripe

First, you need a Stripe account. Register now.

The React Native SDK is open source and fully documented. Internally, it uses the native iOS and Android SDKs. To install Stripe’s React Native SDK, run one of the following commands in your project’s directory (depending on which package manager you use):

Command Line
yarn add @stripe/stripe-react-native

Next, install some other necessary dependencies:

  • For iOS, go to the ios directory and run pod install to ensure that you also install the required native dependencies.
  • For Android, there are no more dependencies to install.

Notiz

We recommend following the official TypeScript guide to add TypeScript support.

Stripe initialization

To initialize Stripe in your React Native app, either wrap your payment screen with the StripeProvider component, or use the initStripe initialization method. Only the API publishable key in publishableKey is required. The following example shows how to initialize Stripe using the StripeProvider component.

import { useState, useEffect } from 'react'; import { StripeProvider } from '@stripe/stripe-react-native'; function App() { const [publishableKey, setPublishableKey] = useState(''); const fetchPublishableKey = async () => { const key = await fetchKey(); // fetch key from your server here setPublishableKey(key); }; useEffect(() => { fetchPublishableKey(); }, []); return ( <StripeProvider publishableKey={publishableKey} merchantIdentifier="merchant.identifier" // required for Apple Pay urlScheme="your-url-scheme" // required for 3D Secure and bank redirects > {/* Your app code here */} </StripeProvider> ); }

Notiz

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

Enable payment methods

View your payment methods settings and enable the payment methods you want to support. You need at least one payment method enabled to create a SetupIntent.

By default, Stripe enables cards and other prevalent payment methods that can help you reach more customers, but we recommend turning on additional payment methods that are relevant for your business and customers. See Payment method support for product and payment method support, and our pricing page for fees.

Notiz

At this time, CustomerSheet only supports cards and US bank accounts.

Add Customer endpoints
Server-side

Create two endpoints on your server: one for fetching a Customer’s ephemeral key, and one to create a SetupIntent for saving a new payment method to the Customer.

  1. Create an endpoint to return a Customer ID and an associated ephemeral key. You can view the API version used by the SDK here.
Command Line
curl
Ruby
Python
PHP
Node.js
Java
No results
# Create a Customer (skip this and get the existing Customer ID if this is a returning customer) curl https://api.stripe.com/v1/customers \ -u
sk_test_BQokikJOvBiI2HlWgH4olfQ2
:
\ -X "POST" curl https://api.stripe.com/v1/ephemeral_keys \ -u
sk_test_BQokikJOvBiI2HlWgH4olfQ2
:
\ -X "POST" \ -d "customer"="{{CUSTOMER_ID}}" \
  1. Create an endpoint to return a SetupIntent configured with the Customer ID.
Command Line
curl
Ruby
Python
PHP
Node.js
Java
No results
# Create a Customer (skip this and get the existing Customer ID if this is a returning customer) curl https://api.stripe.com/v1/customers \ -u
sk_test_BQokikJOvBiI2HlWgH4olfQ2
:
\ -X "POST" curl https://api.stripe.com/v1/setup_intents \ -u
sk_test_BQokikJOvBiI2HlWgH4olfQ2
:
\ -d "customer"="{{CUSTOMER_ID}}" \

If you only plan to use the payment method for future payments when your customer is present during the checkout flow, set the usage parameter to on_session to improve authorization rates.

Initialize the sheet

Next, configure the Payment Method Settings Sheet using the CustomerSheetBeta class by providing your desired settings to CustomerSheetBeta.initialize.

import {CustomerSheetBeta} from '@stripe/stripe-react-native'; const {error} = await CustomerSheetBeta.initialize({ setupIntentClientSecret: 'SETUP-INTENT', customerEphemeralKeySecret: 'EPHEMERAL-KEY', customerId: 'CUSTOMER-ID', headerTextForSelectionScreen: 'Manage your payment method', returnURL: 'my-return-url://', });

Present the sheet

Present the Payment Method Settings Sheet using CustomerSheetBeta. When the customer dismisses the sheet, the promise resolves with a CustomerSheetResult.

import {CustomerSheetBeta} from '@stripe/stripe-react-native'; const {error, paymentOption, paymentMethod} = await CustomerSheetBeta.present(); if (error) { if (error.code === CustomerSheetError.Canceled) { // Customer dismissed the sheet without changing their payment option } else { // Show the error in your UI } } else { if (paymentOption) { // Configure your UI based on the payment option MyBackend.setDefaultPaymentMethod(paymentMethod.id); } if (paymentMethod) { console.log(JSON.stringify(paymentMethod, null, 2)); } }
  • If the customer selects a payment method, the result contains a paymentOption. The associated value is the selected PaymentOption, or nil if the user deleted the previously-selected payment method. You can find the full payment method details in the paymentMethod field.
  • If the user cancels the sheet, the result contains an error with the error.code === CustomerSheetError.Canceled. The selected payment method doesn’t change.
  • If an error occurs, the details are included in error.

Learn more about how to enable Apple Pay.

OptionalEnable ACH payments

To enable ACH debit payments: Enable US Bank Account as a payment method in the settings section of the Dashboard.

OptionalFetch the selected payment method

To fetch the default payment method without presenting the Payment Method Settings Sheet, call CustomerSheetBeta.retrievePaymentOptionSelection() after initializing the sheet.

// Call CustomerSheetBeta.initialize() ... const { error, paymentOption, paymentMethod, } = await CustomerSheetBeta.retrievePaymentOptionSelection();

OptionalCustomize the sheet

Appearance

Customize the colors, fonts, and other appearance attributes to match the look and feel of your app by using the appearance API.

Behavior

To add custom behavior for attaching, detaching, and listing saved payment methods, pass in a CustomerAdapter either to CustomerSheetBeta.initialize or as a prop to <CustomerSheetBeta.CustomerSheet />.

const { error } = await CustomerSheetBeta.initialize({ ... customerAdapter: { fetchPaymentMethods: async () => { const paymentMethods = // Get your Stripe payment methods from the server const filteredPaymentMethods = // Perform custom filtering return filteredPaymentMethods; } }, });

Notiz

fetchPaymentMethods can filter out saved payment methods from being shown, but won’t impact the type of payment methods that are addable.

Default billing details

To set default values for billing details collected in the Payment Method Settings Sheet, configure the defaultBillingDetails property. The Payment Method Settings Sheet pre-populates its fields with the values that you provide.

await CustomerSheetBeta.initialize({ // ... defaultBillingDetails: { email: 'foo@bar.com', address: { country: 'US', }, }, });

Billing details collection

Use billingDetailsCollectionConfiguration to specify how you want to collect billing details in the Payment Method Settings Sheet.

You can collect your customer’s name, email, phone number, and address.

If you don’t intend to collect the values that the payment method requires, you must do the following:

  1. Attach the values that aren’t collected by the Payment Method Settings Sheet to the defaultBillingDetails property.
  2. Set billingDetailsCollectionConfiguration.attachDefaultsToPaymentMethod to true.
await CustomerSheetBeta.initialize({ // ... defaultBillingDetails: { email: 'foo@bar.com', } billingDetailsCollectionConfiguration: { name: PaymentSheet.CollectionMode.ALWAYS, email: PaymentSheet.CollectionMode.NEVER, address: PaymentSheet.AddressCollectionMode.FULL, attachDefaultsToPaymentMethod: true }, });

Notiz

Consult with your legal counsel regarding laws that apply to collecting information. Only collect a phone number if you need it for a transaction.

War diese Seite hilfreich?
JaNein
  • Benötigen Sie Hilfe? Kontaktieren Sie den Kundensupport.
  • Nehmen Sie an unserem Programm für frühzeitigen Zugriff teil.
  • Schauen Sie sich unser Änderungsprotokoll an.
  • Fragen? Sales-Team kontaktieren.
  • LLM? Lesen Sie llms.txt.
  • Unterstützt von Markdoc