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
ReadpaymentOutcome 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: falseskips the success and pending screens.isErrorScreenEnabled: falseskips the error screen. The shopper then gets no retry in the sheet.
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.
With a custom layout
WithoutPrimerCheckoutSheet, 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,
paymentOutcomeis an error witherrorIdpayment-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:
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