#MrGrygson
1 messages · Page 1 of 1 (latest)
it depends if the customer is paying for something at the same time as they are saving the card, or if they're purely on your web page just to save the card and you'll charge them later(hours/days later)
In general, they should also pay at the same time
if the former, you should use a PaymentIntent with setup_future_usage, if the latter, you'd use a SetupIntent
https://stripe.com/docs/payments/save-during-payment and https://stripe.com/docs/payments/save-and-reuse?platform=web respectively
So, I've configured code like on setup for future payments, just without checkout session, but using attach method as described in point 5 on this page.
My problem is that for running for some time, I got 2 errors while calling attach to payment method: card_declined, which means that the method that was just created cannot be used.
// Create the PaymentMethod using the details collected by the Payment Element
const { error, paymentMethod } = await stripe.createPaymentMethod({
elements,
// params: {
// billing_details: {
// name: "Jenny Rosen",
// },
// },
});
if (error) {
// This point is only reached if there's an immediate error when
// creating the PaymentMethod. Show the error to your customer (for example, payment details incomplete)
handleError(error);
return;
}
// Store new payment method
await store.storePaymentMethod("STRIPE", paymentMethod);
generally you would never call the direct attach API
what exact guide are you using, what is this point 5?
I'm not creating session
ah duh
then I don't really understand you. At no point would you manually attach the PaymentMethod. You confirm the SetupIntent, and that action automatically attaches the PaymentMethod to the Customer associated with the SetupIntent for you, that's it.