Skip to main content

Quick diagnosis

Provider setup

Hook used outside PrimerCheckoutProvider

Cause: Primer components and hooks read the checkout session from the nearest PrimerCheckoutProvider above them. Outside one, they throw:
PrimerCardFormProvider also needs PrimerCheckoutProvider above it. A common cause is calling a hook in the same component that renders the provider. The hook then runs above the provider, not inside it. Solution: Call the hooks in a child component of PrimerCheckoutProvider:

Card form used outside PrimerCardFormProvider

Cause: PrimerCardForm, the card inputs and usePrimerCardForm read the card form state from PrimerCardFormProvider. Without it, they throw:
PrimerCheckoutSheet sets up its own card form state, so this error comes from a layout you build yourself. Solution: Put PrimerCardFormProvider inside PrimerCheckoutProvider, around your card UI. Your own Pay button does nothing shows the full setup.

Configuration and initialization

Checkout fails to start

Cause: The checkout can’t start, for example because of an invalid or expired client token, a network issue, or an incorrect API key when your server created the client session. usePrimerCheckout().isReady stays false and usePrimerCheckout().error is set. PrimerCheckoutSheet moves from its loading screen to its error screen. Solution: Generate a fresh client token on your server for each checkout attempt. Read the ID and message of usePrimerCheckout().error and show your own message:
To try again, close the sheet and pass a new client token to the provider, or mount a new provider.

Checkout restarts unexpectedly

Cause: The provider starts a new session whenever the clientToken value changes, and ends the session when it unmounts. A client token fetched again on a re-render, or a provider inside a component that unmounts and mounts again, restarts the checkout from the loading screen and resets its state, including paymentOutcome. Solution: Fetch one client token per checkout attempt, keep it in state, and render the provider in a component that stays mounted for the whole checkout:
To reload the session after your backend updates the client session, pass a new client token.

Prebuilt sheet

The sheet doesn’t close

Cause: You control PrimerCheckoutSheet with its visible prop. The sheet calls onRequestDismiss when the shopper taps the backdrop or Cancel, swipes the drag handle down, or presses the Android back button on a screen without a Back button, and when the success screen has been shown for 3 seconds. Without onRequestDismiss, none of these close the sheet: a swipe springs back, and the backdrop and Cancel do nothing. Solution: Set visible to false in onRequestDismiss:

Payment methods

Payment method missing

Cause: Multiple possible causes:
  • No payment methods configured in the Primer Dashboard for the client session’s currency and country
  • Client session missing the currencyCode or countryCode field
  • A native dependency that the payment method needs isn’t installed, for example the PrimerKlarnaSDK pod for Klarna on iOS
Solution: Verify your Dashboard configuration and make sure your client session includes the correct currencyCode and countryCode. Add the native dependencies as described in Native setup. To see which payment methods the session returned, use the snippet in Inspect available payment methods.

Apple Pay or Google Pay not available

Cause: Apple Pay is available on iOS only, and Google Pay on Android only. On the other platform, usePrimerPaymentMethod(type).isAvailable is false. When the wallet is in the session as a native UI method, for example Google Pay on iOS, availabilityError.code is PLATFORM_NOT_SUPPORTED and start() rejects with a PrimerError whose errorId is google-pay-unavailable or apple-pay-unavailable. Solution: Check isAvailable before you show or start a wallet. Enable Apple Pay or Google Pay for your session in the Dashboard. For Apple Pay, add the Apple Pay capability to your iOS app and pass paymentMethodOptions.applePayOptions.merchantIdentifier. See Native setup.

Shopper doesn’t return to your app after a redirect

Cause: Payment methods that leave your app, such as PayPal and Klarna, return to it through a URL. On iOS, that needs a URL scheme registered in your app and paymentMethodOptions.iOS.urlScheme. On Android, Klarna needs paymentMethodOptions.klarnaOptions.returnIntentUrl. Without it, selecting a Klarna payment category ends the attempt with the errorId klarna-return-url-missing. Solution: Register the URL and pass it in settings, as described in Native setup. For Klarna on Android, also add the return activity from the Klarna section.

Card form

Your own Pay button does nothing

Cause: usePrimerCardForm().submit() never rejects. It returns without submitting when:
  • The checkout isn’t ready yet (isReady is false)
  • The card payment method wasn’t started with start() from usePrimerPaymentMethod('PAYMENT_CARD')
  • A submit is already running
  • isValid is false
In each case, it marks the submit as attempted, so the card fields show their errors. Until you call start(), the SDK validates nothing, isValid stays false, and typing in the card fields logs a warning:
Solution: Start the card payment method once the checkout is ready, gate your button on isValid, keep your own flag from the tap until paymentOutcome arrives, then show the result in place of the form:

Form shows invalid despite all visible fields being filled

Cause: isValid comes from the native SDK. A card field you left out of your own layout stays empty, so when the session requires it, isValid stays false. requiredFields lists the fields the native SDK requires. The cardholder name is hidden only when the client session’s CARD_INFORMATION checkout module turns it off, which isCardholderNameVisible reports. A field’s error shows only after the shopper focuses the field and leaves it with a value in it, or after a submit attempt. Fields you build yourself must call markFieldFocused and markFieldBlurred, or their errors stay hidden until a submit attempt. Solution: Render PrimerCardForm, which shows the cardholder name field whenever isCardholderNameVisible is true, or render every card input yourself. Inspect errors and requiredFields with the snippet in Log card form validation errors. See When errors show.

Installation

For installation and build issues, such as 'NativePrimer' could not be found when the app imports @primer-io/react-native, pod install failing on PrimerSDK, or Android Unresolved reference errors, see Troubleshooting in the React Native SDK reference.

Validation vs payment errors

Understanding the difference helps with proper error handling:
Don’t confuse these two error types. Validation errors prevent form submission and are shown inline. Payment failures occur after the form is submitted and require explicit handling.

Debugging tips

Log the payment outcome

usePrimerCheckout().paymentOutcome carries the result of every payment attempt. Render this component anywhere inside PrimerCheckoutProvider:

Check checkout readiness

If isReady stays false, the checkout is either still starting or failed to start, so check error:

Inspect available payment methods

Read the payment methods of the session from usePrimerPaymentMethods once they have loaded:

Log card form validation errors

Render this component inside PrimerCardFormProvider. It logs field names and validation messages:

Read the SDK’s console messages

The React Native layer of the SDK writes warnings and errors to the JavaScript console, which you can read in React Native DevTools. Each message starts with a prefix that names its source, for example: For the native SDKs, check the Xcode console on iOS and Logcat on Android.

Getting help

When contacting Primer support, include:
  1. The diagnosticsId from the error
  2. The errorId and description of the error
  3. Your @primer-io/react-native version, React Native version, platform and OS version
  4. Steps to reproduce the issue
Never include card numbers, expiry dates or security codes in logs, screenshots or support requests.

See also

Events guide

Event handling patterns

Build a custom card form

Card form tutorial

Installation troubleshooting

Fix installation, build and native setup issues

PrimerError

Error fields and the error IDs the SDK raises