Accéder directement au contenu
Créez un compte ou connecter-vous
Logo de la documentation Stripe
/
Demander à l'assistant IA
Créez un compteConnectez-vous
Démarrer
Paiements
Revenus
Plateformes et places de marché
Gestion de fonds
Ressources pour les développeurs
API et SDKAide
Aperçu
À propos des paiements Stripe
Mettre votre intégration à niveau
Analyses des paiements
Paiements en ligne
PrésentationTrouver votre cas d'usageUtiliser Managed Payments
Utiliser Payment Links
Utiliser une page de paiement préconfiguré
Créer une intégration personnalisée avec Elements
Développer une intégration dans l'application
    Présentation
    Payment Sheet
    Payment Element
    Address Element
    Payment Method Messaging Element
      Display BNPL messaging
    Utiliser les redirections pour les achats intégrés à l'application
    Gérer les moyens de paiement dans les paramètres
    Migrer vers les tokens de confirmation
    Cartes bancaires américaines et canadiennes
Paiements par TPE
Terminal
Moyens de paiement
Ajouter des moyens de paiement
Gérer les moyens de paiement
Paiement accéléré avec Link
Scénarios de paiement
Gérer plusieurs devises
Tunnels de paiement personnalisés
Acquisition flexible
Orchestration
Au-delà des paiements
Constituez votre entreprise
Cryptomonnaies
Commerce agentique
Financial Connections
Climate
Comprendre la fraude
Radar pour la protection contre la fraude
Gestion des litiges
Vérifier l'identité
États-Unis
Français (France)
AccueilPaiementsBuild an in-app integrationPayment Method Messaging Element

Remarque

Cette page n'est pas encore disponible dans cette langue. Nous faisons tout notre possible pour proposer notre documentation dans davantage de langues et nous vous fournirons la version traduite dès qu'elle sera disponible.

Display BNPL MessagingVersion bêta publique

Automatically explain buy now, pay later payment options.

To display promotional messaging for buy now, pay later payment options, use the Payment Method Messaging Element.

Set up Stripe
Server-side
Client-side

First, you need a Stripe account. Register now.

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 StripePaymentSheet product to the target of your app.

Remarque

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
No results
import UIKit import StripePaymentSheet @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 } }

Remarque

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

Initialize the Payment Method Messaging Element

Call create to instantiate the Payment Method Messaging Element with a PaymentMethodMessagingElement.Configuration. The Configuration object contains details about the potential purchase and how information about it should be displayed. After PaymentMethodMessagingElement has successfully initialized, put its view into your UI.

@_spi(PaymentMethodMessagingElementPreview) import StripePaymentSheet class MyViewController: UIViewController { private var amount = 1000 // $10.00 private var currency = "USD" private var paymentMethodMessagingElementView: UIView? func addPaymentMethodMessagingElement() { Task { @MainActor in // Create configuration object let configuration = PaymentMethodMessagingElement.Configuration( amount: amount, currency: currency, ) // Create PaymentMethodMessagingElement switch await PaymentMethodMessagingElement.create(configuration: configuration) { case .success(let element): let elementView = element.view self.view.addSubview(elementView) self.paymentMethodMessagingElementView = elementView // Set up constraints for elementView NSLayoutConstraint.activate([( // .. )]) case .noContent: // No element is available to display with this configuration // You may want to adapt your UI accordingly // ... case .failed(let error): // An unrecoverable error has occurred while attempting to load the element // You may want to log the error or take other action // ... } } } override func viewDidLoad() { super.viewDidLoad() // Set up the remainder of your page // ... addPaymentMethodMessagingElement() } }

FacultatifUpdate the element

If the customer performs an action that changes the configuration (for example, selecting a different product variant), initialize a new PaymentMethodMessagingElement instance to reflect the new information.

class MyViewController: UIViewController { // ... func updatePaymentMethodMessagingElement() { paymentMethodMessagingElementView?.removeFromSuperview() addPaymentMethodMessagingElement() } }

FacultatifCustomize the element

Customization options are available through the PaymentMethodMessagingElement.Configuration and PaymentMethodMessagingElement.Appearance objects.

// Configure appearance let appearance = PaymentMethodMessagingElement.Appearance( style: .flat, font: .boldSystemFont(ofSize: 12), textColor: .black, infoIconColor: .blue ) // Create configuration object let configuration = PaymentMethodMessagingElement.Configuration( amount: 1000, // $10.00 currency: "USD", locale: "en_GB", // Defaults to device locale but can be explicitly set countryCode: "US", // Defaults to customer IP address but can be explicitly set paymentMethodTypes: [.affirm, .klarna], // Defaults to dynamic payment methods from the Dashboard, but can be explicitly set appearance: appearance )
Cette page vous a-t-elle été utile ?
OuiNon
  • Besoin d'aide ? Contactez le service Support.
  • Consultez notre log des modifications.
  • Des questions ? Contactez l'équipe commerciale.
  • LLM ? Lire llms.txt.
  • Propulsé par Markdoc