Save a card
Store a card with the customer’s consent and charge it again later.
In beta. Saving a card and charging it later both work, and are tested end to end. What is not yet settled is a permission the bank grants per merchant, and the exact parameter it expects on a merchant-initiated charge — which is documented nowhere and which the integration this was built from never proved in production. Expect it to work; tell us if a charge is refused, because that is a question for the bank rather than for your code.
Ask to save it
Cards belong to a customer, so create one first. Then set setup_future_usage on the payment the customer is making now.
ts
const customer = await sp.customers.create({
email: "diver@example.com",
name: "Reuben Arnold",
});
const intent = await sp.paymentIntents.create({
amount: 6000,
currency: "usd",
customer: customer.id,
setup_future_usage: "off_session",
});When the payment succeeds you get a payment_method.attached event, and the card appears on the customer.
Charge it later
ts
const methods = await sp.customers.listPaymentMethods(customer.id);
const card = methods.data[0];
await sp.paymentIntents.create({
amount: 4500,
currency: "usd",
customer: customer.id,
payment_method: card.id,
off_session: true,
confirm: true,
});It can still be refused
A card issuer can decline a charge the cardholder is not present for, and may ask for authentication instead. When that happens the payment reaches requires_action with a URL in next_action — you will need the customer back to complete it. Build for that rather than assuming a saved card always works.
What we hold
Never a card number. What we store is a token from the bank, the masked number, the brand and the expiry — enough to show the customer which card it is, and nothing that could be used anywhere else.