Automattic / woocommerce-payments

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

Paying for pending renewal after free trial doesn't save WooCommerce Payments as the payment method & stays as manual renewal #8815

Open mattallan opened 1 month ago

mattallan commented 1 month ago

Describe the bug

In WooCommerce Subscriptions there's a setting that allows customers to purchase $0 subscription products (i.e. subscriptions that have a trial period) without entering a payment method on the checkout: image

After the free trial ends, when the customer pays for the first renewal order with WooPayments, the new payment method is not set or the payment tokens on the subscription, resulting in the subscription remaining as requiring manual renewal, instead of automatically renewing with WooPayments.

In the Stripe extension we add support for this by adding the payment method meta to the subscription and making sure the payment method is set. See the code in maybe_update_source_on_subscription_order() function.

Here's a screen recording of the issue:

https://github.com/Automattic/woocommerce-payments/assets/2275145/70539fe5-b7b3-4326-b92e-42a26a7d257e

To Reproduce

  1. Enable the $0 checkout setting in WooCommerce > Settings >Subscriptions
  2. Create a subscription product with a 7-day free trial
  3. Purchase the subscription with no payment method.
  4. You will see the trial and next payment date. The subscription will be in "manual payment" mode which is expected.
  5. Manually trigger the subscription renewal using the "Process renewal" subscription action: image
  6. Now pay for the new pending renewal order from My Account page and complete the payment with Woo Payments.
  7. Check the subscription on the My Account page and notice that it's still saying it is manual renewal.
  8. Process another renewal and notice it's not renewing automatically.

Expected behavior

It's expected that after paying for the pending renewal with WooPayments, the next renewal will automatically process with our gateway.

haszari commented 1 month ago

Thanks @mattallan 👍🏻 Clarifying that the bug here is that subscriptions with $0 first payment / deferred first payment don't work reliably (because auto-renew is not set up).