-
Notifications
You must be signed in to change notification settings - Fork 548
PaymentIntent - Same card is saved multiple times #45
Comments
@yns01 thanks for raising this! I'm discussing with the team and will get back to you. Quick question on the use-case. Do you give the customer the option to select their stored card(s) instead of typing in the card number? Therefore the scenario would be:
Is that correct? |
@thorsten-stripe We give the customer the option to select one of their stored credit card but also to enter a new one to pay and eventually store it if they chose to. The scenario is correct, yes. |
@yns01 thanks. We're looking at options for automatic deduping, will keep you posted here. As it stands today you have two options:
Hope this works for you in the meantime. |
@thorsten-stripe Any new on a more robust and permanent solution? |
Any updates on this guys ? |
We're working on a more elegant solution, in the meantime, please use one of the deduplication approaches outlined above. You can find an example implementation here: dffb17f |
Any updates on this one? |
@nticaric no automatic deduping yet, but you can utilise the manual confirmation integration flow[0] which allows you to check the PaymentMethod before creating/confirming the PaymentIntent. [0] https://stripe.com/docs/payments/payment-intents/quickstart#manual-confirmation-flow |
Not yet the deduping functionality you've been hoping for, but wanted to quickly follow-up that post-payment attachment of a payment method to a customer object is now available via the SCA off-session payment APIs[0], which might be helpful for some of you. [0] https://stripe.com/docs/payments/cards/saving-cards#saving-card-after-payment |
We've published a video that specifically looks at customer management / card-on-file with regard to SCA which you might find helpful if you landed here: https://youtu.be/52oinv6BZ34 |
For those who use
Does it make sense @thorsten-stripe ? |
@Pyo25 Yes, that works, and good to call out that the fingerprint stays the same even if the card number gets a new expiration date. One quick note, in an ideal integration you'd be checking against the data in your own DB instead of listing all PMs for the customer. |
Yeah indeed! |
I am using handleCardPayment method and i am saving card for future use in it. This methods add card every time weather the result is success or error. Can anyone help with it? I want to add it only when the payment succeeds. |
I think fingerprint stays the same even when billing address and name details change (at least with test card it did), so need to check for that too and if it doesn't match, then update your DB and Stripe with new details. |
Thanks @Pyo25! @thorsten-stripe, I agree with your point about ideal integration way, but there is also point about service that allows you to install and use with almost no-thinking-required way. From that point of view I would say that having an option to perform idempotent operation on payment method is a must have. What if introduce this as option to payment method attach (both through PaymentMethod API or PaymentIntent API)? So if I want it, they will simply reuse existing payment method, as long as it's clearly distinguishable by (fingerprint, exp. month, exp. year). |
@GrafGenerator |
I think Stripe API could just overwrite duplicated card with the newer one and save us trouble adding unnecessary "remove duplicates" code. |
After integrating the stripe API into my app for a few hours I also came across this issue. Any updates on de-duping? Seems like something that should just work at the stripe level. |
+1 Having the same issue. |
Any news about this? |
A simple check to check duplicate card OR manual option to Allow/Disallow duplicate cards should do the trick, Why this has not been addressed? :) |
I understand that you are looking for a way to automatically de-duplicate payment methods upon saving, however the experience for this is very specific to individual use cases. For example, why is the user entering the same card again instead of selecting the stored one? Are they trying to update their billing details? As you know your customers best, we recommend the approaches outlined above and adapting them to your customer's needs. To make things easier, we have updated the saving behaviour to only attach payment methods to the customer if the payment was successful. This avoids the situation where potentially invalid payment methods are saved to the customer. You can learn more in our guide: https://stripe.com/docs/payments/save-during-payment We've noted your desire for an option to automatically de-duplicate and are actively exploring this as we work to improve the ergonomics around payment method attachment. For the time being, I'm going to close out this issue as it doesn't directly relate to the demo. If you have additional questions about this, please reach out to support using the form at https://support.stripe.com/ (preferred) or via email to [email protected]. Thanks everyone for the valuable feedback! To get updates vial email you can subscribe to our developer digest at the bottom right of docs: https://stripe.com/docs |
I have noticed that the number of duplicata card is equal to the number of time that the stripe form has been mount and unmount I think is due to eventListener that has not been delete I think |
This is working example for duplicate payment methods avoidance for PHP // Response from frontent JS
$json_str = file_get_contents('php://input');
$body = json_decode($json_str);
// Retrieve confirmedpayment method
$paymentMethod = \Stripe\PaymentMethod::retrieve($body->payment_method);
// Get all customer CARD payment methods
$methods = \Stripe\PaymentMethod::all([
'customer' => $this->customer->id, // $this->customer->id is running PHP object instance customer ID variable.
'type' => 'card',
]);
if ($methods) {
foreach ($methods->data as $card) {
if (
$card->card->fingerprint == $paymentMethod->card->fingerprint &&
$card->card->exp_month == $paymentMethod->card->exp_month &&
$card->card->exp_year == $paymentMethod->card->exp_year
) {
// set matching payment method as current.
$paymentMethod = $card;
break;
}
}
}
// Attach to customer "again" (not needed?)
$paymentMethod->attach([
'customer' => $this->customer->id,
]); |
@thorsten-stripe : This issue is affecting the hosted invoice page by Stripe now. Every time a customer pays an invoice on the hosted invoice page, it keeps saving the same card every single time. I don't know how to solve this issue at all because it's out of my hand to control how the hosted invoice page works. |
@thorsten-stripe,
|
Same problem here |
I am providing customers to use an already saved card, but the option to add new card too. I don't know why it is so difficult for Stripe to detect a duplicate card and replace/update the old one. They are just ignoring their customer's voice and closing issues without resolving the issue at their end. |
Below is a PHP example that detaches all duplicated cards from a customer. This should be called after a successful transaction. $stripe = new StripeClient('STRIPE_SECRET_KEY');
$cards = $stripe->paymentMethods->all(['customer' => 'CUSTOMER_ID', 'type' => 'card']);
$fingerprints = [];
foreach ($cards as $card) {
$fingerprint = $card['card']['fingerprint'];
if (in_array($fingerprint, $fingerprints, true)) {
$stripe->paymentMethods->detach($card['id']);
} else {
$fingerprints[] = $fingerprint;
}
} |
Hi, these solutions seem good for deduplicating cards returned by the PaymentMethod List API. |
@thorsten-stripe Why you closed issue? |
@thorsten-stripe I'd also prefer a simple solution to this like setting an option in the I really feel that something like this should be part of the API since every dev is running into this kind of issue sooner or later. |
I understand that stripe is a huge and complex ecosystem and that the developers want to be cautious to avoid introducing any unintended breaking changes but for the life of me I can't comprehend why anyone would ever want the same card attached to the same customer represented by multiple payment methods in the database. It's confusingly counterintuitive and places an unnecessary burden on thousands of developers to accidentally discover this odd behavior and then implement a fix for it. At a minimum the docs should include a warning about it. |
Same problem :( looks like this issue has been for a while... |
I've found a workaround.. you can follow these steps to avoid duplication of cards on stripe as well as on your database.
This approach will attach the duplicated cards to stripe customers but we're deleting them if we found them duplicated. |
|
Nothing to say here. Stripe WTF?! |
The funny thing on my side is that I'm using
And then I see the payment intent in the mobile app (iOS & Android) and whenever I pay I have the card duplicated. |
common stripe. seriously? |
Guys. After more digging they provided a video yesterday as well as some code. Here is the links. hope it will help you too. https://glitch.com/edit/#!/stripe-tinydemos-deduplicate-cards?path=server.js%3A122%3A32 |
Developers first. Before IPO. After it cost $90B and fuck fucking developers. |
I am integrate Stripe Google pay Button for recurring payment(subscription). in that case I got below error https://api.stripe.com/v1/payment_methods { https://api.stripe.com/v1/payment_intents/pi_3K7G0wI29lnP5KBa14QrQFOg/confirm //CONTROLLER REQUEST
) { |
When someone need's an example for the PHP API: $paymentMethods = $stripeClient
->customers
->allPaymentMethods($paymentIntent->customer->id, ['type' => 'card', 'limit' => 100]);
$fingerprints = [];
foreach ($paymentMethods as $method)
{
$fingerprints[$method->card->fingerprint . '-' . $method->card->last4] = $method->id;
}
foreach ($paymentMethods as $method)
{
if (!in_array($method->id, $fingerprints))
{
$stripeClient->paymentMethods->detach($method->id);
}
} Work's in testing mode as in live mode. 👍 |
Hey @thorsten-stripe, how have you been?
I'm playing around with the PaymentIntent API and I managed to attach a source to a customer. However, I noticed that if the user enters the same card he already saved, it will be attached twice as you can see here:
Example here:
You can see that the fingerprint are exactly the same (which is normal as it’s the same card). How can we prevent that?
Regards,
Yanis.
The text was updated successfully, but these errors were encountered: