Skip to main content
PrimerClientError is the type of errors returned by the SDK. Each error is described by an error code and description it may include contextual information.

Not all failures are retryable

Before prompting the user to retry after an error, keep two things in mind: A client-side error doesn’t always mean the payment failed. An error like PAYMENT_FAILED or PRIMER_SERVER_ERROR can be caused by conditions local to the browser — for example, a network drop after the payment was submitted. In that case the payment may have completed successfully even though the SDK reported a failure. Your server — through payment webhooks or the Payments API — is the source of truth for the payment’s status. Verify the status server-side before asking the user to pay again, otherwise you risk charging them twice. Decline reasons are intentionally generic. When a payment is declined, PAYMENT_FAILED doesn’t carry the specific decline reason. This is deliberate to avoid leaking details. The detailed reason is available to you server-side via webhooks, the Payments API, and the Primer Dashboard.

Deciding whether to retry

PrimerClientError doesn’t say whether the failure happened in transit, so use the presence of payment data in onCheckoutFail instead. A failure without payment may be network-caused — a payment may still have been created, so ask your backend before retrying. A failure with payment identifies the failed payment: cross-check its status and decline reason by payment.id before deciding whether to offer a retry.

Properties

Error Codes, Descriptions and Recovery Suggestions