> ## Documentation Index
> Fetch the complete documentation index at: https://primer.io/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# PrimerCheckoutSheet

> Prebuilt bottom sheet that runs the whole checkout, from payment method selection to the result screen.

> [!WARNING]
>
> 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`](https://primer.io/docs/sdk/react-native-checkout/v3.0.0-beta/api/primer-checkout-provider) 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

```tsx theme={"dark"}
interface PrimerCheckoutSheetProps {
  visible: boolean;
  onDismiss?: () => void;
  onRequestDismiss?: () => void;
  dismissOnBackdropPress?: boolean;
}
```

| Prop | Type | Default | Description |
| - | - | - | - |
| `visible` | `boolean` | Required | Opens the sheet when it becomes `true` and closes it, with an animation, when it becomes `false`. |
| `onRequestDismiss` | `() => void` | — | Called when the shopper or the sheet asks to close. Set `visible` to `false` here. See [Closing the sheet](#closing-the-sheet). |
| `onDismiss` | `() => void` | — | Called after the sheet has finished closing. |
| `dismissOnBackdropPress` | `boolean` | `true` | Whether a tap on the backdrop calls `onRequestDismiss`. |

`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](#result-screens).

> [!WARNING]
>
> 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:

| Setting | Effect |
| - | - |
| `isSuccessScreenEnabled: false` | Skips the success and pending screens. The sheet clears `paymentOutcome` and calls `onRequestDismiss`. |
| `isErrorScreenEnabled: false` | Skips the error screen after a failed payment. The sheet clears `paymentOutcome` and calls `onRequestDismiss`. The shopper gets no Retry button. |

Your callbacks still run in both cases. Read the result as it arrives, as shown on the [`usePrimerCheckout`](https://primer.io/docs/sdk/react-native-checkout/v3.0.0-beta/api/use-primer-checkout#reacting-to-the-payment-outcome) page.

### When the checkout fails to start

Watch [`usePrimerCheckout().error`](https://primer.io/docs/sdk/react-native-checkout/v3.0.0-beta/api/use-primer-checkout#reading-a-start-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:

```text theme={"dark"}
usePrimerCheckout must be used within a <PrimerCheckoutProvider>. Wrap your component tree with <PrimerCheckoutProvider clientToken="...">.
```

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`](https://primer.io/docs/sdk/react-native-checkout/v3.0.0-beta/api/theming/primer-theme-override) and from `settings.uiOptions.appearanceMode`. The sheet itself uses these tokens:

| Part | Token |
| - | - |
| Backdrop | `colors.overlay` |
| Sheet background | `colors.backgroundPrimary` |
| Top corners | `radii.large` |

## Usage

```tsx theme={"dark"}
import { useEffect, useState } from 'react';
import { Button } from 'react-native';
import {
  PrimerCheckoutProvider,
  PrimerCheckoutSheet,
  usePrimerCheckout,
} from '@primer-io/react-native';
import { fetchClientToken, showOrderConfirmation } from './checkout-api';

function OrderConfirmation() {
  const { paymentOutcome } = usePrimerCheckout();

  useEffect(() => {
    if (paymentOutcome?.status === 'success') {
      showOrderConfirmation(paymentOutcome.data.payment?.id);
    }
  }, [paymentOutcome]);

  return null;
}

export function CheckoutButton() {
  const [clientToken, setClientToken] = useState<string | null>(null);
  const [visible, setVisible] = useState(false);

  const openCheckout = async () => {
    setClientToken(await fetchClientToken());
    setVisible(true);
  };

  return (
    <>
      <Button title="Checkout" onPress={openCheckout} />
      {clientToken !== null && (
        <PrimerCheckoutProvider clientToken={clientToken}>
          <OrderConfirmation />
          <PrimerCheckoutSheet
            visible={visible}
            onRequestDismiss={() => setVisible(false)}
            onDismiss={() => setClientToken(null)}
          />
        </PrimerCheckoutProvider>
      )}
    </>
  );
}
```

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

## See also

> [card] [PrimerCheckoutProvider](https://primer.io/docs/sdk/react-native-checkout/v3.0.0-beta/api/primer-checkout-provider.md)
>
> Start the session and set the callbacks.

> [card] [usePrimerCheckout](https://primer.io/docs/sdk/react-native-checkout/v3.0.0-beta/api/use-primer-checkout.md)
>
> Read the payment outcome from your own components.

> [card] [PrimerSettings](https://primer.io/docs/sdk/react-native-checkout/v3.0.0-beta/api/common/primer-settings.md)
>
> Turn result screens on or off and set the appearance mode.

> [card] [Handle the payment result](https://primer.io/docs/sdk/react-native-checkout/v3.0.0-beta/guides/handle-payment-result.md)
>
> React to successful, pending and failed payments.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.