Skip to main content
Primer Checkout React Native SDK is currently in beta (v3.0.0-beta.1). The API is subject to change before the stable release.
PrimerCheckoutSheet is the prebuilt checkout UI. It opens a bottom sheet with a loading screen, payment method selection, the screens of the selected payment method, and the result screens. Render it inside PrimerCheckoutProvider and control it with the visible prop. The sheet renders in a React Native Modal, above the rest of your app. For a custom UI, build your own layout from the components and hooks instead.

Props

PrimerCheckoutSheetProps is exported from @primer-io/react-native as a type.

Closing the sheet

You control the sheet with visible. The sheet calls onRequestDismiss when:
  • The shopper taps the backdrop, while dismissOnBackdropPress is true.
  • The shopper swipes the drag handle down.
  • The shopper presses the Android back button on a screen without a Back button. On a screen with a Back button, Android back goes to the previous screen.
  • The shopper taps Cancel.
  • A success or pending result screen has been shown for 3 seconds.
  • A result screen is turned off in settings. See Result screens.
Without onRequestDismiss, none of these close the sheet: the backdrop and Cancel do nothing, a swipe springs back, and the success screen stays open. Always pass onRequestDismiss and set visible to false in it.
Results are delivered by the provider, not the sheet. They reach paymentOutcome and your callbacks while PrimerCheckoutProvider stays mounted, also after the sheet closes.

What the sheet shows

  1. Loading. The sheet opens on a loading screen while the checkout starts and the payment method resources load.
  2. Payment method selection. Saved payment methods come first when the shopper has any, then the payment methods of the client session.
  3. The payment method. A card opens the card form, with the billing address fields when the client session asks for them. Other payment methods open their own screen: a bank list, Klarna, the Stripe ACH details and mandate, or a short form for Bancontact card, MB WAY and BLIK. Payment methods with a native UI, such as Apple Pay, Google Pay or PayPal, open it while the sheet shows a processing screen.
  4. Processing. A loading screen while the payment runs.
  5. Result. A success screen, a pending screen for a pending Stripe ACH payment, or an error screen with Retry and an option to choose another payment method.

Result screens

Two settings in settings.uiOptions turn off the result screens: Your callbacks still run in both cases. Read the result as it arrives, as shown on the usePrimerCheckout page.

When the checkout fails to start

Watch usePrimerCheckout().error, close the sheet, and start again with a new client token.

Opening the sheet again

The content of the sheet is rebuilt each time it opens, so entered values and visible field errors reset. The checkout state of the provider is kept. Use a new client token, or a new PrimerCheckoutProvider, for each checkout attempt.

Placement

Render PrimerCheckoutSheet inside PrimerCheckoutProvider. It renders nothing until visible first becomes true, so a missing provider shows up as an error the first time the sheet opens:
The sheet sets up the card form and billing address state for its own screens. You don’t add PrimerCardFormProvider around it.

Styling

The sheet takes its look from the provider’s theme and from settings.uiOptions.appearanceMode. The sheet itself uses these tokens:

Usage

This example unmounts the provider in onDismiss, so each checkout attempt gets a new client token.

See also

PrimerCheckoutProvider

Start the session and set the callbacks.

usePrimerCheckout

Read the payment outcome from your own components.

PrimerSettings

Turn result screens on or off and set the appearance mode.

Handle the payment result

React to successful, pending and failed payments.