#idhruv-payment-method
1 messages ยท Page 1 of 1 (latest)
thanks river
i am calling stripe.paymentMethods.detach while removing the already saved cards from our ui
after using the same card again to pay it throws this error mentioned above
Upon checking,
pm_1LcvjaGdNldKu1zm20S304qO was used in pi_3LcvjOGdNldKu1zm1WHLay6I [0] previously without attaching to a customer.
When a card was used without being attached to a customer, it cannot be used again.
[0] https://dashboard.stripe.com/test/payments/pi_3LcvjOGdNldKu1zm1WHLay6I
I'd recommend save the payment method to the customer while charging to the customer using Payment Intent with the steps here: https://stripe.com/docs/payments/save-during-payment
So that no additional attach request is required
okay but now how can i reuse this card
? it is the test card
and while testing i had some failed attempts previously where i paid without attaching the customer first
this is where it was attached and then i removed it
Based on cus_KnJ92zEgAonAPr [0], these two cards are already attached to the customer.
In order to use saved card, the steps will be:
- Get the payment methods of the customer: https://stripe.com/docs/api/payment_methods/customer_list
- Let the customer choose the payment method and pass its Payment Method ID (pm_xxx) in the Payment Intent Create request: https://stripe.com/docs/payments/save-during-payment?platform=web#charge-saved-payment-method
[0] https://dashboard.stripe.com/test/customers/cus_KnJ92zEgAonAPr
okay this is already happening
but my question is
i am trying to use a different card here because of which the error is getting triggered
it is this card that ends with 3220 that triggers the error, how i can i reuse it
Also another question. this is our current workflow:
- create payment intent (on backend nodejs)
- confirm card payment (on ui)
- create customer (on backend)
3.1. attach payment method
to this customer - acknowledge payment done in our db on final response
is this flow correct?
We cannot create customer without payment_method which we get from paymentIntent, so we are forced to create a paymentIntent with customer value pointing to null and then we try to attach payment method generated to the customer. Is this correct as well?
In order to save card onto the customer, the payment method must not be used for any payment. In your current workflow, payment method has been used in Step 1 and 2 before Step 3 that causing payment method attachment to the customer at Step 3 to fail.
The correct way will be:
- Create a customer
- Create a payment intent and set
customer,setup_future_usage: 'off_session'
Payment methods will be attached to the customer with above steps. For more details, you can refer to the doc here: https://stripe.com/docs/payments/save-during-payment
No problem! Happy to help ๐