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.
PrimerError describes a payment or checkout failure. Every error has an errorId to branch on and a description to log. Errors usually carry a diagnosticsId to share with Primer support.

Definition

Import the type with import type { PrimerError } from '@primer-io/react-native'. The block below shows the shape of the type, not code to copy.

Properties

Where errors arrive

You never create a PrimerError. Primer Checkout delivers it through these channels: A shopper who cancels a payment method with its own UI, for example by closing the Apple Pay, Google Pay or PayPal sheet, produces errorId payment-cancelled. To treat a cancel differently from a failure, check errorId.

Reading an initialization error

Read the ID and message of an initialization error from usePrimerCheckout().error:
To recover from an initialization error, start a new session with a new clientToken, or remount PrimerCheckoutProvider.

Handling payment errors

Watch paymentOutcome to catch every failed attempt.
When you contact Primer support about a failure, include the diagnosticsId. It identifies the exact occurrence in Primer’s logs.

Errors raised by the React Native layer

These are other error IDs you can see in paymentOutcome and the other channels in Where errors arrive. The *-start-failed, *-submit-failed, *-mandate-failed and *-decline-failed IDs wrap a failure that was not a PrimerError, such as a rejected native call. Their description is the original error’s message. When the underlying failure is already a PrimerError, it arrives unchanged, with its own errorId. The native bridges of the React Native SDK raise errors with their own IDs too, for example native-ios, native-bridge and native-android. They arrive through the same channels as errors from the native SDK, see Where errors arrive. Branch on errorId and log description.

See also

usePrimerCheckout

paymentOutcome, error and retry()

Handle the payment result

Success, pending and failure end to end

Checkout data

CheckoutData, PaymentOutcome and the client session

PrimerSettings

Settings behind several of these errors