#jayy26
1 messages ยท Page 1 of 1 (latest)
You'd need to do that manually after session completion
so on the 'payment_method.attached' event ?
Listen for a checkout.session.completed event then update the invoice_settings.default_payment_method field: https://stripe.com/docs/payments/accept-a-payment?platform=web&ui=checkout#prefill-customer-data
can you tell me what am i doing wrong with this >> req_mRepcfrX1PXQ2P
I am doing a charge using the following:
await stripe.charges.create({
amount: Math.floor(charge * 100),
description: 'Prorated charge for subscription update.',
customer: paymentMethod.user.stripeCustomerId!,
currency: paymentMethod.user.currency,
})
it says Cannot charge a customer that has no active card
but i did set it as default
so i'm not sure what am i doing wrong here ..
๐
๐
Why are you using the Charge endpoint? This is a very old API that we don't recommend using.
Instead you should create a PaymentIntent, and pass the payment_method parameter: https://stripe.com/docs/api/payment_intents/create
i wanted to create a 1 time charge to the customer
Then you should use a PaymentIntent
and i pass confirm: true?
Yes
wait i'm a little bit confused. so confirm: true skips the redirection to stripe and just charges the customer yes? so what about off_session ?
i'm gonna test this:
await stripe.paymentIntents.create({
amount: Math.floor(charge * 100),
currency: paymentMethod.user.currency,
customer: paymentMethod.user.stripeCustomerId!,
capture_method: 'automatic',
off_session: true,
description: 'Prorated charge for subscription update.',
confirm: true,
})
to see if it works
doesn't it use the default one attached to the customer already ?
The default is only used by Billing products (so invoices and subscriptions, not PaymentIntents)