#sspl-paymentintent-errors

1 messages · Page 1 of 1 (latest)

crude canopy
#

hello

#

The error indicates that the PaymentMethod was not attached to a customer before, or was detached since then

#

you are trying to use a PaymentMethod id pm_123 that was never attached successfully

#

if the original charge fails the PaymentMethod isn't attached

craggy summit
#

Thanks @crude canopy for responding to my question. Just to confirm my understanding, so if the payment intent was successful, the payment method would have been attached to the consumer as a result of setting "setup_future_usage"="off_session" , right? Those requests failed because the previous payment intents failed and thus the attachment didn't happen?

crude canopy
#

yes

#

the goal is to avoid attaching a card that failed

#

otherwise every attempt would attach bad card over and over

craggy summit
#

What should I do to prevent the error from happening again?

#

I was under the impression that "setup_future_usage"="off_session" would always ensure the payment method is attached to the consumer specified in my payment intent

#

For example, if a payment intent failed but the given payment method was valid, the attachment didn't happen. Subsequently when I make another payment intent with the same payment method it would have failed with the error The provided PaymentMethod was previously used with a PaymentIntent without Customer attachment... which is something I am trying to prevent

crude canopy
#

If the payment fail we consider the PaymentMethod invalid, we'll never attach it

#

so you need to understand that behaviour and adapt to it. You can not re-use a card that failed, you have to treat it as a failure and not store its PaymentMethod id, it can never be re-used

craggy summit
#

Thanks for clarifying. However, a payment intent could fail for different reasons other than invalid payment method. Does Stripe examine the error/decline reason or does Stripe always deem the PaymentMethod invalid?

crude canopy
#

always invalid

craggy summit
#

Interesting. For our use case we would want to be able to retry payment (create a new payment intent) with the same payment method on a different day. For example a customer might not have enough credit today but they pay down their credit card bill on the next day.

#

Is there a way to explicitly attach the payment method to the consumer? Or must I create a new payment method?

crude canopy
#

We mostly discourage this. You're clearly displaying an error toyour customer that it didn't work, they are unlikely to be okay with you just retrying days later without their approval

craggy summit
#

I see. For the record we do obtain their approval for charging them on a later date.

crude canopy
#

in that case you need to change your flow and you have to first attach the PaymentMethod to a customer via the SetupIntent API

#

cc @elfin sable who is taking over for me

craggy summit
#

Thanks @crude canopy - I will look into SetupIntent API.

#

@elfin sable - Is there a way to check whether a payment method has been attached to a consumer in Stripe dashboard?