From 359162f8ef0d786f92eab98a688ca42408d14e7e Mon Sep 17 00:00:00 2001 From: Mayisha <33387139+Mayisha@users.noreply.github.com> Date: Thu, 9 Jan 2025 00:52:06 +0600 Subject: [PATCH 1/2] Migrate PRB settings data to ECE (#3688) * create class for migrating prb to ece * include and initiate class * use express checkout option name * add changelog --- changelog.txt | 1 + ...-request-data-to-express-checkout-data.php | 63 ++++++++++++++++++ ...lass-wc-stripe-express-checkout-helper.php | 16 ++--- readme.txt | 1 + ...-request-data-to-express-checkout-data.php | 64 +++++++++++++++++++ woocommerce-gateway-stripe.php | 2 + 6 files changed, 139 insertions(+), 8 deletions(-) create mode 100644 includes/migrations/class-migrate-payment-request-data-to-express-checkout-data.php create mode 100644 tests/phpunit/admin/migrations/test-class-migrate-payment-request-data-to-express-checkout-data.php diff --git a/changelog.txt b/changelog.txt index b600c762f..cf49c8940 100644 --- a/changelog.txt +++ b/changelog.txt @@ -32,6 +32,7 @@ * Dev - Add a GitHub Action workflow to run QIT E2E Integrations tests. * Fix - Check billing interval and period to set in mandate options. * Fix - Check order currency on pay for order page to display supported payment methods. +* Update - Migrate payment request settings data to express checkout settings data. * Update - Make the new Stripe Express Checkout Element enabled by default in all accounts. = 9.0.0 - 2024-12-12 = diff --git a/includes/migrations/class-migrate-payment-request-data-to-express-checkout-data.php b/includes/migrations/class-migrate-payment-request-data-to-express-checkout-data.php new file mode 100644 index 000000000..9592f69ae --- /dev/null +++ b/includes/migrations/class-migrate-payment-request-data-to-express-checkout-data.php @@ -0,0 +1,63 @@ +get_gateway(); + + $express_checkout_enabled = $stripe_gateway->get_option( 'express_checkout' ); + + if ( empty( $express_checkout_enabled ) ) { + $this->migrate(); + } + } + + /** + * Copies over Payment Request settings data to Express Checkout settings data. + */ + private function migrate() { + $stripe_gateway = $this->get_gateway(); + + $payment_request_enabled = $stripe_gateway->get_option( 'payment_request', 'no' ); + $payment_request_button_type = $stripe_gateway->get_option( 'payment_request_button_type', 'default' ); + $payment_request_button_theme = $stripe_gateway->get_option( 'payment_request_button_theme', 'dark' ); + $payment_request_button_size = $stripe_gateway->get_option( 'payment_request_button_size', 'default' ); + $payment_request_button_locations = $stripe_gateway->get_option( 'payment_request_button_locations', [ 'checkout' ] ); + + $stripe_gateway->update_option( 'express_checkout', $payment_request_enabled ); + $stripe_gateway->update_option( 'express_checkout_button_type', $payment_request_button_type ); + $stripe_gateway->update_option( 'express_checkout_button_theme', $payment_request_button_theme ); + $stripe_gateway->update_option( 'express_checkout_button_size', $payment_request_button_size ); + $stripe_gateway->update_option( 'express_checkout_button_locations', $payment_request_button_locations ); + } + + /** + * Returns the main Stripe payment gateways. + * + * @return WC_Stripe_Payment_Gateway + */ + public function get_gateway() { + return woocommerce_gateway_stripe()->get_main_stripe_gateway(); + } +} diff --git a/includes/payment-methods/class-wc-stripe-express-checkout-helper.php b/includes/payment-methods/class-wc-stripe-express-checkout-helper.php index fe8aa1272..ac5705e50 100644 --- a/includes/payment-methods/class-wc-stripe-express-checkout-helper.php +++ b/includes/payment-methods/class-wc-stripe-express-checkout-helper.php @@ -85,7 +85,7 @@ public function is_account_creation_possible() { * @return string */ public function get_button_type() { - return isset( $this->stripe_settings['payment_request_button_type'] ) ? $this->stripe_settings['payment_request_button_type'] : 'default'; + return isset( $this->stripe_settings['express_checkout_button_type'] ) ? $this->stripe_settings['express_checkout_button_type'] : 'default'; } /** @@ -94,7 +94,7 @@ public function get_button_type() { * @return string */ public function get_button_theme() { - return isset( $this->stripe_settings['payment_request_button_theme'] ) ? $this->stripe_settings['payment_request_button_theme'] : 'dark'; + return isset( $this->stripe_settings['express_checkout_button_theme'] ) ? $this->stripe_settings['express_checkout_button_theme'] : 'dark'; } /** @@ -103,7 +103,7 @@ public function get_button_theme() { * @return string */ public function get_button_height() { - $height = isset( $this->stripe_settings['payment_request_button_size'] ) ? $this->stripe_settings['payment_request_button_size'] : 'default'; + $height = isset( $this->stripe_settings['express_checkout_button_size'] ) ? $this->stripe_settings['express_checkout_button_size'] : 'default'; if ( 'small' === $height ) { return '40'; } @@ -121,7 +121,7 @@ public function get_button_height() { * @return string */ public function get_button_radius() { - $height = isset( $this->stripe_settings['payment_request_button_size'] ) ? $this->stripe_settings['payment_request_button_size'] : 'default'; + $height = isset( $this->stripe_settings['express_checkout_button_size'] ) ? $this->stripe_settings['express_checkout_button_size'] : 'default'; if ( 'small' === $height ) { return '2'; } @@ -1329,18 +1329,18 @@ public function get_login_confirmation_settings() { */ public function get_button_locations() { // If the locations have not been set return the default setting. - if ( ! isset( $this->stripe_settings['payment_request_button_locations'] ) ) { + if ( ! isset( $this->stripe_settings['express_checkout_button_locations'] ) ) { return [ 'product', 'cart' ]; } // If all locations are removed through the settings UI the location config will be set to // an empty string "". If that's the case (and if the settings are not an array for any // other reason) we should return an empty array. - if ( ! is_array( $this->stripe_settings['payment_request_button_locations'] ) ) { + if ( ! is_array( $this->stripe_settings['express_checkout_button_locations'] ) ) { return []; } - return $this->stripe_settings['payment_request_button_locations']; + return $this->stripe_settings['express_checkout_button_locations']; } /** @@ -1351,7 +1351,7 @@ public function get_button_locations() { * @return boolean */ public function is_express_checkout_enabled() { - return isset( $this->stripe_settings['payment_request'] ) && 'yes' === $this->stripe_settings['payment_request']; + return isset( $this->stripe_settings['express_checkout'] ) && 'yes' === $this->stripe_settings['express_checkout']; } /** diff --git a/readme.txt b/readme.txt index 07a6499d2..f7a2330b0 100644 --- a/readme.txt +++ b/readme.txt @@ -142,6 +142,7 @@ If you get stuck, you can ask for help in the [Plugin Forum](https://wordpress.o * Dev - Add a GitHub Action workflow to run QIT E2E Integrations tests. * Fix - Check billing interval and period to set in mandate options. * Fix - Check order currency on pay for order page to display supported payment methods. +* Update - Migrate payment request settings data to express checkout settings data. * Update - Make the new Stripe Express Checkout Element enabled by default in all accounts. [See changelog for all versions](https://raw.githubusercontent.com/woocommerce/woocommerce-gateway-stripe/trunk/changelog.txt). diff --git a/tests/phpunit/admin/migrations/test-class-migrate-payment-request-data-to-express-checkout-data.php b/tests/phpunit/admin/migrations/test-class-migrate-payment-request-data-to-express-checkout-data.php new file mode 100644 index 000000000..13e1c832b --- /dev/null +++ b/tests/phpunit/admin/migrations/test-class-migrate-payment-request-data-to-express-checkout-data.php @@ -0,0 +1,64 @@ +gateway_mock = $this->getMockBuilder( WC_Gateway_Stripe::class ) + ->disableOriginalConstructor() + ->getMock(); + $this->migration = $this->getMockBuilder( Migrate_Payment_Request_Data_To_Express_Checkout_Data::class ) + ->disableOriginalConstructor() + ->setMethods( [ 'get_gateway' ] ) + ->getMock(); + } + + public function test_migration_not_executed_when_data_already_migrated() { + $this->setup_environment( [ 'express_checkout' => 'yes' ] ); + + $this->gateway_mock->expects( $this->never() ) + ->method( 'update_option' ); + + $this->migration->maybe_migrate(); + } + + public function test_prb_settings_data_migration_to_ece_settings_data() { + $this->setup_environment( [] ); + + $this->gateway_mock->expects( $this->exactly( 5 ) ) + ->method( 'update_option' ); + + $this->migration->maybe_migrate(); + } + + private function setup_environment( $settings ) { + $this->gateway_mock->method( 'get_option' ) + ->willReturnCallback( + function ( $key ) use ( $settings ) { + return isset( $settings[ $key ] ) ? $settings[ $key ] : ''; + } + ); + $this->migration->method( 'get_gateway' )->willReturn( $this->gateway_mock ); + } +} diff --git a/woocommerce-gateway-stripe.php b/woocommerce-gateway-stripe.php index 786af27cd..1fd543e2d 100644 --- a/woocommerce-gateway-stripe.php +++ b/woocommerce-gateway-stripe.php @@ -264,8 +264,10 @@ public function init() { require_once dirname( __FILE__ ) . '/includes/admin/class-wc-stripe-inbox-notes.php'; require_once dirname( __FILE__ ) . '/includes/admin/class-wc-stripe-upe-compatibility-controller.php'; require_once dirname( __FILE__ ) . '/includes/migrations/class-allowed-payment-request-button-types-update.php'; + require_once dirname( __FILE__ ) . '/includes/migrations/class-migrate-payment-request-data-to-express-checkout-data.php'; require_once dirname( __FILE__ ) . '/includes/class-wc-stripe-account.php'; new Allowed_Payment_Request_Button_Types_Update(); + new Migrate_Payment_Request_Data_To_Express_Checkout_Data(); $this->api = new WC_Stripe_Connect_API(); $this->connect = new WC_Stripe_Connect( $this->api ); From 7bd882442f60d488f4763052f62ce00bebdf0070 Mon Sep 17 00:00:00 2001 From: Nathan Bloomfield Date: Wed, 8 Jan 2025 22:01:58 -0600 Subject: [PATCH 2/2] Lint fixes (#3673) * Lint fixes --------- Co-authored-by: nbloomf Co-authored-by: Anne Mirasol --- changelog.txt | 1 + .../abstract-wc-stripe-payment-gateway.php | 2 +- ...ass-wc-rest-stripe-settings-controller.php | 1 - includes/admin/stripe-eps-settings.php | 4 +- includes/admin/stripe-p24-settings.php | 4 +- includes/admin/stripe-sepa-settings.php | 4 +- .../class-wc-stripe-intent-controller.php | 2 +- includes/class-wc-stripe-webhook-handler.php | 1 - ...subscriptions-legacy-sepa-token-update.php | 7 + .../class-wc-stripe-payment-tokens.php | 39 ++-- readme.txt | 1 + woocommerce-gateway-stripe.php | 169 +++++++++--------- 12 files changed, 121 insertions(+), 114 deletions(-) diff --git a/changelog.txt b/changelog.txt index cf49c8940..66665bc71 100644 --- a/changelog.txt +++ b/changelog.txt @@ -5,6 +5,7 @@ * Fix - Return to the correct page when redirect-based payment method fails. * Fix - Show default recipient for Payment Authentication Requested email. * Fix - Correctly handles IPP failed payments webhook calls by extracting the order ID from the payment intent metadata. +* Dev - Fix lint issues raised by WordPress code standards. * Fix - Fix ECE crash in classic cart and checkout pages for non-English language sites. * Fix - Correctly handles UK postcodes redacted by Apple Pay. * Tweak - Avoid re-sending Processing Order customer email when merchant wins dispute. diff --git a/includes/abstracts/abstract-wc-stripe-payment-gateway.php b/includes/abstracts/abstract-wc-stripe-payment-gateway.php index d018b98cf..1f16ce8f3 100644 --- a/includes/abstracts/abstract-wc-stripe-payment-gateway.php +++ b/includes/abstracts/abstract-wc-stripe-payment-gateway.php @@ -1408,7 +1408,7 @@ public function get_level3_data_from_order( $order ) { $currency = $order->get_currency(); $stripe_line_items = array_map( - function( $item ) use ( $currency ) { + function ( $item ) use ( $currency ) { if ( is_a( $item, 'WC_Order_Item_Product' ) ) { $product_id = $item->get_variation_id() ? $item->get_variation_id() diff --git a/includes/admin/class-wc-rest-stripe-settings-controller.php b/includes/admin/class-wc-rest-stripe-settings-controller.php index 39b0c4c40..8e6dbb35f 100644 --- a/includes/admin/class-wc-rest-stripe-settings-controller.php +++ b/includes/admin/class-wc-rest-stripe-settings-controller.php @@ -439,7 +439,6 @@ private function update_is_debug_log_enabled( WP_REST_Request $request ) { } $this->gateway->update_option( 'logging', $is_debug_log_enabled ? 'yes' : 'no' ); - } /** diff --git a/includes/admin/stripe-eps-settings.php b/includes/admin/stripe-eps-settings.php index 5a0698b92..74c8a55bd 100644 --- a/includes/admin/stripe-eps-settings.php +++ b/includes/admin/stripe-eps-settings.php @@ -1,4 +1,6 @@ __( 'Webhook Endpoints', 'woocommerce-gateway-stripe' ), 'type' => 'title', /* translators: webhook URL */ - 'description' => $this->display_admin_settings_webhook_description(), + 'description' => $this->display_admin_settings_webhook_description(), // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UndefinedVariable ], ] ); diff --git a/includes/admin/stripe-p24-settings.php b/includes/admin/stripe-p24-settings.php index 9de838db4..43d34a78b 100644 --- a/includes/admin/stripe-p24-settings.php +++ b/includes/admin/stripe-p24-settings.php @@ -1,4 +1,6 @@ __( 'Webhook Endpoints', 'woocommerce-gateway-stripe' ), 'type' => 'title', /* translators: webhook URL */ - 'description' => $this->display_admin_settings_webhook_description(), + 'description' => $this->display_admin_settings_webhook_description(), // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UndefinedVariable ], ] ); diff --git a/includes/admin/stripe-sepa-settings.php b/includes/admin/stripe-sepa-settings.php index 8101f1f64..da3a826d6 100644 --- a/includes/admin/stripe-sepa-settings.php +++ b/includes/admin/stripe-sepa-settings.php @@ -1,4 +1,6 @@ __( 'Webhook Endpoints', 'woocommerce-gateway-stripe' ), 'type' => 'title', /* translators: webhook URL */ - 'description' => $this->display_admin_settings_webhook_description(), + 'description' => $this->display_admin_settings_webhook_description(), // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UndefinedVariable ], ] ); diff --git a/includes/class-wc-stripe-intent-controller.php b/includes/class-wc-stripe-intent-controller.php index c6a976879..ccd967cfc 100644 --- a/includes/class-wc-stripe-intent-controller.php +++ b/includes/class-wc-stripe-intent-controller.php @@ -1101,7 +1101,7 @@ public function confirm_change_payment_from_setup_intent_ajax() { throw new WC_Stripe_Exception( 'subscription_not_found', __( "We're not able to process this subscription change payment request payment. Please try again later.", 'woocommerce-gateway-stripe' ) ); } - $setup_intent_id = isset( $_POST['intent_id'] ) ? wc_clean( wp_unslash( $_POST['intent_id'] ) ) : null; + $setup_intent_id = ( isset( $_POST['intent_id'] ) && is_string( $_POST['intent_id'] ) ) ? sanitize_text_field( wp_unslash( $_POST['intent_id'] ) ) : null; if ( empty( $setup_intent_id ) ) { throw new WC_Stripe_Exception( 'intent_not_found', __( "We're not able to process this subscription change payment request payment. Please try again later.", 'woocommerce-gateway-stripe' ) ); diff --git a/includes/class-wc-stripe-webhook-handler.php b/includes/class-wc-stripe-webhook-handler.php index 87cdd57e4..818756bcf 100644 --- a/includes/class-wc-stripe-webhook-handler.php +++ b/includes/class-wc-stripe-webhook-handler.php @@ -1200,7 +1200,6 @@ protected function handle_deferred_payment_intent_succeeded( $order, $intent_id do_action( 'wc_gateway_stripe_process_payment', $charge, $order ); $this->process_response( $charge, $order ); - } /** diff --git a/includes/compat/class-wc-stripe-subscriptions-legacy-sepa-token-update.php b/includes/compat/class-wc-stripe-subscriptions-legacy-sepa-token-update.php index c6cc78ad0..b0f8ec430 100644 --- a/includes/compat/class-wc-stripe-subscriptions-legacy-sepa-token-update.php +++ b/includes/compat/class-wc-stripe-subscriptions-legacy-sepa-token-update.php @@ -90,16 +90,19 @@ public function maybe_update_subscription_source( WC_Subscription $subscription */ private function get_subscription_to_migrate( $subscription_id ) { if ( ! WC_Stripe_Feature_Flags::is_upe_checkout_enabled() ) { + // phpcs:ignore WordPress.Security.EscapeOutput.ExceptionNotEscaped throw new \Exception( sprintf( '---- Skipping migration of subscription #%d. The Legacy experience is enabled.', $subscription_id ) ); } if ( ! class_exists( 'WC_Subscriptions' ) ) { + // phpcs:ignore WordPress.Security.EscapeOutput.ExceptionNotEscaped throw new \Exception( sprintf( '---- Skipping migration of subscription #%d. The WooCommerce Subscriptions extension is not active.', $subscription_id ) ); } $subscription = wcs_get_subscription( $subscription_id ); if ( ! $subscription ) { + // phpcs:ignore WordPress.Security.EscapeOutput.ExceptionNotEscaped throw new \Exception( sprintf( '---- Skipping migration of subscription #%d. Subscription not found.', $subscription_id ) ); } @@ -121,6 +124,7 @@ private function set_subscription_updated_payment_method( WC_Subscription $subsc // Bail out if the subscription is already using a pm_. if ( 0 !== strpos( $source_id, 'src_' ) ) { + // phpcs:ignore WordPress.Security.EscapeOutput.ExceptionNotEscaped throw new \Exception( sprintf( 'The subscription is not using a Stripe Source for renewals.', $subscription->get_id() ) ); } @@ -129,11 +133,13 @@ private function set_subscription_updated_payment_method( WC_Subscription $subsc // Bail out, if the source object isn't expected to be migrated. eg Card sources are not migrated. if ( isset( $source_object->type ) && 'card' === $source_object->type ) { + // phpcs:ignore WordPress.Security.EscapeOutput.ExceptionNotEscaped throw new \Exception( sprintf( 'Skipping migration of Source for subscription #%d. Source is a card.', $subscription->get_id() ) ); } // Bail out if the src_ hasn't been migrated to pm_ yet. if ( ! isset( $source_object->metadata->migrated_payment_method ) ) { + // phpcs:ignore WordPress.Security.EscapeOutput.ExceptionNotEscaped throw new \Exception( sprintf( 'The Source has not been migrated to PaymentMethods on the Stripe account.', $subscription->get_id() ) ); } @@ -153,6 +159,7 @@ private function set_subscription_updated_payment_method( WC_Subscription $subsc private function set_subscription_updated_payment_gateway_id( WC_Subscription $subscription ) { // The subscription is not using the legacy SEPA gateway ID. if ( WC_Gateway_Stripe_Sepa::ID !== $subscription->get_payment_method() ) { + // phpcs:ignore WordPress.Security.EscapeOutput.ExceptionNotEscaped throw new \Exception( sprintf( '---- Skipping migration of subscription #%d. Subscription is not using the legacy SEPA payment method.', $subscription->get_id() ) ); } diff --git a/includes/payment-tokens/class-wc-stripe-payment-tokens.php b/includes/payment-tokens/class-wc-stripe-payment-tokens.php index 2369ae993..ba44bbed8 100644 --- a/includes/payment-tokens/class-wc-stripe-payment-tokens.php +++ b/includes/payment-tokens/class-wc-stripe-payment-tokens.php @@ -192,22 +192,19 @@ public function woocommerce_get_customer_payment_tokens_legacy( $tokens, $custom } else { unset( $stored_tokens[ $source->id ] ); } + } elseif ( ! isset( $stored_tokens[ $source->id ] ) && WC_Stripe_Payment_Methods::CARD === $source->object ) { + $token = new WC_Payment_Token_CC(); + $token->set_token( $source->id ); + $token->set_gateway_id( WC_Gateway_Stripe::ID ); + $token->set_card_type( strtolower( $source->brand ) ); + $token->set_last4( $source->last4 ); + $token->set_expiry_month( $source->exp_month ); + $token->set_expiry_year( $source->exp_year ); + $token->set_user_id( $customer_id ); + $token->save(); + $tokens[ $token->get_id() ] = $token; } else { - if ( ! isset( $stored_tokens[ $source->id ] ) && WC_Stripe_Payment_Methods::CARD === $source->object ) { - $token = new WC_Stripe_Payment_Token_CC(); - $token->set_token( $source->id ); - $token->set_gateway_id( WC_Gateway_Stripe::ID ); - $token->set_card_type( strtolower( $source->brand ) ); - $token->set_last4( $source->last4 ); - $token->set_expiry_month( $source->exp_month ); - $token->set_expiry_year( $source->exp_year ); - $token->set_user_id( $customer_id ); - $token->set_fingerprint( $source->fingerprint ); - $token->save(); - $tokens[ $token->get_id() ] = $token; - } else { - unset( $stored_tokens[ $source->id ] ); - } + unset( $stored_tokens[ $source->id ] ); } } } @@ -446,10 +443,8 @@ public function woocommerce_payment_token_deleted( $token_id, $token ) { } $stripe_customer->detach_payment_method( $token->get_token() ); - } else { - if ( WC_Gateway_Stripe::ID === $token->get_gateway_id() || WC_Gateway_Stripe_Sepa::ID === $token->get_gateway_id() ) { - $stripe_customer->delete_source( $token->get_token() ); - } + } elseif ( WC_Gateway_Stripe::ID === $token->get_gateway_id() || WC_Gateway_Stripe_Sepa::ID === $token->get_gateway_id() ) { + $stripe_customer->delete_source( $token->get_token() ); } } catch ( WC_Stripe_Exception $e ) { WC_Stripe_Logger::log( 'Error: ' . $e->getMessage() ); @@ -471,10 +466,8 @@ public function woocommerce_payment_token_set_default( $token_id ) { if ( WC_Stripe_UPE_Payment_Gateway::ID === $token->get_gateway_id() ) { $stripe_customer->set_default_payment_method( $token->get_token() ); } - } else { - if ( WC_Gateway_Stripe::ID === $token->get_gateway_id() || WC_Gateway_Stripe_Sepa::ID === $token->get_gateway_id() ) { - $stripe_customer->set_default_source( $token->get_token() ); - } + } elseif ( WC_Gateway_Stripe::ID === $token->get_gateway_id() || WC_Gateway_Stripe_Sepa::ID === $token->get_gateway_id() ) { + $stripe_customer->set_default_source( $token->get_token() ); } } catch ( WC_Stripe_Exception $e ) { WC_Stripe_Logger::log( 'Error: ' . $e->getMessage() ); diff --git a/readme.txt b/readme.txt index f7a2330b0..3ba9388c8 100644 --- a/readme.txt +++ b/readme.txt @@ -115,6 +115,7 @@ If you get stuck, you can ask for help in the [Plugin Forum](https://wordpress.o * Fix - Return to the correct page when redirect-based payment method fails. * Fix - Show default recipient for Payment Authentication Requested email. * Fix - Correctly handles IPP failed payments webhook calls by extracting the order ID from the payment intent metadata. +* Dev - Fix lint issues raised by WordPress code standards. * Fix - Fix ECE crash in classic cart and checkout pages for non-English language sites. * Fix - Correctly handles UK postcodes redacted by Apple Pay. * Tweak - Avoid re-sending Processing Order customer email when merchant wins dispute. diff --git a/woocommerce-gateway-stripe.php b/woocommerce-gateway-stripe.php index 1fd543e2d..4068a6a64 100644 --- a/woocommerce-gateway-stripe.php +++ b/woocommerce-gateway-stripe.php @@ -188,84 +188,85 @@ public function __construct() { */ public function init() { if ( is_admin() ) { - require_once dirname( __FILE__ ) . '/includes/admin/class-wc-stripe-privacy.php'; + require_once __DIR__ . '/includes/admin/class-wc-stripe-privacy.php'; } - require_once dirname( __FILE__ ) . '/includes/class-wc-stripe-feature-flags.php'; - require_once dirname( __FILE__ ) . '/includes/class-wc-stripe-upe-compatibility.php'; - require_once dirname( __FILE__ ) . '/includes/class-wc-stripe-co-branded-cc-compatibility.php'; - require_once dirname( __FILE__ ) . '/includes/class-wc-stripe-exception.php'; - require_once dirname( __FILE__ ) . '/includes/class-wc-stripe-logger.php'; - require_once dirname( __FILE__ ) . '/includes/class-wc-stripe-helper.php'; - include_once dirname( __FILE__ ) . '/includes/class-wc-stripe-api.php'; - include_once dirname( __FILE__ ) . '/includes/class-wc-stripe-mode.php'; - require_once dirname( __FILE__ ) . '/includes/compat/trait-wc-stripe-subscriptions-utilities.php'; - require_once dirname( __FILE__ ) . '/includes/compat/trait-wc-stripe-subscriptions.php'; - require_once dirname( __FILE__ ) . '/includes/compat/trait-wc-stripe-pre-orders.php'; - require_once dirname( __FILE__ ) . '/includes/compat/class-wc-stripe-subscriptions-legacy-sepa-token-update.php'; - require_once dirname( __FILE__ ) . '/includes/abstracts/abstract-wc-stripe-payment-gateway.php'; - require_once dirname( __FILE__ ) . '/includes/abstracts/abstract-wc-stripe-payment-gateway-voucher.php'; - require_once dirname( __FILE__ ) . '/includes/class-wc-stripe-action-scheduler-service.php'; - require_once dirname( __FILE__ ) . '/includes/class-wc-stripe-webhook-state.php'; - require_once dirname( __FILE__ ) . '/includes/class-wc-stripe-webhook-handler.php'; - require_once dirname( __FILE__ ) . '/includes/payment-tokens/trait-wc-stripe-fingerprint.php'; - require_once dirname( __FILE__ ) . '/includes/payment-tokens/interface-wc-stripe-payment-method-comparison.php'; - require_once dirname( __FILE__ ) . '/includes/payment-tokens/class-wc-stripe-cc-payment-token.php'; - require_once dirname( __FILE__ ) . '/includes/payment-tokens/class-wc-stripe-sepa-payment-token.php'; - require_once dirname( __FILE__ ) . '/includes/payment-tokens/class-wc-stripe-link-payment-token.php'; - require_once dirname( __FILE__ ) . '/includes/payment-tokens/class-wc-stripe-cash-app-payment-token.php'; - require_once dirname( __FILE__ ) . '/includes/class-wc-stripe-apple-pay-registration.php'; - require_once dirname( __FILE__ ) . '/includes/class-wc-gateway-stripe.php'; - require_once dirname( __FILE__ ) . '/includes/constants/class-wc-stripe-currency-code.php'; - require_once dirname( __FILE__ ) . '/includes/constants/class-wc-stripe-payment-methods.php'; - require_once dirname( __FILE__ ) . '/includes/constants/class-wc-stripe-intent-status.php'; - require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-stripe-upe-payment-gateway.php'; - require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-stripe-upe-payment-method.php'; - require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-stripe-upe-payment-method-cc.php'; - require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-stripe-upe-payment-method-alipay.php'; - require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-stripe-upe-payment-method-giropay.php'; - require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-stripe-upe-payment-method-ideal.php'; - require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-stripe-upe-payment-method-klarna.php'; - require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-stripe-upe-payment-method-affirm.php'; - require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-stripe-upe-payment-method-afterpay-clearpay.php'; - require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-stripe-upe-payment-method-bancontact.php'; - require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-stripe-upe-payment-method-boleto.php'; - require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-stripe-upe-payment-method-oxxo.php'; - require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-stripe-upe-payment-method-eps.php'; - require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-stripe-upe-payment-method-sepa.php'; - require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-stripe-upe-payment-method-p24.php'; - require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-stripe-upe-payment-method-sofort.php'; - require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-stripe-upe-payment-method-multibanco.php'; - require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-stripe-upe-payment-method-link.php'; - require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-stripe-upe-payment-method-cash-app-pay.php'; - require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-stripe-upe-payment-method-wechat-pay.php'; - require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-bancontact.php'; - require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-sofort.php'; - require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-giropay.php'; - require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-eps.php'; - require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-ideal.php'; - require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-p24.php'; - require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-alipay.php'; - require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-sepa.php'; - require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-multibanco.php'; - require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-boleto.php'; - require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-gateway-stripe-oxxo.php'; - require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-stripe-payment-request.php'; - require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-stripe-express-checkout-element.php'; - require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-stripe-express-checkout-helper.php'; - require_once dirname( __FILE__ ) . '/includes/payment-methods/class-wc-stripe-express-checkout-ajax-handler.php'; - require_once dirname( __FILE__ ) . '/includes/compat/class-wc-stripe-woo-compat-utils.php'; - require_once dirname( __FILE__ ) . '/includes/connect/class-wc-stripe-connect.php'; - require_once dirname( __FILE__ ) . '/includes/connect/class-wc-stripe-connect-api.php'; - require_once dirname( __FILE__ ) . '/includes/class-wc-stripe-order-handler.php'; - require_once dirname( __FILE__ ) . '/includes/payment-tokens/class-wc-stripe-payment-tokens.php'; - require_once dirname( __FILE__ ) . '/includes/class-wc-stripe-customer.php'; - require_once dirname( __FILE__ ) . '/includes/class-wc-stripe-intent-controller.php'; - require_once dirname( __FILE__ ) . '/includes/admin/class-wc-stripe-inbox-notes.php'; - require_once dirname( __FILE__ ) . '/includes/admin/class-wc-stripe-upe-compatibility-controller.php'; - require_once dirname( __FILE__ ) . '/includes/migrations/class-allowed-payment-request-button-types-update.php'; - require_once dirname( __FILE__ ) . '/includes/migrations/class-migrate-payment-request-data-to-express-checkout-data.php'; - require_once dirname( __FILE__ ) . '/includes/class-wc-stripe-account.php'; + require_once __DIR__ . '/includes/class-wc-stripe-feature-flags.php'; + require_once __DIR__ . '/includes/class-wc-stripe-upe-compatibility.php'; + require_once __DIR__ . '/includes/class-wc-stripe-co-branded-cc-compatibility.php'; + require_once __DIR__ . '/includes/class-wc-stripe-exception.php'; + require_once __DIR__ . '/includes/class-wc-stripe-logger.php'; + require_once __DIR__ . '/includes/class-wc-stripe-helper.php'; + include_once __DIR__ . '/includes/class-wc-stripe-api.php'; + include_once __DIR__ . '/includes/class-wc-stripe-mode.php'; + require_once __DIR__ . '/includes/compat/trait-wc-stripe-subscriptions-utilities.php'; + require_once __DIR__ . '/includes/compat/trait-wc-stripe-subscriptions.php'; + require_once __DIR__ . '/includes/compat/trait-wc-stripe-pre-orders.php'; + require_once __DIR__ . '/includes/compat/class-wc-stripe-subscriptions-legacy-sepa-token-update.php'; + require_once __DIR__ . '/includes/abstracts/abstract-wc-stripe-payment-gateway.php'; + require_once __DIR__ . '/includes/abstracts/abstract-wc-stripe-payment-gateway-voucher.php'; + require_once __DIR__ . '/includes/class-wc-stripe-action-scheduler-service.php'; + require_once __DIR__ . '/includes/class-wc-stripe-webhook-state.php'; + require_once __DIR__ . '/includes/class-wc-stripe-webhook-handler.php'; + require_once __DIR__ . '/includes/payment-tokens/trait-wc-stripe-fingerprint.php'; + require_once __DIR__ . '/includes/payment-tokens/interface-wc-stripe-payment-method-comparison.php'; + require_once __DIR__ . '/includes/payment-tokens/class-wc-stripe-cc-payment-token.php'; + require_once __DIR__ . '/includes/payment-tokens/class-wc-stripe-sepa-payment-token.php'; + require_once __DIR__ . '/includes/payment-tokens/class-wc-stripe-link-payment-token.php'; + require_once __DIR__ . '/includes/payment-tokens/class-wc-stripe-cash-app-payment-token.php'; + require_once __DIR__ . '/includes/class-wc-stripe-apple-pay-registration.php'; + require_once __DIR__ . '/includes/class-wc-gateway-stripe.php'; + require_once __DIR__ . '/includes/constants/class-wc-stripe-currency-code.php'; + require_once __DIR__ . '/includes/constants/class-wc-stripe-payment-methods.php'; + require_once __DIR__ . '/includes/constants/class-wc-stripe-intent-status.php'; + require_once __DIR__ . '/includes/payment-methods/class-wc-stripe-upe-payment-gateway.php'; + require_once __DIR__ . '/includes/payment-methods/class-wc-stripe-upe-payment-method.php'; + require_once __DIR__ . '/includes/payment-methods/class-wc-stripe-upe-payment-method-cc.php'; + require_once __DIR__ . '/includes/payment-methods/class-wc-stripe-upe-payment-method-alipay.php'; + require_once __DIR__ . '/includes/payment-methods/class-wc-stripe-upe-payment-method-giropay.php'; + require_once __DIR__ . '/includes/payment-methods/class-wc-stripe-upe-payment-method-ideal.php'; + require_once __DIR__ . '/includes/payment-methods/class-wc-stripe-upe-payment-method-klarna.php'; + require_once __DIR__ . '/includes/payment-methods/class-wc-stripe-upe-payment-method-affirm.php'; + require_once __DIR__ . '/includes/payment-methods/class-wc-stripe-upe-payment-method-afterpay-clearpay.php'; + require_once __DIR__ . '/includes/payment-methods/class-wc-stripe-upe-payment-method-bancontact.php'; + require_once __DIR__ . '/includes/payment-methods/class-wc-stripe-upe-payment-method-boleto.php'; + require_once __DIR__ . '/includes/payment-methods/class-wc-stripe-upe-payment-method-oxxo.php'; + require_once __DIR__ . '/includes/payment-methods/class-wc-stripe-upe-payment-method-eps.php'; + require_once __DIR__ . '/includes/payment-methods/class-wc-stripe-upe-payment-method-sepa.php'; + require_once __DIR__ . '/includes/payment-methods/class-wc-stripe-upe-payment-method-p24.php'; + require_once __DIR__ . '/includes/payment-methods/class-wc-stripe-upe-payment-method-sofort.php'; + require_once __DIR__ . '/includes/payment-methods/class-wc-stripe-upe-payment-method-multibanco.php'; + require_once __DIR__ . '/includes/payment-methods/class-wc-stripe-upe-payment-method-link.php'; + require_once __DIR__ . '/includes/payment-methods/class-wc-stripe-upe-payment-method-cash-app-pay.php'; + require_once __DIR__ . '/includes/payment-methods/class-wc-stripe-upe-payment-method-wechat-pay.php'; + require_once __DIR__ . '/includes/payment-methods/class-wc-gateway-stripe-bancontact.php'; + require_once __DIR__ . '/includes/payment-methods/class-wc-gateway-stripe-sofort.php'; + require_once __DIR__ . '/includes/payment-methods/class-wc-gateway-stripe-giropay.php'; + require_once __DIR__ . '/includes/payment-methods/class-wc-gateway-stripe-eps.php'; + require_once __DIR__ . '/includes/payment-methods/class-wc-gateway-stripe-ideal.php'; + require_once __DIR__ . '/includes/payment-methods/class-wc-gateway-stripe-p24.php'; + require_once __DIR__ . '/includes/payment-methods/class-wc-gateway-stripe-alipay.php'; + require_once __DIR__ . '/includes/payment-methods/class-wc-gateway-stripe-sepa.php'; + require_once __DIR__ . '/includes/payment-methods/class-wc-gateway-stripe-multibanco.php'; + require_once __DIR__ . '/includes/payment-methods/class-wc-gateway-stripe-boleto.php'; + require_once __DIR__ . '/includes/payment-methods/class-wc-gateway-stripe-oxxo.php'; + require_once __DIR__ . '/includes/payment-methods/class-wc-stripe-payment-request.php'; + require_once __DIR__ . '/includes/payment-methods/class-wc-stripe-express-checkout-element.php'; + require_once __DIR__ . '/includes/payment-methods/class-wc-stripe-express-checkout-helper.php'; + require_once __DIR__ . '/includes/payment-methods/class-wc-stripe-express-checkout-ajax-handler.php'; + require_once __DIR__ . '/includes/compat/class-wc-stripe-woo-compat-utils.php'; + require_once __DIR__ . '/includes/connect/class-wc-stripe-connect.php'; + require_once __DIR__ . '/includes/connect/class-wc-stripe-connect-api.php'; + require_once __DIR__ . '/includes/class-wc-stripe-order-handler.php'; + require_once __DIR__ . '/includes/payment-tokens/class-wc-stripe-payment-tokens.php'; + require_once __DIR__ . '/includes/class-wc-stripe-customer.php'; + require_once __DIR__ . '/includes/class-wc-stripe-intent-controller.php'; + require_once __DIR__ . '/includes/admin/class-wc-stripe-inbox-notes.php'; + require_once __DIR__ . '/includes/admin/class-wc-stripe-upe-compatibility-controller.php'; + require_once __DIR__ . '/includes/migrations/class-allowed-payment-request-button-types-update.php'; + require_once __DIR__ . '/includes/migrations/class-migrate-payment-request-data-to-express-checkout-data.php'; + require_once __DIR__ . '/includes/class-wc-stripe-account.php'; + new Allowed_Payment_Request_Button_Types_Update(); new Migrate_Payment_Request_Data_To_Express_Checkout_Data(); @@ -284,24 +285,24 @@ public function init() { $intent_controller->init_hooks(); if ( is_admin() ) { - require_once dirname( __FILE__ ) . '/includes/admin/class-wc-stripe-admin-notices.php'; - require_once dirname( __FILE__ ) . '/includes/admin/class-wc-stripe-settings-controller.php'; + require_once __DIR__ . '/includes/admin/class-wc-stripe-admin-notices.php'; + require_once __DIR__ . '/includes/admin/class-wc-stripe-settings-controller.php'; if ( isset( $_GET['area'] ) && 'payment_requests' === $_GET['area'] ) { - require_once dirname( __FILE__ ) . '/includes/admin/class-wc-stripe-payment-requests-controller.php'; + require_once __DIR__ . '/includes/admin/class-wc-stripe-payment-requests-controller.php'; new WC_Stripe_Payment_Requests_Controller(); } else { new WC_Stripe_Settings_Controller( $this->account ); } if ( WC_Stripe_Feature_Flags::is_upe_checkout_enabled() ) { - require_once dirname( __FILE__ ) . '/includes/admin/class-wc-stripe-payment-gateways-controller.php'; + require_once __DIR__ . '/includes/admin/class-wc-stripe-payment-gateways-controller.php'; new WC_Stripe_Payment_Gateways_Controller(); } } // REMOVE IN THE FUTURE. - require_once dirname( __FILE__ ) . '/includes/deprecated/class-wc-stripe-apple-pay.php'; + require_once __DIR__ . '/includes/deprecated/class-wc-stripe-apple-pay.php'; add_filter( 'woocommerce_payment_gateways', [ $this, 'add_gateways' ] ); add_filter( 'pre_update_option_woocommerce_stripe_settings', [ $this, 'gateway_settings_update' ], 10, 2 ); @@ -786,7 +787,7 @@ public function initialize_subscriptions_updater() { if ( ! class_exists( 'WCS_Background_Repairer' ) ) { return; } - require_once dirname( __FILE__ ) . '/includes/migrations/class-wc-stripe-subscriptions-repairer-legacy-sepa-tokens.php'; + require_once __DIR__ . '/includes/migrations/class-wc-stripe-subscriptions-repairer-legacy-sepa-tokens.php'; $logger = wc_get_logger(); $updater = new WC_Stripe_Subscriptions_Repairer_Legacy_SEPA_Tokens( $logger ); @@ -796,7 +797,7 @@ public function initialize_subscriptions_updater() { } public function load_plugin_textdomain() { - load_plugin_textdomain( 'woocommerce-gateway-stripe', false, plugin_basename( dirname( __FILE__ ) ) . '/languages' ); + load_plugin_textdomain( 'woocommerce-gateway-stripe', false, plugin_basename( __DIR__ ) . '/languages' ); } } @@ -859,7 +860,7 @@ function wcstripe_deactivated() { function woocommerce_gateway_stripe_woocommerce_block_support() { if ( class_exists( 'Automattic\WooCommerce\Blocks\Payments\Integrations\AbstractPaymentMethodType' ) ) { - require_once dirname( __FILE__ ) . '/includes/class-wc-stripe-blocks-support.php'; + require_once __DIR__ . '/includes/class-wc-stripe-blocks-support.php'; // priority is important here because this ensures this integration is // registered before the WooCommerce Blocks built-in Stripe registration. // Blocks code has a check in place to only register if 'stripe' is not