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 withimport 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 aPrimerError. 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 fromusePrimerCheckout().error:
clientToken, or remount PrimerCheckoutProvider.
Handling payment errors
WatchpaymentOutcome to catch every failed attempt.
Errors raised by the React Native layer
These are other error IDs you can see inpaymentOutcome 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 sessionPrimerSettings
Settings behind several of these errors