Quick diagnosis
Provider setup
Hook used outside PrimerCheckoutProvider
Cause: Primer components and hooks read the checkout session from the nearestPrimerCheckoutProvider 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:
Checkout restarts unexpectedly
Cause: The provider starts a new session whenever theclientToken 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:
Prebuilt sheet
The sheet doesn’t close
Cause: You controlPrimerCheckoutSheet 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
currencyCodeorcountryCodefield - A native dependency that the payment method needs isn’t installed, for example the
PrimerKlarnaSDKpod for Klarna on iOS
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 andpaymentMethodOptions.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 (
isReadyisfalse) - The card payment method wasn’t started with
start()fromusePrimerPaymentMethod('PAYMENT_CARD') - A submit is already running
isValidisfalse
start(), the SDK validates nothing, isValid stays false, and typing in the card fields logs a warning:
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:Debugging tips
Log the payment outcome
usePrimerCheckout().paymentOutcome carries the result of every payment attempt. Render this component anywhere inside PrimerCheckoutProvider:
Check checkout readiness
IfisReady 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 fromusePrimerPaymentMethods once they have loaded:
Log card form validation errors
Render this component insidePrimerCardFormProvider. 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:- The
diagnosticsIdfrom the error - The
errorIdanddescriptionof the error - Your
@primer-io/react-nativeversion, React Native version, platform and OS version - Steps to reproduce the issue
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