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.
Each payment attempt ends in a paymentOutcome on usePrimerCheckout(). It reports the result of every payment the native SDK processes, for every payment method, so build your result handling on it. The provider callbacks onCheckoutComplete and onError are useful for logging.

Payment outcomes

paymentOutcome is null until the first attempt ends. After that, it holds the latest outcome until the next outcome replaces it or it’s cleared, for example by clearPaymentOutcome() or by the prebuilt sheet. data.payment holds the payment’s id and orderId.
A 'success' outcome can also be a payment that is still pending. For every payment method, confirm the payment status on your server with the payment ID before you fulfill the order.

Read the outcome

Read paymentOutcome from a component inside PrimerCheckoutProvider. usePrimerCheckout() throws outside the provider.
confirmOrder, showPendingNotice and logPaymentFailure stand for your own code. The effect runs once for each new outcome, as long as onOutcome keeps the same identity, which useCallback ensures here.

With the prebuilt sheet

PrimerCheckoutSheet shows a result screen for each outcome: The sheet closes only when your onRequestDismiss sets visible to false. To skip the result screens, set settings.uiOptions:
  • isSuccessScreenEnabled: false skips the success and pending screens.
  • isErrorScreenEnabled: false skips the error screen. The shopper then gets no retry in the sheet.
When a screen is skipped, the sheet calls onRequestDismiss instead of showing it, and clears the outcome at the same time. Read the outcome in an effect, as in the example above, so you don’t miss it. Skipping a screen doesn’t change what the callbacks report.
Use a new client token and a new PrimerCheckoutProvider for each checkout attempt. Mount the provider when you open the sheet and unmount it in onDismiss, as in the example above.

With a custom layout

Without PrimerCheckoutSheet, nothing shows the result for you. Render your own result UI from paymentOutcome.
  • When the shopper cancels a payment method with its own UI, such as Apple Pay, Google Pay or PayPal, paymentOutcome is an error with errorId payment-cancelled. Check for it so you don’t show a cancel as a failed payment. See PrimerError.

Callbacks

PrimerCheckoutProvider also reports results through two callbacks:
trackPaymentCreated and trackPaymentError stand for your own code.

Errors when the checkout starts

usePrimerCheckout().error is set when the checkout fails to start, for example because the client token has expired. isReady stays false. Payment errors don’t go there: they arrive in paymentOutcome. Read the error’s ID and message, as in this example:
In the prebuilt sheet, a start-up error shows the error screen. To try again, close the sheet and mount PrimerCheckoutProvider again with a new client token.

Read a PrimerError

paymentOutcome.error and the error argument of onError are typed as PrimerError: Log errorId and diagnosticsId, and include diagnosticsId in support requests when it’s set. See PrimerError for the error IDs the SDK raises.

See also

usePrimerCheckout

Checkout state, paymentOutcome and start-up errors

PrimerCheckoutSheet

The prebuilt sheet and its dismissal props

PrimerError

Error fields and error IDs

Checkout data

CheckoutData, PaymentOutcome and the client session