I'm working on integrating Stripe into my application and have encountered a scenario where users are able to add the same card multiple times. I want to prevent users from adding duplicate card entries.
Is there any built-in restriction in Stripe to prevent the addition of the same card again and again? If not, what would be the recommended approach to implement such a restriction on my end? I want to ensure a seamless user experience while avoiding unnecessary duplication of card entries.
Any insights or code snippets demonstrating how to handle this scenario would be greatly appreciated!
I'm using laravel. I've checked the relevant documentation on Stripe but couldn't find information specifically addressing this use case. I'm currently handling card additions through
$paymentMethod = $request->user()->addPaymentMethod($request->token);
//setting newly added card as default card if getting mark as default true in request
$request->input('mark_as_default') ? $request->user()->updateDefaultPaymentMethod($paymentMethod->id) : null;
return $paymentMethod;
Thank you in advance for your assistance!
It's possible to prevent duplicate cards, but that require some custom code. What you need to do:
fingerprintof all your existing PaymentMethodsfingerprintto the ones in your databasefingerprint, it means it's a duplicate