Save payment methods for checkoutBeta
Learn how to save payment methods for reuse in future Checkout Sessions.
Beta
The Custom Checkout integration is in private beta. To request access, click here.
Note
Custom Checkout support for saved payment methods only includes cards. It doesn’t support other saved payment methods, such as bank accounts.
Enable saved payment methods
Add an endpoint on your server that creates a Checkout Session object and set the ui_mode to custom
.
A Checkout Session represents your customer’s session as they pay for one-time purchases or subscriptions. Checkout Sessions expire 24 hours after creation. To allow a customer to save their payment method for future use, specify the saved_payment_method_options.payment_method_save parameter when creating the Checkout Session.
Saving a payment method requires a Customer. Pass an existing customer, or, to create a new customer, set the Checkout Session’s customer_creation to always
.
After you create the Checkout Session, use the client secret returned in the response to mount Elements.
Collect consent
Caution
Global privacy laws are complicated and nuanced. Before implementing the ability to store customer payment method details, work with your legal team to make sure that it complies with your privacy and compliance framework.
In most cases, you must collect a customer’s consent before you save their payment methods. The following example shows how to obtain consent using a checkbox.
Indicate to Stripe whether your customer has provided consent when you call confirm by passing the savePaymentMethod
parameter. When you save a customer’s payment details, you’re responsible for complying with all applicable laws, regulations, and network rules.
Next steps
Next, learn how to use saved payment methods in your checkout flow.