@@ -324,6 +324,13 @@ class WC_Payments {
324324 */
325325 private static $ payment_method_service ;
326326
327+ /**
328+ * Instance of WC_Payments_Remediate_Canceled_Auth_Fees, created in init function
329+ *
330+ * @var WC_Payments_Remediate_Canceled_Auth_Fees
331+ */
332+ private static $ fee_remediation ;
333+
327334 /**
328335 * Entry point to the initialization logic.
329336 */
@@ -357,6 +364,7 @@ public static function init() {
357364 add_action ( 'admin_init ' , [ __CLASS__ , 'add_woo_admin_notes ' ] );
358365 add_action ( 'admin_init ' , [ __CLASS__ , 'remove_deprecated_notes ' ] );
359366 add_action ( 'init ' , [ __CLASS__ , 'install_actions ' ] );
367+ add_action ( 'upgrader_process_complete ' , [ __CLASS__ , 'on_plugin_update ' ], 10 , 2 );
360368
361369 add_action ( 'woocommerce_blocks_payment_method_type_registration ' , [ __CLASS__ , 'register_checkout_gateway ' ] );
362370
@@ -504,6 +512,7 @@ public static function init() {
504512 include_once __DIR__ . '/class-wc-payments-order-service.php ' ;
505513 include_once __DIR__ . '/class-wc-payments-order-success-page.php ' ;
506514 include_once __DIR__ . '/class-wc-payments-file-service.php ' ;
515+ include_once __DIR__ . '/migrations/class-wc-payments-remediate-canceled-auth-fees.php ' ;
507516 include_once __DIR__ . '/class-wc-payments-webhook-processing-service.php ' ;
508517 include_once __DIR__ . '/class-wc-payments-webhook-reliability-service.php ' ;
509518 include_once __DIR__ . '/fraud-prevention/class-fraud-prevention-service.php ' ;
@@ -564,6 +573,7 @@ public static function init() {
564573 self ::$ incentives_service = new WC_Payments_Incentives_Service ( self ::$ database_cache );
565574 self ::$ duplicate_payment_prevention_service = new Duplicate_Payment_Prevention_Service ();
566575 self ::$ duplicates_detection_service = new Duplicates_Detection_Service ();
576+ self ::$ fee_remediation = new WC_Payments_Remediate_Canceled_Auth_Fees ();
567577
568578 ( new WooPay_Scheduler ( self ::$ api_client ) )->init ();
569579
@@ -576,6 +586,7 @@ public static function init() {
576586 self ::$ compatibility_service ->init_hooks ();
577587 self ::$ customer_service ->init_hooks ();
578588 self ::$ token_service ->init_hooks ();
589+ self ::$ fee_remediation ->init ();
579590
580591 /**
581592 * FLAG: PAYMENT_METHODS_LIST
@@ -712,6 +723,7 @@ function () {
712723 require_once __DIR__ . '/migrations/class-erase-bnpl-announcement-meta.php ' ;
713724 require_once __DIR__ . '/migrations/class-erase-deprecated-flags-and-options.php ' ;
714725 require_once __DIR__ . '/migrations/class-manual-capture-payment-method-settings-update.php ' ;
726+ require_once __DIR__ . '/migrations/class-wc-payments-remediate-canceled-auth-fees.php ' ;
715727 add_action ( 'woocommerce_woocommerce_payments_updated ' , [ new Allowed_Payment_Request_Button_Types_Update ( self ::get_gateway () ), 'maybe_migrate ' ] );
716728 add_action ( 'woocommerce_woocommerce_payments_updated ' , [ new \WCPay \Migrations \Allowed_Payment_Request_Button_Sizes_Update ( self ::get_gateway () ), 'maybe_migrate ' ] );
717729 add_action ( 'woocommerce_woocommerce_payments_updated ' , [ new \WCPay \Migrations \Update_Service_Data_From_Server ( self ::get_account_service () ), 'maybe_migrate ' ] );
@@ -1528,6 +1540,34 @@ public static function update_plugin_version() {
15281540 update_option ( 'woocommerce_woocommerce_payments_version ' , WCPAY_VERSION_NUMBER );
15291541 }
15301542
1543+ /**
1544+ * Handle plugin updates.
1545+ *
1546+ * @param WP_Upgrader $upgrader WP_Upgrader instance.
1547+ * @param array $options Array of update data.
1548+ * @return void
1549+ */
1550+ public static function on_plugin_update ( $ upgrader , $ options ) {
1551+ if ( 'update ' !== $ options ['action ' ] || 'plugin ' !== $ options ['type ' ] ) {
1552+ return ;
1553+ }
1554+
1555+ // Check if WooPayments was updated.
1556+ $ plugins = isset ( $ options ['plugins ' ] ) ? $ options ['plugins ' ] : [];
1557+ if ( ! in_array ( plugin_basename ( WCPAY_PLUGIN_FILE ), $ plugins , true ) ) {
1558+ return ;
1559+ }
1560+
1561+ // Get new version.
1562+ $ plugin_data = get_plugin_data ( WCPAY_PLUGIN_FILE );
1563+ $ new_version = $ plugin_data ['Version ' ];
1564+
1565+ // Trigger version gate check.
1566+ if ( isset ( self ::$ fee_remediation ) ) {
1567+ self ::$ fee_remediation ->maybe_schedule_remediation ( $ new_version );
1568+ }
1569+ }
1570+
15311571 /**
15321572 * Sets the plugin activation timestamp.
15331573 *
0 commit comments