#Paris - Subscriptions
1 messages ยท Page 1 of 1 (latest)
Hello! Can you give me a request ID showing the payment_intent_incompatible_payment_method error you mentioned? Here's how you can find a request ID: https://support.stripe.com/questions/finding-the-id-for-an-api-request
req_8qvzhZkD39JKuY
Are you building your own payment page for this with Stripe Elements?
yes but i started having second thoughts on that :d
Can you share the code you're using to confirm this payment? Specifically looking for the code calling stripe.confirmPayment or stripe.confirmCardPayment.
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
Ah, okay, so that's the issue. You're not providing payment details. You're calling this, but there is no attached Payment Method: https://stripe.com/docs/js/payment_intents/confirm_card_payment#stripe_confirm_card_payment-attached
You need to instead call this with a reference to the Stripe Element that has the payment details in it: https://stripe.com/docs/js/payment_intents/confirm_card_payment
that makes sense, but why does it work on all the other times? ๐
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.
i also do that in the backend in this case
If you want to use that same Payment Method again you need to update the Payment Intent with it again.
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
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.
perfect, i will try what you suggested ๐ that is great help
You can update the Payment Method on the Payment Intent server-side using this API: https://stripe.com/docs/api/payment_intents/update#update_payment_intent-payment_method
Then your client-side code should work.