Automattic / woocommerce-payments

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

Customers should be able to migrate from x gateway to WCPay subscriptions via a manual renewal #5102

Open james-allan opened 1 year ago

james-allan commented 1 year ago

Describe the bug

If a store switches from using WC Stripe + WC Subscriptions to WCPay Subscriptions subscription go to manual renewal mode. When the subscription eventually renews manually, the customer should be able to log into their account, pay for the renewal using WC Payments and that should transition them to WCPay Subscriptions.

This currently isn't the case.

To Reproduce

  1. Set up a store running with Stripe + WC Subscription extension
  2. Purchase a subscription using Stripe.
  3. Enable WC Payments.
  4. Deactivate Stripe and WC Subscriptions (when prompted accept that you will be transitioning to WCPay Subscriptions).
  5. Note that the Stripe subscription is now manual.
  6. Go to the edit subscription screen and manaulaly request a renewal from the actions dropdown (see screenshot below)
  7. From your My account page Pay for the manual renewal using WC Payments.
  8. ⚠️ WC Pay does NOT take over as the payment method for that subscription.

Screenshots

Screen Shot 2022-11-11 at 7 40 59 am

Actual behavior

There is a function that is set up purely for creating a WCPay subscription in this flow. WC_Payments_Subscription_Service::create_subscription_for_manual_renewal() [code ref].

However in this scenario it is falling over because it eventually calls WC_Payments_Subscription_Service::create_subscription() however that function bails early if the subscription doesn't have WC Payments as the payment method [code ref].

The PR that introduced that bail out (https://github.com/Automattic/woocommerce-payments/pull/3308/) added it to avoid creating WCPay Subscriptions for free subscriptions. We'll need to make sure that bug isn't reintroduced by fixing this issue.

Expected behavior

When you pay for a manual subscription and WC Subscriptions (extension) isn't active, we should be creating a subscription.

Critical flows

@aheckler suggested that this flow could be tested by GlobalStep regularly. Adding a note / reminder to this issue to look at this as part of shipping the fix.

haszari commented 1 year ago

Labelling as high priority as it's important for subscribers to be able to easily add payment and keep their subscription payment active. Based on @james-allan analysis this was introduced (a regression) so that also raises the priority.

aheckler commented 1 year ago

I did some testing by simply commenting out the return in WC_Payments_Subscription_Service::create_subscription() like so:

Screenshot taken on 2022-11-14 at 19 51 15 UTC@2x

This worked for the use case of migrating from Stripe + Subscriptions to just WC Pay. But notably, it did NOT work for the use case of migrating from Stripe + Subscriptions to WC Pay + Subscriptions.

Steps to reproduce:

  1. WC Pay + Stripe + Subscriptions all on a test site.
  2. Buy an example subscription product using Stripe as payment method.
  3. Disable Stripe as a payment gateway under WooCommerce > Settings > Payments tab > All Payment Methods.
  4. Under WooCommerce > Subscriptions, use pencil icon in billing section to set the subscription to manual renewal.
  5. Click Update to save that.
  6. Under WooCommerce > Status > Scheduled Actions, search for your subscription ID to find the woocommerce_scheduled_subscription_payment action for it.
  7. Hover over that and click Run. This simulates time passing and the sub coming due for manual renewal.
  8. Find the Pay Now link in whatever email inbox you used and open it up in browser,
  9. Pay using WC Pay form in checkout.
  10. After paying, check the sub under WooCommerce > Subscriptions. It's still on Manual Renewal.

EDIT: After discussing this on P2 with @james-allan, it turns out it's expected that WC Pay will NOT take over in the case of a Stripe + Subscriptions to WC Pay + Subscriptions migration. :( Bummer.

jbordonado commented 1 year ago

@haszari Will Helix work on this?

haszari commented 1 year ago

Will Helix work on this?

@jbordonado Yes - this is within our responsibilities, we'll consider it for upcoming sprints.

haszari commented 1 year ago

The PR that introduced that bail out (https://github.com/Automattic/woocommerce-payments/pull/3308) added it to avoid creating WCPay Subscriptions for free subscriptions. We'll need to make sure that bug isn't reintroduced by fixing this issue. Expected behavior When you pay for a manual subscription and WC Subscriptions (extension) isn't active, we should be creating a subscription.

A first step here would be to confirm that this was introduced in WCPay 5.0 – retest in WCPay 4.9 and confirm no bug.

jbordonado commented 1 year ago

Will Helix work on this?

@jbordonado Yes - this is within our responsibilities, we'll consider it for upcoming sprints.

Thank you, I suspected but wasn't sure.