Skip to content
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
wants to merge 1 commit into from

Conversation

bborman22
Copy link
Contributor

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 from WC_Payment_Gateway_WCPay which calls maybe_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.

  • Addressing the renewal duplicate charge issue explicitly involved checking for the existence of the 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).
  • Avoiding any further oddites involved removing the maybe_init_subscriptions from the WC_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:

  • No UPE at all.
  • Legacy UPE.
  • Split UPE without WooPay.
  • Split UPE with WooPay.
  1. Configure store for the current scenario you are testing above.
  2. If not already present, install the WC Subscriptions plugin and add a subscription product.
  3. Go to checkout a subscription product using a CC.
  4. Confirm subscription checkout was successful and a subscription was created.
  5. Now as merchant admin, go into the subscription that was created and under the subscription actions, choose "Process Renewal" and hit Update.
  6. Confirm that the renewal order was created and paid under the subscription order page under "Related Orders".
  7. Log into the Stripe dashboard and view the test merchant account's payments and confirm that there is only one charge for the renewal.

After confirmation of the above, run an additional test with a subscription and SEPA.

  1. Enable SEPA on your merchant account from the Stripe dashboard.
  2. Restart your local WCPay server memcache instance to clear cached account data.
  3. Refresh account data on merchant store with the dev tools.
  4. Under Payment settings, make sure SEPA is enabled.
  5. Checkout with a subscription product and repeat steps 5, 6, and 7 from above.

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.


  • Run npm run changelog to add a changelog file, choose patch 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.
  • Covered with tests (or have a good reason not to test in description ☝️)
  • Tested on mobile (or does not apply)

Post merge

@bborman22 bborman22 marked this pull request as ready for review February 28, 2023 14:11
@github-actions
Copy link
Contributor

Size Change: 0 B

Total Size: 1.37 MB

ℹ️ View Unchanged
Filename Size
release/woocommerce-payments/assets/css/admin.css 913 B
release/woocommerce-payments/assets/css/success.css 401 B
release/woocommerce-payments/dist/blocks-checkout.css 2.33 kB
release/woocommerce-payments/dist/blocks-checkout.js 39.5 kB
release/woocommerce-payments/dist/checkout.css 1.34 kB
release/woocommerce-payments/dist/checkout.js 28.1 kB
release/woocommerce-payments/dist/index.css 36.1 kB
release/woocommerce-payments/dist/index.js 384 kB
release/woocommerce-payments/dist/multi-currency-analytics.js 1.05 kB
release/woocommerce-payments/dist/multi-currency-switcher-block.js 56.3 kB
release/woocommerce-payments/dist/multi-currency.css 14.8 kB
release/woocommerce-payments/dist/multi-currency.js 72.7 kB
release/woocommerce-payments/dist/order.css 248 B
release/woocommerce-payments/dist/order.js 12.7 kB
release/woocommerce-payments/dist/payment-gateways.css 1.2 kB
release/woocommerce-payments/dist/payment-gateways.js 47.2 kB
release/woocommerce-payments/dist/payment-request.js 12 kB
release/woocommerce-payments/dist/platform-checkout-express-button.js 16 kB
release/woocommerce-payments/dist/platform-checkout.css 4.02 kB
release/woocommerce-payments/dist/platform-checkout.js 75.4 kB
release/woocommerce-payments/dist/settings.css 51.3 kB
release/woocommerce-payments/dist/settings.js 181 kB
release/woocommerce-payments/dist/subscription-edit-page.js 668 B
release/woocommerce-payments/dist/subscription-product-onboarding-modal.css 7.18 kB
release/woocommerce-payments/dist/subscription-product-onboarding-modal.js 12.8 kB
release/woocommerce-payments/dist/subscription-product-onboarding-toast.js 703 B
release/woocommerce-payments/dist/subscriptions-empty-state.css 298 B
release/woocommerce-payments/dist/subscriptions-empty-state.js 44.3 kB
release/woocommerce-payments/dist/tos.css 236 B
release/woocommerce-payments/dist/tos.js 15.7 kB
release/woocommerce-payments/dist/upe_checkout.css 1.34 kB
release/woocommerce-payments/dist/upe_checkout.js 32.9 kB
release/woocommerce-payments/dist/upe_split_checkout.css 1.34 kB
release/woocommerce-payments/dist/upe_split_checkout.js 33.2 kB
release/woocommerce-payments/dist/upe-blocks-checkout.css 2.33 kB
release/woocommerce-payments/dist/upe-blocks-checkout.js 39 kB
release/woocommerce-payments/dist/upe-split-blocks-checkout.css 2.34 kB
release/woocommerce-payments/dist/upe-split-blocks-checkout.js 39.7 kB
release/woocommerce-payments/includes/subscriptions/assets/css/plugin-page.css 633 B
release/woocommerce-payments/includes/subscriptions/assets/js/plugin-page.js 720 B
release/woocommerce-payments/vendor/automattic/jetpack-admin-ui/src/css/jetpack-icon.css 224 B
release/woocommerce-payments/vendor/automattic/jetpack-assets/build/i18n-loader.js 2.43 kB
release/woocommerce-payments/vendor/automattic/jetpack-assets/src/js/i18n-loader.js 1.01 kB
release/woocommerce-payments/vendor/automattic/jetpack-identity-crisis/babel.config.js 160 B
release/woocommerce-payments/vendor/automattic/jetpack-identity-crisis/build/index.css 2.27 kB
release/woocommerce-payments/vendor/automattic/jetpack-identity-crisis/build/index.js 13.3 kB
release/woocommerce-payments/vendor/automattic/jetpack-identity-crisis/build/index.rtl.css 2.27 kB
release/woocommerce-payments/vendor/automattic/jetpack-tracking/src/js/tracks-ajax.js 789 B
release/woocommerce-payments/vendor/automattic/jetpack-tracking/src/js/tracks-callables.js 925 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/css/about.css 1.2 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/css/admin-order-statuses.css 403 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/css/admin.css 3.56 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/css/checkout.css 299 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/css/modal.css 742 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/css/view-subscription.css 572 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/css/wcs-upgrade.css 411 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/admin-pointers.js 544 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/admin.js 9.07 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/jstz.js 6.8 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/jstz.min.js 3.83 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/meta-boxes-coupon.js 544 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/meta-boxes-subscription.js 2.38 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/moment.js 22.1 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/moment.min.js 11.6 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/payment-method-restrictions.js 1.29 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/wcs-meta-boxes-order.js 502 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/frontend/payment-methods.js 355 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/frontend/single-product.js 429 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/frontend/view-subscription.js 1.38 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/frontend/wcs-cart.js 387 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/modal.js 1.1 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/wcs-upgrade.js 1.27 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/build/index.css 392 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/build/index.js 3.06 kB

compressed-size-action

@bborman22
Copy link
Contributor Author

Closing this branch in favor of #5625

@bborman22 bborman22 closed this Feb 28, 2023
@bborman22 bborman22 deleted the hotfix/upe-renewals-multi-charge branch March 1, 2023 15:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant