#Paris - Subscriptions

1 messages ยท Page 1 of 1 (latest)

sharp cipher
grizzled belfry
#

req_8qvzhZkD39JKuY

sharp cipher
#

Are you building your own payment page for this with Stripe Elements?

grizzled belfry
#

yes but i started having second thoughts on that :d

sharp cipher
#

Can you share the code you're using to confirm this payment? Specifically looking for the code calling stripe.confirmPayment or stripe.confirmCardPayment.

grizzled belfry
#

i am using this const { error: errorAction, paymentIntent } = await stripe.confirmCardPayment(paymentIdent.client_secret);

#

where the client_secret, comes from the payment_ident that is on the last_invoice od the subscription

sharp cipher
grizzled belfry
#

that makes sense, but why does it work on all the other times? ๐Ÿ˜„

sharp cipher
#

The other times there must already be a Payment Method attached to the Payment Intent.

#

I think the issue you're running into is that, when a payment fails, the Payment Method is removed from the Payment Intent.

grizzled belfry
#

i also do that in the backend in this case

sharp cipher
#

If you want to use that same Payment Method again you need to update the Payment Intent with it again.

grizzled belfry
#

await stripe.paymentMethods.attach(paymentMethodID, {
customer: customerID,
});
// Set the payment method as the 'default' for this customer
await stripe.customers.update(customerID, {
invoice_settings: {
default_payment_method: paymentMethodID,
},
});

#

i use this in the server

sharp cipher
#

That attaches the Payment Method to the Customer, and sets it as the default for Invoices.

#

That's good and fine, but when the payment fails that Payment Method is detached from the Payment Intent that failed.

grizzled belfry
#

perfect, i will try what you suggested ๐Ÿ™‚ that is great help

sharp cipher
#

Then your client-side code should work.

grizzled belfry
#

that is amazing ๐Ÿ™‚

#

thanks a lot

#

i did what you suggested, attached payment method in the server side instead of the client and it works as expected ๐Ÿ˜› you are a Star Rubeus ๐Ÿ™‚