woocommerce / woocommerce-gateway-stripe

The official Stripe Payment Gateway for WooCommerce
https://wordpress.org/plugins/woocommerce-gateway-stripe/
231 stars 202 forks source link

Card ID Source reverting to old ID after Stripe update with WooCommerce Subscriptions #476

Closed poolet08 closed 6 years ago

poolet08 commented 6 years ago

Affected ticket(s)

What I expected

What happened instead

We recently updated to the latest version of Stripe with WooCommerce & Subscriptions and we noticed an uptick in failing subscriptions. I took a look further and it appears that for whatever reason some customers card ID source linked to their subscription reverted back to an old card ID Source thus causing their subscription to fail upon renewal even though they have an active card on file and renewed successfully in December.

Steps to reproduce the issue


poolet08 commented 6 years ago

Ah okay got it. I will do that. Thanks for your assistance.

poolet08 commented 6 years ago

Also,

I am not sure what fixed that white page issue we had with the Payment Methods page, but that was fixed in this latest update also.

poolet08 commented 6 years ago

Roy,

I am going some of these subscriptions and I am pretty sure that this has happened to some Subscription that I did not touch. I have one here where I can see in the log where the customer put in a new card.

On 12/21/17 he deleted and put in a new card. There was then a 404 error and then a successful charge right after. Then 404 errors on the next renewal on 01/22/18. I never touched that subscription.

poolet08 commented 6 years ago

It looks like anytime there is a 404 error associated with a card, it resets the source card ID back to the original/old source Card. This regardless of whether or not I removed the source ID or not.

roykho commented 6 years ago

404 means The requested resource doesn't exist. Much has changed since 4.0 so I would urge you to use it for awhile and monitor it.

roykho commented 6 years ago

This may lead back to the issue you mentioned earlier where customers are changing cards via the add payment method page instead of the subscription.

poolet08 commented 6 years ago

Yes it sounds like it. It appears that customers are removing the card via Payment Methods and adding a new one. Yet they do not link it to their Subscription.

I believe WC Subscriptions made it where it will automatically pick up the default one because I mentioned this to them a year ago. So I believe they made a fix where it will go and automatically charge the default card on file if the card was removed from Stripe.

Now since 4.0 it appears for any customer where this has happened, it is putting in an old source card ID thus causing the payment to fail.

poolet08 commented 6 years ago

That is why the 404 error appears and then a successful charge right after.

poolet08 commented 6 years ago

See attached. stripe3 stripe4

roykho commented 6 years ago

No it does not pick the default one in Stripe. It picks the next one available in the WC account.

poolet08 commented 6 years ago

Okay got it. Well that seems to be where the issue lays. Is this normal operation you think?

roykho commented 6 years ago

If it so happens the next one available is the default one, then everything will work but this is not always the case. I tested this earlier when I had 3+ cards in the account and I tried removing one that was linked to a subscription. Subscription then gave me a notice that it picked another card to use so that payment does not cease. But that next one that it choice is not my default card.

poolet08 commented 6 years ago

Well almost every one of these has a 404 error associated with them which should probably not be. The card linked to the subscription should never give a 404 error as there should always be a card linked to it. Thus 404 would never appear right?

roykho commented 6 years ago

Well that seems to be where the issue lays. Is this normal operation you think?

If you ask me, I would like it if anytime a customer goes to change/delete a card that is linked to a subscription, the subscription plugin should redirect them to the change payment method page for the subscription in question as I mentioned earlier and would be the ideal solution.

poolet08 commented 6 years ago

Yes that seems like a good operation.

roykho commented 6 years ago

The solution to the issues you're mentioning is "intervention". When in fact this should be "prevention". The question is how can we prevent this happening in the first place.

poolet08 commented 6 years ago

Okay well right now my concern is how long this will go on that I have to manually fix these subscriptions. I am finding one right after the other and I have fixed probably 15 or so just now. (We updated Sat. Night)

Can you confirm if there is an issue going on that can possibly be resolved?

poolet08 commented 6 years ago

Roy,

Please see order 583683 ... This customer has never even had a failed payment or even changed his card until 1/12/18. He changed his card on 01/12/18 and then his monthly payment went to charge on 1/23/18 (today) but it failed because Stripe has the old card source ID listed in the Subscription and not his new one. It is a 404 error.

Before the 4.0 update the system would have automatically updated this and began charging the next default payment source on file. Now its not doing this.

Thanks

poolet08 commented 6 years ago

I can confirm on one customer that the system tried to charge a source back from June of 2017 that was deleted. So the problem seems to stem from customers who have changed their payment method at one point.

roykho commented 6 years ago

Am currently researching if there is any solution to your issue.

poolet08 commented 6 years ago

Thanks Roy!

poolet08 commented 6 years ago

Hi Roy,

Any updates by any chance?

roykho commented 6 years ago

Sorry not yet, but meanwhile perhaps you can switch back to 3.2.3 and that will work?

roykho commented 6 years ago

