Delete stale _mollie_order_id meta on renewal order creation - #1253
Open
fjbender wants to merge 1 commit into
Open
Delete stale _mollie_order_id meta on renewal order creation#1253fjbender wants to merge 1 commit into
fjbender wants to merge 1 commit into
Conversation
Fixes #1250. delete_renewal_meta() already strips _mollie_payment_id and _mollie_cancelled_payment_id copied over from the parent order by WooCommerce Subscriptions, but left _mollie_order_id behind. Renewal orders never create a Mollie Order themselves (only MolliePayment is used for renewals), so any _mollie_order_id present is always stale data inherited from the parent order's initial Orders API payment. That stale value caused cancelExistingMolliePaymentIfPending() to check the parent's old, non-cancelable Orders API resource instead of the renewal's own Payments API transaction, silently blocking manual "Pay for order" retries for failed subscription renewals.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #1250 — a regression introduced in 8.1.8 silently blocks the "Pay for order" retry link for failed WooCommerce Subscriptions renewals whenever the subscription's initial payment went through the Orders API.
delete_renewal_meta()already strips_mollie_payment_idand_mollie_cancelled_payment_idthat WooCommerce Subscriptions copies from the parent order onto a new renewal order, but it never cleared_mollie_order_id. Renewal orders always pay viaMolliePayment(Payments API) and never create a Mollie Order themselves, so any_mollie_order_idpresent on a renewal order is always stale data inherited from the parent order.cancelExistingMolliePaymentIfPending()(added in 8.1.8) checks_mollie_order_idbefore_mollie_payment_id, so it was resolving that stale, non-cancelable parent Order resource instead of the renewal's own failed SEPA Direct Debit payment — leading to a silent['result' => 'failure']on manual retry.This is a one-line fix at the root cause: strip
_mollie_order_idalongside the other inherited meta at renewal-order creation time, so it's never present to be misread later.Test plan
_mollie_order_idmeta after creationinitialPaymentUsedOrderAPI()behavior is unaffected (it reads the meta off the parent order, not the renewal order)