usePrimerVaultManager gives you the customer’s saved (vaulted) payment methods and the actions to pay with or delete one. Use it to build saved-method UI in a custom layout; the prebuilt PrimerCheckoutSheet shows saved methods itself.
The provider loads the saved methods once the checkout is ready, and again after every client session update, whether or not a component uses this hook. Call the hook inside PrimerCheckoutProvider; it throws outside one.
Saved payment methods belong to a customer, so create the client session with a
customerId.Signature
Returns
To tell “not loaded yet” from “no saved methods”, check
usePrimerCheckout().isReady together with isLoading.
VaultedPaymentMethodItem
One saved method, ready to render. It is a union onkind.
Fields for
kind: 'card':
Fields for
kind: 'bank':
Fields for
kind: 'other':
Pay with a saved method
pay and payById clear the previous payment outcome and start the payment. The native SDK runs it, and the result arrives in usePrimerCheckout().paymentOutcome, like any other payment.
- They don’t reject. A failure ends the attempt with an error outcome.
- They do nothing until the saved methods have been set up during the first load.
- Keep your own loading flag: set it on tap and clear it only when
paymentOutcomereports a failure.
paymentOutcome.error and show your own message in your UI. See PrimerError for the error IDs.
CVV recapture
requiresVaultedCardCvv is true when the client session asks for the CVV of saved cards again (the card option captureVaultedCardCvv).
When requiresVaultedCardCvv is true and the method is a card, render your own CVV field and pass the value: pay({ cvv }) or payById(id, { cvv }). A CVV has 3 or 4 digits, depending on the card network.
VaultedPaymentMethodAdditionalData is { cvv: string }.
Delete a saved method
deleteVaultedPaymentMethod(id) deletes the method at once, with no confirmation step. Add your own confirmation if you want one.
- When the delete succeeds, the list reloads. If the deleted method was the selected one, the first remaining method becomes
activeMethod. If the reload fails, the deleted method is still removed fromvaultedMethodsand the promise resolves. - It rejects in three cases:
{ errorId: 'INVALID_VAULTED_METHOD_ID', description }whenidisn’t invaultedMethods.{ errorId: 'VAULT_MANAGER_NOT_CONFIGURED', description }when the saved methods haven’t been set up yet.- The native SDK’s error when the delete itself fails.
Usage
A list of saved methods with a Pay button and CVV recapture:See also
usePrimerCheckout
The payment outcome and checkout state.
Handle the payment result
React to success, pending and error outcomes.
PrimerPaymentMethodList
List the session’s other payment methods.
PrimerError
Error fields and where errors arrive.