-
Notifications
You must be signed in to change notification settings - Fork 69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hotfix Ensure Subscription Initialization is only run once #5644
Closed
Conversation
This file contains 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
Size Change: 0 B Total Size: 1.37 MB ℹ️ View Unchanged
|
Closing this branch in favor of #5625 |
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.
Fixes #5615
Changes proposed in this Pull Request
This PR addresses the issue that was discovered in #5615. In short, the issue was that subscription renewals were running multiple charges for each renewal. It was discovered that it was running transactions for as many UPE payment methods that were available + 1. We discovered this was due to the fact that the
woocommerce_scheduled_subscription_payment_woocommerce_payments
action was being added for every payment method class. This was happening since each class was ultimately inheriting fromWC_Payment_Gateway_WCPay
which callsmaybe_init_subscriptions
in it's constructor and each class was calling it's parent contructor within it's own constructor.To address this issue we took two steps, one to explicity avoid this renewal duplicate charge issue and one to avoid any other oddities that might have been waiting in hiding due to the multiple calls to
maybe_init_subscriptions
.woocommerce_scheduled_subscription_payment_woocommerce_payments
before adding it. In this way we ensure that the action is only ever added once (and thus only ever called once).maybe_init_subscriptions
from theWC_Payment_Gateway_WCPay
constructor and instead calling it explicitly once all the of the enabled / relevant gateways have been instantiated.Testing instructions
The following test should all be performed under each of these four scenarios:
After confirmation of the above, run an additional test with a subscription and SEPA.
Note: While the scenarios above will cover the primary expected areas of impact, it wouldn't hurt to confirm some processes with WooPay enabled and disabled in non-UPE and legacy UPE as well.
npm run changelog
to add a changelog file, choosepatch
to leave it empty if the change is not significant. You can add multiple changelog files in one PR by running this command a few times.Post merge