#av-savedcards
1 messages · Page 1 of 1 (latest)
doesn't seem like there is a direct Github sample unfortunately, but https://stripe.com/docs/payments/save-during-payment?platform=web is the overall guide and covers that exactly.
If it helps, there's no actual change on the frontend, the only that that's different from the regular non-saving use cases is the arguments you pass on the backend when creating a PaymentIntent.
Let me know if anything specific is unclear
I think I've worked out the saving part using the payment element, the bit I'm not sure about is how allow the user to add a new method if it gets rejected when charging off-session.
Is this maybe because only cards can be changed off-session? Can google/apple pay be charged later?
ah, well that is a case of basically redirecting them to your existing payment page.
If you already have a page that charges a card using the PaymentElement and saves it to a customer, you'd send the customer there if off-session payment fails.
you can save the cards entered with Google/Apple Pay and charge them the same as other cards, in general, it's all the same
I see, thanks. Do you mean that I can create a payment element using the client secret of a PaymentIntent that was declined?
you can yes, you can re-use the same PaymentIntent until it succeeds
this is partly why when you charge the card offsession and it declines, the PaymentIntent detaches the card and goes to the requires_payment_method state, so you can then plug it into an existing payment page to do a retry
I'll try that! Also, in the case of authentication being required to complete the offsession payment, the sample on github uses the stripe.confirmCardPayment function instead of stripe.confirmPayment in order to let the customer authenticate. Do I need to change this to make it work with payment element?
you'd still use confirmCardPayment I believe
remember, you don't actually have an Element here. It's just a page with a "press this to try again" which then attempts the payment on the saved card and can present 3D Secure, you're not recollecting a card from an Element/PaymentElement , that would be separate later if the customer's save card is not working and they want to try a different one
Thank you so much @leaden osprey , this worked. One more thing, when the payment fails and the user uses an alternative card, can I save this second card to the customer object? Using setup_future_usage doesn't seem to work as that cannot be used with off_session = true
ah good point