Automattic / woocommerce-payments

Accept payments via credit card. Manage transactions within WordPress.
https://wordpress.org/plugins/woocommerce-payments/
Other
174 stars 69 forks source link

Renewal attempt for a canceled Subscription in Test mode after switching to Live mode #3687

Open AashikP opened 2 years ago

AashikP commented 2 years ago

Describe the bug

It seems what happens is when there is a Sub created under WC Pay's Test mode and canceled after it is flipped to Live, the wcpay_track_new_order action continues to fire off, even if the action fails.

To Reproduce

  1. Purchase a Subscription in test mode
  2. Notice the Scheduled Actions: https://d.pr/i/EQ77uL+
  3. Cancel the Subscription while on test mode.
  4. Notice that the Subscription is set to Pending Cancellation, but wcpay_track_new_order is still present
  5. Switch to Live mode
  6. When it is time for renewal, the default subscription end scheduled action runs, along with wcpay_track_new_order which fails:

    https://d.pr/i/pkjQvA+

  7. This generates new orders which should not be generated, and prevents canceling the Subscription itself since it generates this error:

    https://d.pr/i/PWDMxb+

  8. Also note that the renewal orders keep coming in, even though they fail with this error: action failed via WP Cron: Error: Unable to fetch payment method details from the provided payment_method_id.

    https://d.pr/i/u4AV7W+

Expected behavior

Either ensure no renewal orders are created post-cancellation or make it clear to the customer in the docs about what will happen to the subscriptions that are not completely canceled / that are in pending cancellation state.

Desktop (please complete the following information):

Any

Smartphone (please complete the following information):

Any

Additional context

Slack discussion : p1642095259178500-slack-C7U3Y3VMY

Customer Reports : 4669003-zen

AashikP commented 2 years ago

May be related: https://github.com/Automattic/woocommerce-payments/issues/3269

mepoland commented 2 years ago

I am a store owner experiencing this issue and want to point out one side effect of this bug. I have recurring "test" orders happening every day and every week which I cannot cancel. Even though these orders are not charging anyone money (4242 credit card), they make accounting very difficult as they have to be manually filtered out from real transactions. I paid for WC's Xero accounting sync plugin which was creating invoices for all these test transactions in my accounting software, and had to manually remove them there as well (fun fact, there is no way to bulk delete invoices in Xero). So this is not just an annoyance that can be ignored.

zmaglica commented 2 years ago

Hey @AashikP Based on your suggestion and linked issue, the most convenient way (by my opinion) is to update docs and propose solution mentioned in linked issue. What do you think about that?

AashikP commented 2 years ago

Based on your suggestion and linked issue, the most convenient way (by my opinion) is to update docs and propose solution mentioned in linked issue. What do you think about that?

Sounds like a plan! Reaching out internally regarding those updates to the document.

htdat commented 2 years ago

Hello @AashikP, I am doing triage for this issue.

Reaching out internally regarding those updates to the document.

Would you mind leaving the internal link(s) here? And is there anything that WCPay developers can help?

AashikP commented 2 years ago

Hello @htdat, thank you for the ping. It looks like this was not picked up post the ping here: p1644381451810639-slack-CGGCLBN58

htdat commented 2 years ago

post the ping here: p1644381451810639-slack-CGGCLBN58

Based on this convo, I continue working on this issue.

@Automattic/helix - can you have a look at this issue? Do you think that we can catch up this error, and handle them gracefully OR give a better error message?

Eventually, we may still want to add a document or a new section in an existing document to explain about this. That would reduce support requests to our HEs.

haszari commented 2 years ago

Thanks for the heads up @htdat – will take a look and see what we can do about this. Hopefully we can document a workaround / fix for this issue and maybe #1453 and #3269 as well.