Second thought may not be a good idea because then the ones that already got processed correctly after 4.0 may have trouble in the next round of renewals.

poolet08 commented 6 years ago

Okay. Yeah its just doing it on ones that have had a 404 error in the past. Not sure what caused that. I suppose I can keep updating them as they fail and hopefully whittle down on the issues but I am just worried about missing subscriptions.

roykho commented 6 years ago

Can you please link a screen capture of the customer of this order 583683. I want to see the list of sources on this customer ( Stripe Dashboard ). Please block any sensitive information of course.

poolet08 commented 6 years ago

Hi Roy,

I have linked it but this particular customers payment is failing anyway. stripe6

poolet08 commented 6 years ago

Anything new today Roy?

roykho commented 6 years ago

Nothing yet as I am still unable to replicate this issue. Can you check one thing. Get the source or card id from the one card that shows in Stripe and do a search in your database to see if that comes up?

poolet08 commented 6 years ago

So you are not able to replicate old card source ID's being charged instead of the latest one?

poolet08 commented 6 years ago

I am looking at Order 584529 ... It was set to renew today but it failed because it tried to charge an old card source. I had to go in and manually update it to the card source that was on file. However, last month it charged the correct source that was on file. For some reason in some cases its trying to charge old card source id's that are no longer linked with the Subscription.

roykho commented 6 years ago

Is this "old" card still there in Stripe though?

poolet08 commented 6 years ago

No it is not.

roykho commented 6 years ago

And to summarize if the source id field is empty, it will try to charge the original source, does that sum it up?

poolet08 commented 6 years ago

That is how it used to operate yes. If I cleared the card source ID out, it would always charge the default card on file. However, this issue is further than that as its doing this to some subscriptions that I have not touched.

Another new one just came in and if you want to pop in and see ... 584602

roykho commented 6 years ago

Right you said in the past that this happens to either when the card field is empty OR if the customer has had 404 errors in the past?

poolet08 commented 6 years ago

Yes. In this particular case he removed the card on 1/22/18 which was linked to the subscription. He put in a new card on 9/21/17 and changed the default payment source.

This issue may relate back to just the subscription not being updated with the default payment source which is probably not what the current issue is.

poolet08 commented 6 years ago

However, prior to 4.0 ... The system would have thrown a 404 error and then Stripe or Subscriptions would have picked up the default card on file and charged it.

roykho commented 6 years ago

Let me see if I can whip up a temp solution for you to "try" and charge whatever is the default card on Stripe for the customer. Would that work?

poolet08 commented 6 years ago

Well I don't want you to go too far out of your way on this. The vast majority are charging out. Its probably just a few subscriptions a day at this point. 5 or so.

Its just interesting as to what is causing it. I wouldn't mind screensharing with you so we can look at a subscription or two so you have a good idea of what is going on if possible?

roykho commented 6 years ago

Ok please download from this branch here https://github.com/woocommerce/woocommerce-gateway-stripe/tree/test-subs

Let me know if that works for you.

poolet08 commented 6 years ago

Okay great. I will get back to you shortly.

jrick1229 commented 6 years ago

Just an update from the Subscriptions team, we are seeing this error come in on many tickets:

Stripe Transaction Failed (Customer cus_************** does not have a linked source with ID card_*****************.) Order status changed from Pending payment to Failed.

We were going to open an issue, but noticed that this is probably the same exact problem. We haven't been successful in replicating, but are wondering what the issue could be. Some seem to be related to customers who have tried to change their cards after failed charges, but not all.

roykho commented 6 years ago

This issue is probably because for whatever reason the stored card is either missing or customer had changed the payment method via the "add payment method" screen of WC ( not the subs one ).

Prior to 4.0, it would go and look for a default card to charge from the customer. This feature was later than removed in 4.0 because we felt that this "may" encounter some legal issues because the customer in question may or may not want you to charge any other card other than the one they had originally signed up with.

So what would be better is a way for Subscription to check if they're on the WC add payment page, to know which card/source is tied to the subscription and if they want to edit/change that, it would link them to the "change payment method" of the Subscription. That way a supposedly valid card will always be linked.

poolet08 commented 6 years ago

Good to see this. T= ]0i

poolet08 commented 6 years ago

Thanks!

roykho commented 6 years ago

@poolet08 did you try the branch I mentioned? Did it work for you? Or did you not have any renewals yet?

poolet08 commented 6 years ago

We have not Roy. The guy who handles our WordPress stuff isn't in yet.

poolet08 commented 6 years ago

Hi Roy,

We haven't updated just yet but I wanted to confirm this is pretty stable and shouldn't have any issues? I am always nervous about running something on the production site.

roykho commented 6 years ago

Well so far we haven't yet gotten anyone else with this issue and none of us can replicate this on our end other than it is expected to fail in 4.0 if no card is linked or missing. So this is a temp solution for you to see if it works..Essentially it brought back the idea of trying to charge a default card linked in Stripe if none is found.