Closed james-allan closed 3 months ago
Another option would be to handle this in $subscription->payment_failed() and use the last_order to add the meta.
Oh right. That's an interesting idea. So set the meta when the subscription originally failed, not when it goes to pending. 🤔 That makes more sense to set that meta then and makes clean up a lot cleaner too.
@mattallan I've changed this PR to now use the approach you recommended of using $subscription->payment_failed()
and $subscription->payment_complete_for_order()
to set and delete the meta.
Do you mind giving this another look? :)
Fixes https://github.com/woocommerce/woocommerce-subscriptions/issues/4638
Description
When you successfully pay for a failed renewal order, we trigger the
woocommerce_subscriptions_paid_for_failed_renewal_order
hook. This is used by gateways to update the token on the subscription, to use the new token.However, when you pay for an order via the block checkout, WooCommerce Core updates the status to pending (code ref). This brakes our logic which expects the status transition to be failed → processing/completed.
This PR attempts to fix this by making sure we flag when a failed renewal order is paid via block checkout and is updated to pending. Then when the order status transition is pending → processing/completed we can confirm that as scenario where the customer has paid for a failed renewal order.
How to test this PR
trunk
Note that thewoocommerce_subscriptions_paid_for_failed_renewal_order
hook isn't fired because the order is pending, not failed.Product impact