processout / processout-ios

MIT License
3 stars 7 forks source link

Invalid card is assigned to customer token #288

Closed sergey-shablenko closed 3 months ago

sergey-shablenko commented 3 months ago

I have been testing different error scenarios and found that when I run assignCustomerToken and get error like card.stolen, card is still assigned to customer token, when I fetch customer tokens after such failed request I get that stolen card in response. Is it intentional? How to determine if saved payment method is valid before attempting to charge?

andrii-vysotskyi-cko commented 3 months ago

How to determine if saved payment method is valid before attempting to charge?

Hi @sergey-shablenko, there is no 100% reliable way to determine whether payment method (token) is valid before charge (i.e. we can't guarantee that future charge will succeed, for example due to lack of money).

When fetching a token you could check its verification_status to understand whether it is in valid state to proceed with charge (expected state is success). Please check this doc for additional details.

card is still assigned to customer token

Normally the proposed flow is to do a customer token verification when a customer adds a card. In case assignment fails we suggest to delete a token.