From f994c770d11ec54fb9b946d9ae6bd3cd63eb0559 Mon Sep 17 00:00:00 2001 From: Nabeel Molham Date: Thu, 22 Aug 2024 12:45:44 +1000 Subject: [PATCH 01/62] Bump 5.13.1 dev version --- .../plugins/gateway-test-plugin/gateway-test-plugin.php | 2 +- tests/_support/plugins/test-plugin/test-plugin.php | 2 +- woocommerce-framework-plugin-loader-sample.php | 2 +- woocommerce/changelog.txt | 2 ++ woocommerce/class-sv-wc-plugin.php | 2 +- 5 files changed, 6 insertions(+), 4 deletions(-) diff --git a/tests/_support/plugins/gateway-test-plugin/gateway-test-plugin.php b/tests/_support/plugins/gateway-test-plugin/gateway-test-plugin.php index a0f629264..718bba674 100644 --- a/tests/_support/plugins/gateway-test-plugin/gateway-test-plugin.php +++ b/tests/_support/plugins/gateway-test-plugin/gateway-test-plugin.php @@ -39,7 +39,7 @@ class SV_WC_Framework_Gateway_Test_Plugin_Loader { const MINIMUM_WC_VERSION = '3.0.9'; /** SkyVerge plugin framework version used by this plugin */ - const FRAMEWORK_VERSION = '5.13.0'; + const FRAMEWORK_VERSION = '5.13.1-dev.1'; /** the plugin name, for displaying notices */ const PLUGIN_NAME = 'WooCommerce Framework Gateway Test Plugin'; diff --git a/tests/_support/plugins/test-plugin/test-plugin.php b/tests/_support/plugins/test-plugin/test-plugin.php index 7ae650926..123f7398d 100644 --- a/tests/_support/plugins/test-plugin/test-plugin.php +++ b/tests/_support/plugins/test-plugin/test-plugin.php @@ -39,7 +39,7 @@ class SV_WC_Framework_Test_Plugin_Loader { const MINIMUM_WC_VERSION = '3.0.9'; /** SkyVerge plugin framework version used by this plugin */ - const FRAMEWORK_VERSION = '5.13.0'; + const FRAMEWORK_VERSION = '5.13.1-dev.1'; /** the plugin name, for displaying notices */ const PLUGIN_NAME = 'WooCommerce Framework Test Plugin'; diff --git a/woocommerce-framework-plugin-loader-sample.php b/woocommerce-framework-plugin-loader-sample.php index 9b11ce0b8..1d0244a45 100644 --- a/woocommerce-framework-plugin-loader-sample.php +++ b/woocommerce-framework-plugin-loader-sample.php @@ -61,7 +61,7 @@ class SV_WC_Framework_Plugin_Loader { const MINIMUM_WC_VERSION = '3.9'; /** SkyVerge plugin framework version used by this plugin */ - const FRAMEWORK_VERSION = '5.13.0'; // TODO: framework version + const FRAMEWORK_VERSION = '5.13.1-dev.1'; // TODO: framework version /** the plugin name, for displaying notices */ diff --git a/woocommerce/changelog.txt b/woocommerce/changelog.txt index 5dbe9f624..430b7f9b3 100644 --- a/woocommerce/changelog.txt +++ b/woocommerce/changelog.txt @@ -1,5 +1,7 @@ *** SkyVerge WooCommerce Plugin Framework Changelog *** +2024.nn.nn - version 5.13.1-dev.1 + 2024.08.21 - version 5.13.0 * Feature - Add a trait for enum-like classes * Misc - Set the checkout page context in the session when rendering payment fields diff --git a/woocommerce/class-sv-wc-plugin.php b/woocommerce/class-sv-wc-plugin.php index 076e9717a..8cd26d2df 100644 --- a/woocommerce/class-sv-wc-plugin.php +++ b/woocommerce/class-sv-wc-plugin.php @@ -47,7 +47,7 @@ abstract class SV_WC_Plugin { /** Plugin Framework Version */ - const VERSION = '5.13.0'; + const VERSION = '5.13.1-dev.1'; /** @var object single instance of plugin */ protected static $instance; From 7cf0efece62668c63ac6a325bea6eb56a8c86cea Mon Sep 17 00:00:00 2001 From: Nabeel Molham Date: Thu, 22 Aug 2024 12:50:34 +1000 Subject: [PATCH 02/62] Update namespace version --- composer.json | 2 +- tests/TestCase.php | 2 +- .../gateway-test-plugin/includes/API.php | 2 +- .../gateway-test-plugin/includes/Gateway.php | 2 +- .../gateway-test-plugin/includes/Plugin.php | 2 +- .../plugins/test-plugin/includes/API.php | 2 +- .../plugins/test-plugin/includes/Gateway.php | 2 +- .../plugins/test-plugin/includes/Plugin.php | 2 +- .../integration/API/CacheableAPIBaseTest.php | 10 +++---- tests/integration/DependenciesTest.php | 6 ++-- tests/integration/HelperTest.php | 4 +-- tests/integration/PluginTest.php | 6 ++-- .../REST_API/Controllers/SettingsTest.php | 10 +++---- tests/integration/REST_API/RESTAPITest.php | 8 +++--- .../SV_WC_Payment_Gateway_Helper_Test.php | 4 +-- .../Settings_API/AbstractSettingsTest.php | 12 ++++---- .../integration/Settings_API/SettingTest.php | 4 +-- .../payment-gateway/GatewayPluginTest.php | 2 +- .../payment-gateway/MyPaymentMethodsTest.php | 8 +++--- .../payment-gateway/PaymentFormTest.php | 6 ++-- ..._WC_Payment_Gateway_Payment_Token_Test.php | 4 +-- ...nt_Gateway_Payment_Tokens_Handler_Test.php | 4 +-- .../apple-pay/ApplePayFrontendTest.php | 10 +++---- tests/unit/API/CacheableRequestTraitTest.php | 20 ++++++------- tests/unit/CountryHelperTest.php | 8 +++--- tests/unit/PaymentFormContextCheckerTest.php | 20 ++++++------- tests/unit/Settings_API/ControlTest.php | 28 +++++++++---------- tests/unit/Settings_API/SettingTest.php | 26 ++++++++--------- woocommerce/Addresses/Address.php | 4 +-- woocommerce/Addresses/Customer_Address.php | 4 +-- woocommerce/Blocks/Block_Integration.php | 10 +++---- woocommerce/Blocks/Blocks_Handler.php | 10 +++---- .../Blocks/Traits/Block_Integration_Trait.php | 16 +++++------ woocommerce/Country_Helper.php | 4 +-- woocommerce/Enums/PaymentFormContext.php | 4 +-- woocommerce/Enums/Traits/EnumTrait.php | 2 +- woocommerce/Handlers/Script_Handler.php | 10 +++---- woocommerce/Lifecycle.php | 12 ++++---- .../Settings_API/Abstract_Settings.php | 6 ++-- woocommerce/Settings_API/Control.php | 6 ++-- woocommerce/Settings_API/Setting.php | 6 ++-- woocommerce/admin/Notes_Helper.php | 4 +-- ...stract-sv-wc-plugin-admin-setup-wizard.php | 6 ++-- .../api/Abstract_Cacheable_API_Base.php | 8 +++--- .../api/abstract-sv-wc-api-json-request.php | 4 +-- .../api/abstract-sv-wc-api-json-response.php | 4 +-- .../api/abstract-sv-wc-api-xml-request.php | 4 +-- .../api/abstract-sv-wc-api-xml-response.php | 4 +-- woocommerce/api/class-sv-wc-api-base.php | 4 +-- woocommerce/api/class-sv-wc-api-exception.php | 4 +-- .../api/interface-sv-wc-api-request.php | 4 +-- .../api/interface-sv-wc-api-response.php | 4 +-- .../api/traits/Cacheable_Request_Trait.php | 4 +-- .../class-sv-wc-admin-notice-handler.php | 4 +-- woocommerce/class-sv-wc-helper.php | 4 +-- woocommerce/class-sv-wc-hook-deprecator.php | 4 +-- .../class-sv-wc-plugin-compatibility.php | 4 +-- .../class-sv-wc-plugin-dependencies.php | 4 +-- woocommerce/class-sv-wc-plugin-exception.php | 4 +-- woocommerce/class-sv-wc-plugin.php | 4 +-- .../class-sv-wp-admin-message-handler.php | 4 +-- .../abstract-sv-wc-data-compatibility.php | 4 +-- .../class-sv-wc-order-compatibility.php | 4 +-- ...class-sv-wc-subscription-compatibility.php | 4 +-- .../Blocks/Gateway_Blocks_Handler.php | 8 +++--- .../Gateway_Checkout_Block_Integration.php | 16 +++++------ .../External_Checkout/Admin.php | 4 +-- .../External_Checkout/External_Checkout.php | 6 ++-- .../External_Checkout/Frontend.php | 16 +++++------ .../External_Checkout/Google_Pay/AJAX.php | 8 +++--- .../External_Checkout/Google_Pay/Admin.php | 8 +++--- .../External_Checkout/Google_Pay/Frontend.php | 12 ++++---- .../Google_Pay/Google_Pay.php | 16 +++++------ .../External_Checkout/Orders.php | 4 +-- ...-payment-gateway-apple-pay-api-request.php | 4 +-- ...payment-gateway-apple-pay-api-response.php | 4 +-- ...ss-sv-wc-payment-gateway-apple-pay-api.php | 6 ++-- ...ent-gateway-apple-pay-payment-response.php | 4 +-- ...-sv-wc-payment-gateway-apple-pay-admin.php | 6 ++-- ...s-sv-wc-payment-gateway-apple-pay-ajax.php | 4 +-- ...-wc-payment-gateway-apple-pay-frontend.php | 10 +++---- .../class-sv-wc-payment-gateway-apple-pay.php | 8 +++--- .../Abstract_Hosted_Payment_Handler.php | 6 ++-- .../Handlers/Abstract_Payment_Handler.php | 6 ++-- .../payment-gateway/Handlers/Capture.php | 6 ++-- .../PaymentFormContextChecker.php | 4 +-- ...ment-gateway-plugin-admin-setup-wizard.php | 6 ++-- ...lass-sv-wc-payment-gateway-admin-order.php | 4 +-- ...ent-gateway-admin-payment-token-editor.php | 4 +-- ...-wc-payment-gateway-admin-user-handler.php | 4 +-- ...nt-gateway-api-response-message-helper.php | 4 +-- ...ent-gateway-api-authorization-response.php | 4 +-- ...eway-api-create-payment-token-response.php | 4 +-- ...-payment-gateway-api-customer-response.php | 4 +-- ...get-tokenized-payment-methods-response.php | 4 +-- ...ment-notification-credit-card-response.php | 4 +-- ...i-payment-notification-echeck-response.php | 4 +-- ...eway-api-payment-notification-response.php | 4 +-- ...ent-notification-tokenization-response.php | 4 +-- ...face-sv-wc-payment-gateway-api-request.php | 4 +-- ...ace-sv-wc-payment-gateway-api-response.php | 4 +-- .../interface-sv-wc-payment-gateway-api.php | 4 +-- .../sv-wc-payment-gateway-apple-pay.js | 4 +-- .../sv-wc-payment-gateway-apple-pay.js.map | 2 +- .../sv-wc-payment-gateway-google-pay.js | 4 +-- .../sv-wc-payment-gateway-google-pay.js.map | 2 +- ...v-wc-payment-gateway-my-payment-methods.js | 4 +-- ...-payment-gateway-my-payment-methods.js.map | 2 +- .../sv-wc-payment-gateway-payment-form.js | 4 +-- .../sv-wc-payment-gateway-payment-form.js.map | 2 +- .../sv-wc-payment-gateway-apple-pay.coffee | 4 +-- .../sv-wc-payment-gateway-google-pay.js | 6 ++-- ...-payment-gateway-my-payment-methods.coffee | 4 +-- .../sv-wc-payment-gateway-payment-form.coffee | 6 ++-- .../class-sv-wc-payment-gateway-direct.php | 6 ++-- .../class-sv-wc-payment-gateway-helper.php | 4 +-- .../class-sv-wc-payment-gateway-hosted.php | 4 +-- ...-wc-payment-gateway-my-payment-methods.php | 8 +++--- ...ass-sv-wc-payment-gateway-payment-form.php | 12 ++++---- .../class-sv-wc-payment-gateway-plugin.php | 8 +++--- .../class-sv-wc-payment-gateway-privacy.php | 4 +-- .../class-sv-wc-payment-gateway.php | 10 +++---- .../class-sv-wc-payment-gateway-exception.php | 4 +-- ...ract-sv-wc-payment-gateway-integration.php | 4 +-- ...payment-gateway-integration-pre-orders.php | 4 +-- ...ment-gateway-integration-subscriptions.php | 4 +-- ...ss-sv-wc-payment-gateway-payment-token.php | 4 +-- ...payment-gateway-payment-tokens-handler.php | 4 +-- ...-sv-wc-payment-gateway-plugin-rest-api.php | 10 +++---- woocommerce/rest-api/Controllers/Settings.php | 8 +++--- .../rest-api/class-sv-wc-plugin-rest-api.php | 4 +-- .../utilities/class-sv-wp-async-request.php | 4 +-- .../class-sv-wp-background-job-handler.php | 4 +-- .../class-sv-wp-job-batch-handler.php | 4 +-- 134 files changed, 399 insertions(+), 399 deletions(-) diff --git a/composer.json b/composer.json index 1e289f9dc..aa02aab74 100644 --- a/composer.json +++ b/composer.json @@ -18,7 +18,7 @@ }, "autoload-dev": { "psr-4": { - "SkyVerge\\WooCommerce\\PluginFramework\\v5_13_0\\Tests\\": "tests/" + "SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\Tests\\": "tests/" } }, "config": { diff --git a/tests/TestCase.php b/tests/TestCase.php index f0c830fb2..cd192f805 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -1,6 +1,6 @@ assertInstanceOf( '\SkyVerge\WooCommerce\PluginFramework\v5_13_0\SV_WC_Plugin_Dependencies', $this->get_plugin()->get_dependency_handler() ); + $this->assertInstanceOf( '\SkyVerge\WooCommerce\PluginFramework\v5_13_1\SV_WC_Plugin_Dependencies', $this->get_plugin()->get_dependency_handler() ); } @@ -161,7 +161,7 @@ public function test_get_dependency_handler() { */ public function test_get_lifecycle_handler() { - $this->assertInstanceOf( '\SkyVerge\WooCommerce\PluginFramework\v5_13_0\Plugin\Lifecycle', $this->get_plugin()->get_lifecycle_handler() ); + $this->assertInstanceOf( '\SkyVerge\WooCommerce\PluginFramework\v5_13_1\Plugin\Lifecycle', $this->get_plugin()->get_lifecycle_handler() ); } diff --git a/tests/integration/REST_API/Controllers/SettingsTest.php b/tests/integration/REST_API/Controllers/SettingsTest.php index 62e19e06c..a87f3b922 100644 --- a/tests/integration/REST_API/Controllers/SettingsTest.php +++ b/tests/integration/REST_API/Controllers/SettingsTest.php @@ -1,14 +1,14 @@ render_js(); $this->assertStringContainsString( 'function load_gateway_test_plugin_payment_methods_handler', $wc_queued_js ); - $this->assertStringContainsString( 'window.jQuery( document.body ).on( \'sv_wc_payment_methods_handler_v5_13_0_loaded\', load_gateway_test_plugin_payment_methods_handler );', $wc_queued_js ); + $this->assertStringContainsString( 'window.jQuery( document.body ).on( \'sv_wc_payment_methods_handler_v5_13_1_loaded\', load_gateway_test_plugin_payment_methods_handler );', $wc_queued_js ); } diff --git a/tests/integration/payment-gateway/PaymentFormTest.php b/tests/integration/payment-gateway/PaymentFormTest.php index 048cc35d0..223fa6943 100644 --- a/tests/integration/payment-gateway/PaymentFormTest.php +++ b/tests/integration/payment-gateway/PaymentFormTest.php @@ -1,11 +1,11 @@ get_plugin()->get_gateway()->get_payment_form_instance()->render_js(); $this->assertStringContainsString( 'function load_test_gateway_payment_form_handler', $wc_queued_js ); - $this->assertStringContainsString( 'window.jQuery( document.body ).on( \'sv_wc_payment_form_handler_v5_13_0_loaded\', load_test_gateway_payment_form_handler );', $wc_queued_js ); + $this->assertStringContainsString( 'window.jQuery( document.body ).on( \'sv_wc_payment_form_handler_v5_13_1_loaded\', load_test_gateway_payment_form_handler );', $wc_queued_js ); } diff --git a/tests/integration/payment-gateway/SV_WC_Payment_Gateway_Payment_Token_Test.php b/tests/integration/payment-gateway/SV_WC_Payment_Gateway_Payment_Token_Test.php index e26e0399d..aa7b25ee9 100644 --- a/tests/integration/payment-gateway/SV_WC_Payment_Gateway_Payment_Token_Test.php +++ b/tests/integration/payment-gateway/SV_WC_Payment_Gateway_Payment_Token_Test.php @@ -1,11 +1,11 @@ invokeArgs( $frontend_instance, [[]] ); $this->assertStringContainsString( 'function load_test_gateway_apple_pay_handler', $wc_queued_js ); - $this->assertStringContainsString( 'window.jQuery( document.body ).on( \'sv_wc_apple_pay_handler_v5_13_0_loaded\', load_test_gateway_apple_pay_handler );', $wc_queued_js ); + $this->assertStringContainsString( 'window.jQuery( document.body ).on( \'sv_wc_apple_pay_handler_v5_13_1_loaded\', load_test_gateway_apple_pay_handler );', $wc_queued_js ); } diff --git a/tests/unit/API/CacheableRequestTraitTest.php b/tests/unit/API/CacheableRequestTraitTest.php index 41106f24b..239886745 100644 --- a/tests/unit/API/CacheableRequestTraitTest.php +++ b/tests/unit/API/CacheableRequestTraitTest.php @@ -1,9 +1,9 @@ js_handler_base_class_name ); + return sprintf( '%s_v5_13_1', $this->js_handler_base_class_name ); } diff --git a/woocommerce/Lifecycle.php b/woocommerce/Lifecycle.php index a9bd1d654..99c97713a 100644 --- a/woocommerce/Lifecycle.php +++ b/woocommerce/Lifecycle.php @@ -22,16 +22,16 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 */ -namespace SkyVerge\WooCommerce\PluginFramework\v5_13_0\Plugin; +namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1\Plugin; -use SkyVerge\WooCommerce\PluginFramework\v5_13_0\Admin\Notes_Helper; -use SkyVerge\WooCommerce\PluginFramework\v5_13_0\SV_WC_Payment_Gateway_Plugin; -use SkyVerge\WooCommerce\PluginFramework\v5_13_0\SV_WC_Plugin; -use SkyVerge\WooCommerce\PluginFramework\v5_13_0\SV_WC_Plugin_Compatibility; +use SkyVerge\WooCommerce\PluginFramework\v5_13_1\Admin\Notes_Helper; +use SkyVerge\WooCommerce\PluginFramework\v5_13_1\SV_WC_Payment_Gateway_Plugin; +use SkyVerge\WooCommerce\PluginFramework\v5_13_1\SV_WC_Plugin; +use SkyVerge\WooCommerce\PluginFramework\v5_13_1\SV_WC_Plugin_Compatibility; defined( 'ABSPATH' ) or exit; -if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_0\\Plugin\\Lifecycle' ) ) : +if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\Plugin\\Lifecycle' ) ) : /** diff --git a/woocommerce/Settings_API/Abstract_Settings.php b/woocommerce/Settings_API/Abstract_Settings.php index c6ed819a2..228c84d75 100644 --- a/woocommerce/Settings_API/Abstract_Settings.php +++ b/woocommerce/Settings_API/Abstract_Settings.php @@ -22,13 +22,13 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 */ -namespace SkyVerge\WooCommerce\PluginFramework\v5_13_0\Settings_API; +namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1\Settings_API; -use SkyVerge\WooCommerce\PluginFramework\v5_13_0 as Framework; +use SkyVerge\WooCommerce\PluginFramework\v5_13_1 as Framework; defined( 'ABSPATH' ) or exit; -if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_0\\Settings_API\\Abstract_Settings' ) ) : +if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\Settings_API\\Abstract_Settings' ) ) : /** diff --git a/woocommerce/Settings_API/Control.php b/woocommerce/Settings_API/Control.php index d85da7e59..57c91dc84 100644 --- a/woocommerce/Settings_API/Control.php +++ b/woocommerce/Settings_API/Control.php @@ -22,13 +22,13 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 */ -namespace SkyVerge\WooCommerce\PluginFramework\v5_13_0\Settings_API; +namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1\Settings_API; -use SkyVerge\WooCommerce\PluginFramework\v5_13_0 as Framework; +use SkyVerge\WooCommerce\PluginFramework\v5_13_1 as Framework; defined( 'ABSPATH' ) or exit; -if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_0\\Settings_API\\Control' ) ) : +if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\Settings_API\\Control' ) ) : /** diff --git a/woocommerce/Settings_API/Setting.php b/woocommerce/Settings_API/Setting.php index e6e317fd7..10d323d7b 100644 --- a/woocommerce/Settings_API/Setting.php +++ b/woocommerce/Settings_API/Setting.php @@ -22,13 +22,13 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 */ -namespace SkyVerge\WooCommerce\PluginFramework\v5_13_0\Settings_API; +namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1\Settings_API; -use SkyVerge\WooCommerce\PluginFramework\v5_13_0 as Framework; +use SkyVerge\WooCommerce\PluginFramework\v5_13_1 as Framework; defined( 'ABSPATH' ) or exit; -if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_0\\Settings_API\\Setting' ) ) : +if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\Settings_API\\Setting' ) ) : /** diff --git a/woocommerce/admin/Notes_Helper.php b/woocommerce/admin/Notes_Helper.php index 20bc4db63..d9fdaf6fb 100644 --- a/woocommerce/admin/Notes_Helper.php +++ b/woocommerce/admin/Notes_Helper.php @@ -21,13 +21,13 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 */ -namespace SkyVerge\WooCommerce\PluginFramework\v5_13_0\Admin; +namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1\Admin; use Automattic\WooCommerce\Admin\Notes as WooCommerce_Admin_Notes; defined( 'ABSPATH' ) or exit; -if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_0\\Admin\\Notes_Helper' ) ) : +if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\Admin\\Notes_Helper' ) ) : /** diff --git a/woocommerce/admin/abstract-sv-wc-plugin-admin-setup-wizard.php b/woocommerce/admin/abstract-sv-wc-plugin-admin-setup-wizard.php index bbe01be5c..709f264ff 100644 --- a/woocommerce/admin/abstract-sv-wc-plugin-admin-setup-wizard.php +++ b/woocommerce/admin/abstract-sv-wc-plugin-admin-setup-wizard.php @@ -21,13 +21,13 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 */ -namespace SkyVerge\WooCommerce\PluginFramework\v5_13_0\Admin; +namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1\Admin; defined( 'ABSPATH' ) or exit; -use SkyVerge\WooCommerce\PluginFramework\v5_13_0 as Framework; +use SkyVerge\WooCommerce\PluginFramework\v5_13_1 as Framework; -if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_0\\Admin\\Setup_Wizard' ) ) : +if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\Admin\\Setup_Wizard' ) ) : /** diff --git a/woocommerce/api/Abstract_Cacheable_API_Base.php b/woocommerce/api/Abstract_Cacheable_API_Base.php index 05e70b43c..7ced9d506 100644 --- a/woocommerce/api/Abstract_Cacheable_API_Base.php +++ b/woocommerce/api/Abstract_Cacheable_API_Base.php @@ -22,14 +22,14 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 */ -namespace SkyVerge\WooCommerce\PluginFramework\v5_13_0\API; +namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1\API; -use SkyVerge\WooCommerce\PluginFramework\v5_13_0\SV_WC_API_Base; -use SkyVerge\WooCommerce\PluginFramework\v5_13_0\API\Traits\Cacheable_Request_Trait; +use SkyVerge\WooCommerce\PluginFramework\v5_13_1\SV_WC_API_Base; +use SkyVerge\WooCommerce\PluginFramework\v5_13_1\API\Traits\Cacheable_Request_Trait; defined( 'ABSPATH' ) or exit; -if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_0\\API\\Abstract_Cacheable_API_Base' ) ) : +if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\API\\Abstract_Cacheable_API_Base' ) ) : /** diff --git a/woocommerce/api/abstract-sv-wc-api-json-request.php b/woocommerce/api/abstract-sv-wc-api-json-request.php index 30aefab07..3151e9916 100644 --- a/woocommerce/api/abstract-sv-wc-api-json-request.php +++ b/woocommerce/api/abstract-sv-wc-api-json-request.php @@ -22,11 +22,11 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 */ -namespace SkyVerge\WooCommerce\PluginFramework\v5_13_0; +namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1; defined( 'ABSPATH' ) or exit; -if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_0\\SV_WC_API_JSON_Request' ) ) : +if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\SV_WC_API_JSON_Request' ) ) : /** diff --git a/woocommerce/api/abstract-sv-wc-api-json-response.php b/woocommerce/api/abstract-sv-wc-api-json-response.php index e4be69c72..58ef9a41a 100644 --- a/woocommerce/api/abstract-sv-wc-api-json-response.php +++ b/woocommerce/api/abstract-sv-wc-api-json-response.php @@ -22,11 +22,11 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 */ -namespace SkyVerge\WooCommerce\PluginFramework\v5_13_0; +namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1; defined( 'ABSPATH' ) or exit; -if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_0\\SV_WC_API_JSON_Response' ) ) : +if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\SV_WC_API_JSON_Response' ) ) : /** diff --git a/woocommerce/api/abstract-sv-wc-api-xml-request.php b/woocommerce/api/abstract-sv-wc-api-xml-request.php index 35cc14fe6..973c0cec3 100644 --- a/woocommerce/api/abstract-sv-wc-api-xml-request.php +++ b/woocommerce/api/abstract-sv-wc-api-xml-request.php @@ -22,11 +22,11 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 */ -namespace SkyVerge\WooCommerce\PluginFramework\v5_13_0; +namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1; defined( 'ABSPATH' ) or exit; -if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_0\\SV_WC_API_XML_Request' ) ) : +if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\SV_WC_API_XML_Request' ) ) : /** diff --git a/woocommerce/api/abstract-sv-wc-api-xml-response.php b/woocommerce/api/abstract-sv-wc-api-xml-response.php index 48df8a40c..dde0df1f3 100644 --- a/woocommerce/api/abstract-sv-wc-api-xml-response.php +++ b/woocommerce/api/abstract-sv-wc-api-xml-response.php @@ -22,11 +22,11 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 */ -namespace SkyVerge\WooCommerce\PluginFramework\v5_13_0; +namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1; defined( 'ABSPATH' ) or exit; -if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_0\\SV_WC_API_XML_Response' ) ) : +if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\SV_WC_API_XML_Response' ) ) : /** diff --git a/woocommerce/api/class-sv-wc-api-base.php b/woocommerce/api/class-sv-wc-api-base.php index e3bb12f14..9acc26e2b 100644 --- a/woocommerce/api/class-sv-wc-api-base.php +++ b/woocommerce/api/class-sv-wc-api-base.php @@ -22,11 +22,11 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 */ -namespace SkyVerge\WooCommerce\PluginFramework\v5_13_0; +namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1; defined( 'ABSPATH' ) or exit; -if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_0\\SV_WC_API_Base' ) ) : +if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\SV_WC_API_Base' ) ) : /** diff --git a/woocommerce/api/class-sv-wc-api-exception.php b/woocommerce/api/class-sv-wc-api-exception.php index aab66fd8c..0bb3bf9ab 100644 --- a/woocommerce/api/class-sv-wc-api-exception.php +++ b/woocommerce/api/class-sv-wc-api-exception.php @@ -22,11 +22,11 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 */ -namespace SkyVerge\WooCommerce\PluginFramework\v5_13_0; +namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1; defined( 'ABSPATH' ) or exit; -if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_0\\SV_WC_API_Exception' ) ) : +if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\SV_WC_API_Exception' ) ) : /** diff --git a/woocommerce/api/interface-sv-wc-api-request.php b/woocommerce/api/interface-sv-wc-api-request.php index 633841f4a..77862105a 100644 --- a/woocommerce/api/interface-sv-wc-api-request.php +++ b/woocommerce/api/interface-sv-wc-api-request.php @@ -22,11 +22,11 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 */ -namespace SkyVerge\WooCommerce\PluginFramework\v5_13_0; +namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1; defined( 'ABSPATH' ) or exit; -if ( ! interface_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_0\\SV_WC_API_Request' ) ) : +if ( ! interface_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\SV_WC_API_Request' ) ) : /** diff --git a/woocommerce/api/interface-sv-wc-api-response.php b/woocommerce/api/interface-sv-wc-api-response.php index 02b6b5e08..0b403fc8c 100644 --- a/woocommerce/api/interface-sv-wc-api-response.php +++ b/woocommerce/api/interface-sv-wc-api-response.php @@ -22,11 +22,11 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 */ -namespace SkyVerge\WooCommerce\PluginFramework\v5_13_0; +namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1; defined( 'ABSPATH' ) or exit; -if ( ! interface_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_0\\SV_WC_API_Response' ) ) : +if ( ! interface_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\SV_WC_API_Response' ) ) : /** diff --git a/woocommerce/api/traits/Cacheable_Request_Trait.php b/woocommerce/api/traits/Cacheable_Request_Trait.php index aa450a022..e60126a37 100644 --- a/woocommerce/api/traits/Cacheable_Request_Trait.php +++ b/woocommerce/api/traits/Cacheable_Request_Trait.php @@ -22,11 +22,11 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 */ -namespace SkyVerge\WooCommerce\PluginFramework\v5_13_0\API\Traits; +namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1\API\Traits; defined( 'ABSPATH' ) or exit; -if ( ! trait_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_0\\API\\Traits\\Cacheable_Request_Trait' ) ) : +if ( ! trait_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\API\\Traits\\Cacheable_Request_Trait' ) ) : /** diff --git a/woocommerce/class-sv-wc-admin-notice-handler.php b/woocommerce/class-sv-wc-admin-notice-handler.php index 619e61528..42633163c 100644 --- a/woocommerce/class-sv-wc-admin-notice-handler.php +++ b/woocommerce/class-sv-wc-admin-notice-handler.php @@ -22,11 +22,11 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 */ -namespace SkyVerge\WooCommerce\PluginFramework\v5_13_0; +namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1; defined( 'ABSPATH' ) or exit; -if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_0\\SV_WC_Admin_Notice_Handler' ) ) : +if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\SV_WC_Admin_Notice_Handler' ) ) : /** diff --git a/woocommerce/class-sv-wc-helper.php b/woocommerce/class-sv-wc-helper.php index cf1c92aa6..8d0a3a1ba 100644 --- a/woocommerce/class-sv-wc-helper.php +++ b/woocommerce/class-sv-wc-helper.php @@ -22,11 +22,11 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 */ -namespace SkyVerge\WooCommerce\PluginFramework\v5_13_0; +namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1; defined( 'ABSPATH' ) or exit; -if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_0\\SV_WC_Helper' ) ) : +if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\SV_WC_Helper' ) ) : /** diff --git a/woocommerce/class-sv-wc-hook-deprecator.php b/woocommerce/class-sv-wc-hook-deprecator.php index 3384b738c..4a4430242 100644 --- a/woocommerce/class-sv-wc-hook-deprecator.php +++ b/woocommerce/class-sv-wc-hook-deprecator.php @@ -22,11 +22,11 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 */ -namespace SkyVerge\WooCommerce\PluginFramework\v5_13_0; +namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1; defined( 'ABSPATH' ) or exit; -if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_0\\SV_WC_Hook_Deprecator' ) ) : +if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\SV_WC_Hook_Deprecator' ) ) : /** diff --git a/woocommerce/class-sv-wc-plugin-compatibility.php b/woocommerce/class-sv-wc-plugin-compatibility.php index 85f028ef6..9391aadbe 100644 --- a/woocommerce/class-sv-wc-plugin-compatibility.php +++ b/woocommerce/class-sv-wc-plugin-compatibility.php @@ -22,13 +22,13 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 */ -namespace SkyVerge\WooCommerce\PluginFramework\v5_13_0; +namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1; use Automattic\WooCommerce\Utilities\OrderUtil; defined( 'ABSPATH' ) or exit; -if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_0\\SV_WC_Plugin_Compatibility' ) ) : +if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\SV_WC_Plugin_Compatibility' ) ) : /** diff --git a/woocommerce/class-sv-wc-plugin-dependencies.php b/woocommerce/class-sv-wc-plugin-dependencies.php index 4b719564c..fd4a0c2a0 100644 --- a/woocommerce/class-sv-wc-plugin-dependencies.php +++ b/woocommerce/class-sv-wc-plugin-dependencies.php @@ -22,11 +22,11 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 */ -namespace SkyVerge\WooCommerce\PluginFramework\v5_13_0; +namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1; defined( 'ABSPATH' ) or exit; -if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_0\\SV_WC_Plugin_Dependencies' ) ) : +if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\SV_WC_Plugin_Dependencies' ) ) : /** diff --git a/woocommerce/class-sv-wc-plugin-exception.php b/woocommerce/class-sv-wc-plugin-exception.php index b4cacc6b8..1056115d4 100644 --- a/woocommerce/class-sv-wc-plugin-exception.php +++ b/woocommerce/class-sv-wc-plugin-exception.php @@ -22,11 +22,11 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 */ -namespace SkyVerge\WooCommerce\PluginFramework\v5_13_0; +namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1; defined( 'ABSPATH' ) or exit; -if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_0\\SV_WC_Plugin_Exception' ) ) : +if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\SV_WC_Plugin_Exception' ) ) : /** diff --git a/woocommerce/class-sv-wc-plugin.php b/woocommerce/class-sv-wc-plugin.php index 8cd26d2df..0de1e18c1 100644 --- a/woocommerce/class-sv-wc-plugin.php +++ b/woocommerce/class-sv-wc-plugin.php @@ -22,14 +22,14 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 */ -namespace SkyVerge\WooCommerce\PluginFramework\v5_13_0; +namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1; use Automattic\WooCommerce\Utilities\FeaturesUtil; use stdClass; defined( 'ABSPATH' ) or exit; -if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_0\\SV_WC_Plugin' ) ) : +if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\SV_WC_Plugin' ) ) : /** diff --git a/woocommerce/class-sv-wp-admin-message-handler.php b/woocommerce/class-sv-wp-admin-message-handler.php index 2ec29dcbc..030184e3f 100644 --- a/woocommerce/class-sv-wp-admin-message-handler.php +++ b/woocommerce/class-sv-wp-admin-message-handler.php @@ -22,11 +22,11 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 */ -namespace SkyVerge\WooCommerce\PluginFramework\v5_13_0; +namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1; defined( 'ABSPATH' ) or exit; -if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_0\\SV_WP_Admin_Message_Handler' ) ) : +if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\SV_WP_Admin_Message_Handler' ) ) : /** diff --git a/woocommerce/compatibility/abstract-sv-wc-data-compatibility.php b/woocommerce/compatibility/abstract-sv-wc-data-compatibility.php index 5e43bf165..c5848db94 100644 --- a/woocommerce/compatibility/abstract-sv-wc-data-compatibility.php +++ b/woocommerce/compatibility/abstract-sv-wc-data-compatibility.php @@ -22,11 +22,11 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 */ -namespace SkyVerge\WooCommerce\PluginFramework\v5_13_0; +namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1; defined( 'ABSPATH' ) or exit; -if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_0\\SV_WC_Data_Compatibility' ) ) : +if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\SV_WC_Data_Compatibility' ) ) : /** diff --git a/woocommerce/compatibility/class-sv-wc-order-compatibility.php b/woocommerce/compatibility/class-sv-wc-order-compatibility.php index 5a89d0d87..046dd1efd 100644 --- a/woocommerce/compatibility/class-sv-wc-order-compatibility.php +++ b/woocommerce/compatibility/class-sv-wc-order-compatibility.php @@ -22,7 +22,7 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 */ -namespace SkyVerge\WooCommerce\PluginFramework\v5_13_0; +namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1; use Automattic\WooCommerce\Admin\Overrides\Order; use Automattic\WooCommerce\Internal\Admin\Orders\PageController; @@ -32,7 +32,7 @@ defined( 'ABSPATH' ) or exit; -if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_0\\SV_WC_Order_Compatibility' ) ) : +if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\SV_WC_Order_Compatibility' ) ) : /** diff --git a/woocommerce/compatibility/class-sv-wc-subscription-compatibility.php b/woocommerce/compatibility/class-sv-wc-subscription-compatibility.php index 98eb4076a..da32e6bf7 100644 --- a/woocommerce/compatibility/class-sv-wc-subscription-compatibility.php +++ b/woocommerce/compatibility/class-sv-wc-subscription-compatibility.php @@ -22,11 +22,11 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 */ -namespace SkyVerge\WooCommerce\PluginFramework\v5_13_0; +namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1; defined( 'ABSPATH' ) or exit; -if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_0\\SV_WC_Subscription_Compatibility' ) ) : +if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\SV_WC_Subscription_Compatibility' ) ) : /** * WooCommerce subscription compatibility class. diff --git a/woocommerce/payment-gateway/Blocks/Gateway_Blocks_Handler.php b/woocommerce/payment-gateway/Blocks/Gateway_Blocks_Handler.php index 7387c8e13..7b73d05fa 100644 --- a/woocommerce/payment-gateway/Blocks/Gateway_Blocks_Handler.php +++ b/woocommerce/payment-gateway/Blocks/Gateway_Blocks_Handler.php @@ -1,16 +1,16 @@ get_handler()->get_plugin()->get_payment_gateway_framework_assets_url() . '/css/frontend/sv-wc-payment-gateway-external-checkout.css', array(), $this->get_handler()->get_plugin()->get_version() ); // TODO: min + wp_enqueue_style( 'sv-wc-external-checkout-v5_13_1', $this->get_handler()->get_plugin()->get_payment_gateway_framework_assets_url() . '/css/frontend/sv-wc-payment-gateway-external-checkout.css', array(), $this->get_handler()->get_plugin()->get_version() ); // TODO: min } diff --git a/woocommerce/payment-gateway/External_Checkout/Google_Pay/AJAX.php b/woocommerce/payment-gateway/External_Checkout/Google_Pay/AJAX.php index 24e5ef317..9175190ee 100644 --- a/woocommerce/payment-gateway/External_Checkout/Google_Pay/AJAX.php +++ b/woocommerce/payment-gateway/External_Checkout/Google_Pay/AJAX.php @@ -22,14 +22,14 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 */ -namespace SkyVerge\WooCommerce\PluginFramework\v5_13_0\Payment_Gateway\External_Checkout\Google_Pay; +namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1\Payment_Gateway\External_Checkout\Google_Pay; -use SkyVerge\WooCommerce\PluginFramework\v5_13_0\SV_WC_Helper; -use SkyVerge\WooCommerce\PluginFramework\v5_13_0\SV_WC_Payment_Gateway_Exception; +use SkyVerge\WooCommerce\PluginFramework\v5_13_1\SV_WC_Helper; +use SkyVerge\WooCommerce\PluginFramework\v5_13_1\SV_WC_Payment_Gateway_Exception; defined( 'ABSPATH' ) or exit; -if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_0\\Payment_Gateway\\External_Checkout\\Google_Pay\\AJAX' ) ) : +if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\Payment_Gateway\\External_Checkout\\Google_Pay\\AJAX' ) ) : /** diff --git a/woocommerce/payment-gateway/External_Checkout/Google_Pay/Admin.php b/woocommerce/payment-gateway/External_Checkout/Google_Pay/Admin.php index a7e5412f7..483274c4d 100755 --- a/woocommerce/payment-gateway/External_Checkout/Google_Pay/Admin.php +++ b/woocommerce/payment-gateway/External_Checkout/Google_Pay/Admin.php @@ -22,13 +22,13 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 */ -namespace SkyVerge\WooCommerce\PluginFramework\v5_13_0\Payment_Gateway\External_Checkout\Google_Pay; +namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1\Payment_Gateway\External_Checkout\Google_Pay; -use SkyVerge\WooCommerce\PluginFramework\v5_13_0\SV_WC_Helper; +use SkyVerge\WooCommerce\PluginFramework\v5_13_1\SV_WC_Helper; defined( 'ABSPATH' ) or exit; -if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_0\\Payment_Gateway\\External_Checkout\\Google_Pay\\Admin' ) ) : +if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\Payment_Gateway\\External_Checkout\\Google_Pay\\Admin' ) ) : /** @@ -37,7 +37,7 @@ * @since 5.10.0 */ #[\AllowDynamicProperties] -class Admin extends \SkyVerge\WooCommerce\PluginFramework\v5_13_0\Payment_Gateway\External_Checkout\Admin { +class Admin extends \SkyVerge\WooCommerce\PluginFramework\v5_13_1\Payment_Gateway\External_Checkout\Admin { /** @var Google_Pay the Google Pay handler instance */ diff --git a/woocommerce/payment-gateway/External_Checkout/Google_Pay/Frontend.php b/woocommerce/payment-gateway/External_Checkout/Google_Pay/Frontend.php index 05bf37632..654b2fb13 100644 --- a/woocommerce/payment-gateway/External_Checkout/Google_Pay/Frontend.php +++ b/woocommerce/payment-gateway/External_Checkout/Google_Pay/Frontend.php @@ -22,14 +22,14 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 */ -namespace SkyVerge\WooCommerce\PluginFramework\v5_13_0\Payment_Gateway\External_Checkout\Google_Pay; +namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1\Payment_Gateway\External_Checkout\Google_Pay; -use SkyVerge\WooCommerce\PluginFramework\v5_13_0\SV_WC_Payment_Gateway_Exception; -use SkyVerge\WooCommerce\PluginFramework\v5_13_0\SV_WC_Payment_Gateway_Plugin; +use SkyVerge\WooCommerce\PluginFramework\v5_13_1\SV_WC_Payment_Gateway_Exception; +use SkyVerge\WooCommerce\PluginFramework\v5_13_1\SV_WC_Payment_Gateway_Plugin; defined( 'ABSPATH' ) or exit; -if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_0\\Payment_Gateway\\External_Checkout\\Google_Pay\\Frontend' ) ) : +if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\Payment_Gateway\\External_Checkout\\Google_Pay\\Frontend' ) ) : /** @@ -38,7 +38,7 @@ * @since 5.10.0 */ #[\AllowDynamicProperties] -class Frontend extends \SkyVerge\WooCommerce\PluginFramework\v5_13_0\Payment_Gateway\External_Checkout\Frontend { +class Frontend extends \SkyVerge\WooCommerce\PluginFramework\v5_13_1\Payment_Gateway\External_Checkout\Frontend { /** @var string JS handler base class name, without the FW version */ @@ -102,7 +102,7 @@ public function enqueue_scripts() { $version = $gateway->get_plugin()->get_assets_version( $gateway->get_id() ); wp_enqueue_script( 'google-pay-js-library', 'https://pay.google.com/gp/p/js/pay.js', [], $version, true ); - wp_enqueue_script( 'sv-wc-google-pay-v5_13_0', $this->get_plugin()->get_payment_gateway_framework_assets_url() . '/dist/frontend/sv-wc-payment-gateway-google-pay.js', [ 'google-pay-js-library', 'jquery' ], $version, true ); + wp_enqueue_script( 'sv-wc-google-pay-v5_13_1', $this->get_plugin()->get_payment_gateway_framework_assets_url() . '/dist/frontend/sv-wc-payment-gateway-google-pay.js', [ 'google-pay-js-library', 'jquery' ], $version, true ); } diff --git a/woocommerce/payment-gateway/External_Checkout/Google_Pay/Google_Pay.php b/woocommerce/payment-gateway/External_Checkout/Google_Pay/Google_Pay.php index 3debc1140..4530f424e 100755 --- a/woocommerce/payment-gateway/External_Checkout/Google_Pay/Google_Pay.php +++ b/woocommerce/payment-gateway/External_Checkout/Google_Pay/Google_Pay.php @@ -22,17 +22,17 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 */ -namespace SkyVerge\WooCommerce\PluginFramework\v5_13_0\Payment_Gateway\External_Checkout\Google_Pay; +namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1\Payment_Gateway\External_Checkout\Google_Pay; -use SkyVerge\WooCommerce\PluginFramework\v5_13_0\Payment_Gateway\External_Checkout\External_Checkout; -use SkyVerge\WooCommerce\PluginFramework\v5_13_0\Payment_Gateway\External_Checkout\Orders; -use SkyVerge\WooCommerce\PluginFramework\v5_13_0\SV_WC_Payment_Gateway_Exception; -use SkyVerge\WooCommerce\PluginFramework\v5_13_0\SV_WC_Payment_Gateway_Helper; -use SkyVerge\WooCommerce\PluginFramework\v5_13_0\SV_WC_Payment_Gateway_Plugin; +use SkyVerge\WooCommerce\PluginFramework\v5_13_1\Payment_Gateway\External_Checkout\External_Checkout; +use SkyVerge\WooCommerce\PluginFramework\v5_13_1\Payment_Gateway\External_Checkout\Orders; +use SkyVerge\WooCommerce\PluginFramework\v5_13_1\SV_WC_Payment_Gateway_Exception; +use SkyVerge\WooCommerce\PluginFramework\v5_13_1\SV_WC_Payment_Gateway_Helper; +use SkyVerge\WooCommerce\PluginFramework\v5_13_1\SV_WC_Payment_Gateway_Plugin; defined( 'ABSPATH' ) or exit; -if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_0\\Payment_Gateway\\External_Checkout\\Google_Pay\\Google_Pay' ) ) : +if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\Payment_Gateway\\External_Checkout\\Google_Pay\\Google_Pay' ) ) : /** @@ -677,7 +677,7 @@ public function get_supported_networks() { $accepted_card_types = ( $this->get_processing_gateway() ) ? $this->get_processing_gateway()->get_card_types() : []; - $accepted_card_types = array_map( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_0\\SV_WC_Payment_Gateway_Helper::normalize_card_type', $accepted_card_types ); + $accepted_card_types = array_map( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\SV_WC_Payment_Gateway_Helper::normalize_card_type', $accepted_card_types ); $valid_networks = [ SV_WC_Payment_Gateway_Helper::CARD_TYPE_AMEX => 'AMEX', diff --git a/woocommerce/payment-gateway/External_Checkout/Orders.php b/woocommerce/payment-gateway/External_Checkout/Orders.php index 8f4c7ed1d..11b1899ee 100644 --- a/woocommerce/payment-gateway/External_Checkout/Orders.php +++ b/woocommerce/payment-gateway/External_Checkout/Orders.php @@ -22,9 +22,9 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 */ -namespace SkyVerge\WooCommerce\PluginFramework\v5_13_0\Payment_Gateway\External_Checkout; +namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1\Payment_Gateway\External_Checkout; -use SkyVerge\WooCommerce\PluginFramework\v5_13_0 as Framework; +use SkyVerge\WooCommerce\PluginFramework\v5_13_1 as Framework; defined( 'ABSPATH' ) or exit; diff --git a/woocommerce/payment-gateway/External_Checkout/apple-pay/api/class-sv-wc-payment-gateway-apple-pay-api-request.php b/woocommerce/payment-gateway/External_Checkout/apple-pay/api/class-sv-wc-payment-gateway-apple-pay-api-request.php index 5d95f0ca3..9f2052738 100644 --- a/woocommerce/payment-gateway/External_Checkout/apple-pay/api/class-sv-wc-payment-gateway-apple-pay-api-request.php +++ b/woocommerce/payment-gateway/External_Checkout/apple-pay/api/class-sv-wc-payment-gateway-apple-pay-api-request.php @@ -22,11 +22,11 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 */ -namespace SkyVerge\WooCommerce\PluginFramework\v5_13_0; +namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1; defined( 'ABSPATH' ) or exit; -if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_0\\SV_WC_Payment_Gateway_Apple_Pay_API_Request' ) ) : +if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\SV_WC_Payment_Gateway_Apple_Pay_API_Request' ) ) : /** diff --git a/woocommerce/payment-gateway/External_Checkout/apple-pay/api/class-sv-wc-payment-gateway-apple-pay-api-response.php b/woocommerce/payment-gateway/External_Checkout/apple-pay/api/class-sv-wc-payment-gateway-apple-pay-api-response.php index daf3507df..247519b14 100644 --- a/woocommerce/payment-gateway/External_Checkout/apple-pay/api/class-sv-wc-payment-gateway-apple-pay-api-response.php +++ b/woocommerce/payment-gateway/External_Checkout/apple-pay/api/class-sv-wc-payment-gateway-apple-pay-api-response.php @@ -22,11 +22,11 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 */ -namespace SkyVerge\WooCommerce\PluginFramework\v5_13_0; +namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1; defined( 'ABSPATH' ) or exit; -if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_0\\SV_WC_Payment_Gateway_Apple_Pay_API_Response' ) ) : +if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\SV_WC_Payment_Gateway_Apple_Pay_API_Response' ) ) : /** diff --git a/woocommerce/payment-gateway/External_Checkout/apple-pay/api/class-sv-wc-payment-gateway-apple-pay-api.php b/woocommerce/payment-gateway/External_Checkout/apple-pay/api/class-sv-wc-payment-gateway-apple-pay-api.php index 94fe20438..e4f0a9f73 100644 --- a/woocommerce/payment-gateway/External_Checkout/apple-pay/api/class-sv-wc-payment-gateway-apple-pay-api.php +++ b/woocommerce/payment-gateway/External_Checkout/apple-pay/api/class-sv-wc-payment-gateway-apple-pay-api.php @@ -22,11 +22,11 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 */ -namespace SkyVerge\WooCommerce\PluginFramework\v5_13_0; +namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1; defined( 'ABSPATH' ) or exit; -if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_0\\SV_WC_Payment_Gateway_Apple_Pay_API' ) ) : +if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\SV_WC_Payment_Gateway_Apple_Pay_API' ) ) : /** @@ -58,7 +58,7 @@ public function __construct( SV_WC_Payment_Gateway $gateway ) { $this->set_request_content_type_header( 'application/json' ); $this->set_request_accept_header( 'application/json' ); - $this->set_response_handler( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_0\\SV_WC_Payment_Gateway_Apple_Pay_API_Response' ); + $this->set_response_handler( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\SV_WC_Payment_Gateway_Apple_Pay_API_Response' ); } diff --git a/woocommerce/payment-gateway/External_Checkout/apple-pay/api/class-sv-wc-payment-gateway-apple-pay-payment-response.php b/woocommerce/payment-gateway/External_Checkout/apple-pay/api/class-sv-wc-payment-gateway-apple-pay-payment-response.php index 2b60aca7e..3d4199cd8 100644 --- a/woocommerce/payment-gateway/External_Checkout/apple-pay/api/class-sv-wc-payment-gateway-apple-pay-payment-response.php +++ b/woocommerce/payment-gateway/External_Checkout/apple-pay/api/class-sv-wc-payment-gateway-apple-pay-payment-response.php @@ -22,11 +22,11 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 */ -namespace SkyVerge\WooCommerce\PluginFramework\v5_13_0; +namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1; defined( 'ABSPATH' ) or exit; -if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_0\\SV_WC_Payment_Gateway_Apple_Pay_Payment_Response' ) ) : +if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\SV_WC_Payment_Gateway_Apple_Pay_Payment_Response' ) ) : /** diff --git a/woocommerce/payment-gateway/External_Checkout/apple-pay/class-sv-wc-payment-gateway-apple-pay-admin.php b/woocommerce/payment-gateway/External_Checkout/apple-pay/class-sv-wc-payment-gateway-apple-pay-admin.php index bf002af18..a4f7b4301 100755 --- a/woocommerce/payment-gateway/External_Checkout/apple-pay/class-sv-wc-payment-gateway-apple-pay-admin.php +++ b/woocommerce/payment-gateway/External_Checkout/apple-pay/class-sv-wc-payment-gateway-apple-pay-admin.php @@ -22,13 +22,13 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 */ -namespace SkyVerge\WooCommerce\PluginFramework\v5_13_0; +namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1; -use SkyVerge\WooCommerce\PluginFramework\v5_13_0\Payment_Gateway\External_Checkout\Admin; +use SkyVerge\WooCommerce\PluginFramework\v5_13_1\Payment_Gateway\External_Checkout\Admin; defined( 'ABSPATH' ) or exit; -if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_0\\SV_WC_Payment_Gateway_Apple_Pay_Admin' ) ) : +if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\SV_WC_Payment_Gateway_Apple_Pay_Admin' ) ) : /** diff --git a/woocommerce/payment-gateway/External_Checkout/apple-pay/class-sv-wc-payment-gateway-apple-pay-ajax.php b/woocommerce/payment-gateway/External_Checkout/apple-pay/class-sv-wc-payment-gateway-apple-pay-ajax.php index 8aade165f..fae8e57e6 100644 --- a/woocommerce/payment-gateway/External_Checkout/apple-pay/class-sv-wc-payment-gateway-apple-pay-ajax.php +++ b/woocommerce/payment-gateway/External_Checkout/apple-pay/class-sv-wc-payment-gateway-apple-pay-ajax.php @@ -22,11 +22,11 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 */ -namespace SkyVerge\WooCommerce\PluginFramework\v5_13_0; +namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1; defined( 'ABSPATH' ) or exit; -if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_0\\SV_WC_Payment_Gateway_Apple_Pay_AJAX' ) ) : +if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\SV_WC_Payment_Gateway_Apple_Pay_AJAX' ) ) : /** diff --git a/woocommerce/payment-gateway/External_Checkout/apple-pay/class-sv-wc-payment-gateway-apple-pay-frontend.php b/woocommerce/payment-gateway/External_Checkout/apple-pay/class-sv-wc-payment-gateway-apple-pay-frontend.php index bb3c427e2..6a3a92d6b 100644 --- a/woocommerce/payment-gateway/External_Checkout/apple-pay/class-sv-wc-payment-gateway-apple-pay-frontend.php +++ b/woocommerce/payment-gateway/External_Checkout/apple-pay/class-sv-wc-payment-gateway-apple-pay-frontend.php @@ -22,11 +22,11 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 */ -namespace SkyVerge\WooCommerce\PluginFramework\v5_13_0; +namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1; defined( 'ABSPATH' ) or exit; -if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_0\\SV_WC_Payment_Gateway_Apple_Pay_Frontend' ) ) : +if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\SV_WC_Payment_Gateway_Apple_Pay_Frontend' ) ) : /** @@ -35,7 +35,7 @@ * @since 4.7.0 */ #[\AllowDynamicProperties] -class SV_WC_Payment_Gateway_Apple_Pay_Frontend extends \SkyVerge\WooCommerce\PluginFramework\v5_13_0\Payment_Gateway\External_Checkout\Frontend { +class SV_WC_Payment_Gateway_Apple_Pay_Frontend extends \SkyVerge\WooCommerce\PluginFramework\v5_13_1\Payment_Gateway\External_Checkout\Frontend { /** @var string JS handler base class name, without the FW version */ @@ -116,9 +116,9 @@ public function enqueue_scripts() { $gateway = $this->get_gateway(); $version = $gateway->get_plugin()->get_assets_version( $gateway->get_id() ); - wp_enqueue_style( 'sv-wc-apple-pay-v5_13_0', $this->get_plugin()->get_payment_gateway_framework_assets_url() . '/css/frontend/sv-wc-payment-gateway-apple-pay.css', [], $version ); // TODO: min + wp_enqueue_style( 'sv-wc-apple-pay-v5_13_1', $this->get_plugin()->get_payment_gateway_framework_assets_url() . '/css/frontend/sv-wc-payment-gateway-apple-pay.css', [], $version ); // TODO: min - wp_enqueue_script( 'sv-wc-apple-pay-v5_13_0', $this->get_plugin()->get_payment_gateway_framework_assets_url() . '/dist/frontend/sv-wc-payment-gateway-apple-pay.js', [ 'jquery' ], $version, true ); + wp_enqueue_script( 'sv-wc-apple-pay-v5_13_1', $this->get_plugin()->get_payment_gateway_framework_assets_url() . '/dist/frontend/sv-wc-payment-gateway-apple-pay.js', [ 'jquery' ], $version, true ); } diff --git a/woocommerce/payment-gateway/External_Checkout/apple-pay/class-sv-wc-payment-gateway-apple-pay.php b/woocommerce/payment-gateway/External_Checkout/apple-pay/class-sv-wc-payment-gateway-apple-pay.php index e609ddbf5..14669170f 100755 --- a/woocommerce/payment-gateway/External_Checkout/apple-pay/class-sv-wc-payment-gateway-apple-pay.php +++ b/woocommerce/payment-gateway/External_Checkout/apple-pay/class-sv-wc-payment-gateway-apple-pay.php @@ -22,13 +22,13 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 */ -namespace SkyVerge\WooCommerce\PluginFramework\v5_13_0; +namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1; -use SkyVerge\WooCommerce\PluginFramework\v5_13_0\Payment_Gateway\External_Checkout\Orders; +use SkyVerge\WooCommerce\PluginFramework\v5_13_1\Payment_Gateway\External_Checkout\Orders; defined( 'ABSPATH' ) or exit; -if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_0\\SV_WC_Payment_Gateway_Apple_Pay' ) ) : +if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\SV_WC_Payment_Gateway_Apple_Pay' ) ) : /** @@ -942,7 +942,7 @@ public function get_supported_networks() { $accepted_card_types = ( $this->get_processing_gateway() ) ? $this->get_processing_gateway()->get_card_types() : array(); - $accepted_card_types = array_map( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_0\\SV_WC_Payment_Gateway_Helper::normalize_card_type', $accepted_card_types ); + $accepted_card_types = array_map( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\SV_WC_Payment_Gateway_Helper::normalize_card_type', $accepted_card_types ); $valid_networks = array( SV_WC_Payment_Gateway_Helper::CARD_TYPE_AMEX => 'amex', diff --git a/woocommerce/payment-gateway/Handlers/Abstract_Hosted_Payment_Handler.php b/woocommerce/payment-gateway/Handlers/Abstract_Hosted_Payment_Handler.php index 4be455972..bc627bece 100644 --- a/woocommerce/payment-gateway/Handlers/Abstract_Hosted_Payment_Handler.php +++ b/woocommerce/payment-gateway/Handlers/Abstract_Hosted_Payment_Handler.php @@ -22,11 +22,11 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 */ -namespace SkyVerge\WooCommerce\PluginFramework\v5_13_0\Payment_Gateway\Handlers; +namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1\Payment_Gateway\Handlers; -use SkyVerge\WooCommerce\PluginFramework\v5_13_0 as FrameworkBase; +use SkyVerge\WooCommerce\PluginFramework\v5_13_1 as FrameworkBase; -if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_0\\Payment_Gateway\\Handlers\\Abstract_Hosted_Payment_Handler' ) ) : +if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\Payment_Gateway\\Handlers\\Abstract_Hosted_Payment_Handler' ) ) : /** diff --git a/woocommerce/payment-gateway/Handlers/Abstract_Payment_Handler.php b/woocommerce/payment-gateway/Handlers/Abstract_Payment_Handler.php index 7daf87986..11938640c 100644 --- a/woocommerce/payment-gateway/Handlers/Abstract_Payment_Handler.php +++ b/woocommerce/payment-gateway/Handlers/Abstract_Payment_Handler.php @@ -22,11 +22,11 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 */ -namespace SkyVerge\WooCommerce\PluginFramework\v5_13_0\Payment_Gateway\Handlers; +namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1\Payment_Gateway\Handlers; -use SkyVerge\WooCommerce\PluginFramework\v5_13_0 as FrameworkBase; +use SkyVerge\WooCommerce\PluginFramework\v5_13_1 as FrameworkBase; -if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_0\\Payment_Gateway\\Handlers\\Abstract_Payment_Handler' ) ) : +if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\Payment_Gateway\\Handlers\\Abstract_Payment_Handler' ) ) : /** diff --git a/woocommerce/payment-gateway/Handlers/Capture.php b/woocommerce/payment-gateway/Handlers/Capture.php index edb9aa765..0a3e1b1ab 100644 --- a/woocommerce/payment-gateway/Handlers/Capture.php +++ b/woocommerce/payment-gateway/Handlers/Capture.php @@ -22,13 +22,13 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 */ -namespace SkyVerge\WooCommerce\PluginFramework\v5_13_0\Payment_Gateway\Handlers; +namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1\Payment_Gateway\Handlers; -use SkyVerge\WooCommerce\PluginFramework\v5_13_0 as Framework; +use SkyVerge\WooCommerce\PluginFramework\v5_13_1 as Framework; defined( 'ABSPATH' ) or exit; -if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_0\\Payment_Gateway\\Handlers\\Capture' ) ) : +if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\Payment_Gateway\\Handlers\\Capture' ) ) : /** diff --git a/woocommerce/payment-gateway/PaymentFormContextChecker.php b/woocommerce/payment-gateway/PaymentFormContextChecker.php index 78e90b8e2..98b96bab6 100644 --- a/woocommerce/payment-gateway/PaymentFormContextChecker.php +++ b/woocommerce/payment-gateway/PaymentFormContextChecker.php @@ -1,8 +1,8 @@ 0&&void 0!==arguments[0]?arguments[0]:{};return this.block_ui(),this.get_payment_request(n).then(function(n){return e(t.button).show(),e(t.wrapper).show(),t.payment_request=JSON.parse(n),t.unblock_ui()},function(n){return console.error("[Apple Pay] Could not build payment request. "+n.message),e(t.button).hide(),1===e(t.container).children().length&&e(t.wrapper).hide(),t.unblock_ui()})}},{key:"get_payment_request",value:function(t){var n=this;return new Promise(function(i,o){var a;return a={action:"wc_".concat(n.gateway_id,"_apple_pay_get_payment_request")},e.extend(t,a),e.post(n.ajax_url,t,function(e){return e.success?i(e.data):o(e.data)})})}},{key:"render_errors",value:function(t){return e(".woocommerce-error, .woocommerce-message").remove(),this.ui_element.prepend('"),this.ui_element.removeClass("processing").unblock(),e("html, body").animate({scrollTop:this.ui_element.offset().top-100},1e3)}},{key:"block_ui",value:function(){return this.ui_element.block({message:null,overlayCSS:{background:"#fff",opacity:.6}})}},{key:"unblock_ui",value:function(){return this.ui_element.unblock()}}])}(),e(document.body).trigger("sv_wc_apple_pay_handler_v5_13_0_loaded")})}).call(this); +function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(t)}function t(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function n(e,t){for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:{};return this.block_ui(),this.get_payment_request(n).then(function(n){return e(t.button).show(),e(t.wrapper).show(),t.payment_request=JSON.parse(n),t.unblock_ui()},function(n){return console.error("[Apple Pay] Could not build payment request. "+n.message),e(t.button).hide(),1===e(t.container).children().length&&e(t.wrapper).hide(),t.unblock_ui()})}},{key:"get_payment_request",value:function(t){var n=this;return new Promise(function(i,o){var a;return a={action:"wc_".concat(n.gateway_id,"_apple_pay_get_payment_request")},e.extend(t,a),e.post(n.ajax_url,t,function(e){return e.success?i(e.data):o(e.data)})})}},{key:"render_errors",value:function(t){return e(".woocommerce-error, .woocommerce-message").remove(),this.ui_element.prepend('
  • '+t.join("
  • ")+"
"),this.ui_element.removeClass("processing").unblock(),e("html, body").animate({scrollTop:this.ui_element.offset().top-100},1e3)}},{key:"block_ui",value:function(){return this.ui_element.block({message:null,overlayCSS:{background:"#fff",opacity:.6}})}},{key:"unblock_ui",value:function(){return this.ui_element.unblock()}}])}(),e(document.body).trigger("sv_wc_apple_pay_handler_v5_13_1_loaded")})}).call(this); },{}]},{},["L57g"], null) -//# sourceMappingURL=../frontend/sv-wc-payment-gateway-apple-pay.js.map \ No newline at end of file +//# sourceMappingURL=../frontend/sv-wc-payment-gateway-apple-pay.js.map diff --git a/woocommerce/payment-gateway/assets/dist/frontend/sv-wc-payment-gateway-apple-pay.js.map b/woocommerce/payment-gateway/assets/dist/frontend/sv-wc-payment-gateway-apple-pay.js.map index b6c202f57..29b0484b0 100644 --- a/woocommerce/payment-gateway/assets/dist/frontend/sv-wc-payment-gateway-apple-pay.js.map +++ b/woocommerce/payment-gateway/assets/dist/frontend/sv-wc-payment-gateway-apple-pay.js.map @@ -1 +1 @@ -{"version":3,"sources":["frontend/sv-wc-payment-gateway-apple-pay.coffee"],"names":["jQuery","$","window","SV_WC_Apple_Pay_Handler_v5_13_0","args","init_product_page","bind","init_cart_page","init_checkout_page","on_validate_merchant","validate_merchant","on_payment_method_selected","on_shipping_contact_selected","on_shipping_method_selected","on_payment_authorized","process_authorization","on_cancel_payment","reset_payment_request","get_payment_request","gateway_id","gateway_slug","merchant_id","ajax_url","validate_nonce","recalculate_totals_nonce","process_nonce","payment_request","generic_error","wrapper","container","button","ApplePaySession","canMakePaymentsWithActiveCard","then","canMakePayments","children","length","hide","is_available","ui_element","show","document","body","on","e","error","preventDefault","block_ui","session","get_new_session","onvalidatemerchant","event","onpaymentmethodselected","onshippingcontactselected","onshippingmethodselected","onpaymentauthorized","oncancel","begin","error1","fail_payment","parents","get_sdk_version","validationURL","merchant_session","JSON","parse","completeMerchantValidation","response","abort","message","url","Promise","resolve","reject","data","post","success","completePaymentMethodSelection","total","line_items","console","lineItems","shippingContact","completeShippingContactSelection","STATUS_SUCCESS","shipping_methods","STATUS_FAILURE","shippingMethod","identifier","completeShippingMethodSelection","payment","set_payment_status","complete_purchase","action","nonce","stringify","unblock_ui","location","redirect","render_errors","status","completePayment","base_data","extend","errors","remove","prepend","join","removeClass","unblock","animate","scrollTop","offset","top","block","overlayCSS","background","opacity","trigger","call"],"mappings":";AAAA,SAAA,EAAA,GAAA,OAAA,EAAA,mBAAA,QAAA,iBAAA,OAAA,SAAA,SAAA,GAAA,cAAA,GAAA,SAAA,GAAA,OAAA,GAAA,mBAAA,QAAA,EAAA,cAAA,QAAA,IAAA,OAAA,UAAA,gBAAA,IAAA,GAAA,SAAA,EAAA,EAAA,GAAA,KAAA,aAAA,GAAA,MAAA,IAAA,UAAA,qCAAA,SAAA,EAAA,EAAA,GAAA,IAAA,IAAA,EAAA,EAAA,EAAA,EAAA,OAAA,IAAA,CAAA,IAAA,EAAA,EAAA,GAAA,EAAA,WAAA,EAAA,aAAA,EAAA,EAAA,cAAA,EAAA,UAAA,IAAA,EAAA,UAAA,GAAA,OAAA,eAAA,EAAA,EAAA,EAAA,KAAA,IAAA,SAAA,EAAA,EAAA,EAAA,GAAA,OAAA,GAAA,EAAA,EAAA,UAAA,GAAA,GAAA,EAAA,EAAA,GAAA,OAAA,eAAA,EAAA,YAAA,CAAA,UAAA,IAAA,EAAA,SAAA,EAAA,GAAA,IAAA,EAAA,EAAA,EAAA,UAAA,MAAA,UAAA,EAAA,GAAA,EAAA,EAAA,GAAA,SAAA,EAAA,EAAA,GAAA,GAAA,UAAA,EAAA,KAAA,EAAA,OAAA,EAAA,IAAA,EAAA,EAAA,OAAA,aAAA,QAAA,IAAA,EAAA,CAAA,IAAA,EAAA,EAAA,KAAA,EAAA,GAAA,WAAA,GAAA,UAAA,EAAA,GAAA,OAAA,EAAA,MAAA,IAAA,UAAA,gDAAA,OAAA,WAAA,EAAA,OAAA,QAAA,IAAA,WASEA,OAAO,SAASC,GAAG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6B,QAAQU,OACfvC,EAAE,EAAK2B,SAASY,OAChB,EAAKd,gBAAkBsC,KAAKC,MAAME,GAC3B,EAAK6B,cACX,SAAC7B,GAOK,OANPa,QAAQnC,MAAM,gDAAkDsB,EAASE,SACzEpE,EAAE,EAAK6B,QAAQO,OAE6B,IAAxCpC,EAAE,EAAK4B,WAAWM,WAAWC,QAC/BnC,EAAE,EAAK2B,SAASS,OAEX,EAAK2D,iBAhWlB,CAAA,IAAA,sBAoWE,MAAA,SAAoBtB,GAAM,IAAA,EAAA,KACjB,OAAA,IAAIH,QAAQ,SAACC,EAASC,GACvB6B,IAAAA,EAMGrG,OALPqG,EAAY,CACM,OAAA,MAAA,OAAA,EAAKnF,WAArB,mCAEFlB,EAAEsG,OAAO7B,EAAM4B,GAERrG,EAAE0E,KAAK,EAAKrD,SAAUoD,EAAM,SAACP,GAC9BA,OAAAA,EAASS,QACJJ,EAAQL,EAASO,MAEjBD,EAAON,EAASO,YAhXjC,CAAA,IAAA,gBAyXE,MAAA,SAAc8B,GAQLvG,OANPA,EAAE,4CAA4CwG,SAEzClE,KAAAA,WAAWmE,QAAQ,qCAAuCF,EAAOG,KAAK,aAAe,cAErFpE,KAAAA,WAAWqE,YAAY,cAAcC,UAEnC5G,EAAE,cAAc6G,QAAQ,CAC7BC,UAAW,KAAKxE,WAAWyE,SAASC,IAAM,KACzC,OAnYP,CAAA,IAAA,WAyYE,MAAA,WACS,OAAA,KAAK1E,WAAW2E,MAAM,CAC3B7C,QAAS,KACT8C,WAAY,CACVC,WAAY,OACZC,QAAS,QA9YjB,CAAA,IAAA,aAsZE,MAAA,WACS,OAAA,KAAK9E,WAAWsE,cAvZ3B,GA4ZO5G,EAAEwC,SAASC,MAAM4E,QAAQ,8CAGjCC,KAAK","file":"sv-wc-payment-gateway-apple-pay.js","sourceRoot":"../js","sourcesContent":["(function() {\n /*\n WooCommerce Apple Pay Handler\n Version 4.7.0\n\n Copyright (c) 2016, SkyVerge, Inc.\n Licensed under the GNU General Public License v3.0\n http://www.gnu.org/licenses/gpl-3.0.html\n */\n jQuery(function($) {\n \"use strict\";\n // The WooCommerce Apple Pay handler base class.\n\n // @since 4.7.0\n window.SV_WC_Apple_Pay_Handler_v5_13_0 = class SV_WC_Apple_Pay_Handler_v5_13_0 {\n // Constructs the handler.\n\n // @since 4.7.0\n constructor(args) {\n // Initializes the product page.\n\n // @since 5.6.0\n this.init_product_page = this.init_product_page.bind(this);\n // Initializes the cart page.\n\n // @since 5.6.0\n this.init_cart_page = this.init_cart_page.bind(this);\n // Initializes the checkout page.\n\n // @since 5.6.0\n this.init_checkout_page = this.init_checkout_page.bind(this);\n // The callback for after the merchant data is validated.\n\n // @since 4.7.0\n this.on_validate_merchant = this.on_validate_merchant.bind(this);\n // Validates the merchant data.\n\n // @since 4.7.0\n // @return object\n this.validate_merchant = this.validate_merchant.bind(this);\n // Fires after a payment method has been selected.\n\n // @since 4.7.0\n this.on_payment_method_selected = this.on_payment_method_selected.bind(this);\n // Fires after a shipping contact has been selected.\n\n // @since 4.7.0\n this.on_shipping_contact_selected = this.on_shipping_contact_selected.bind(this);\n // Fires after a shipping method has been selected.\n\n // @since 4.7.0\n this.on_shipping_method_selected = this.on_shipping_method_selected.bind(this);\n // The callback for after the payment data is authorized.\n\n // @since 4.7.0\n this.on_payment_authorized = this.on_payment_authorized.bind(this);\n // Processes the transaction data.\n\n // @since 4.7.0\n this.process_authorization = this.process_authorization.bind(this);\n // The callback for when the payment card is cancelled/dismissed.\n\n // @since 4.7.0\n this.on_cancel_payment = this.on_cancel_payment.bind(this);\n // Resets the payment request via AJAX.\n\n // Extending handlers can call this on change events to refresh the data.\n\n // @since 4.7.0\n this.reset_payment_request = this.reset_payment_request.bind(this);\n // Gets the payment request via AJAX.\n\n // @since 4.7.0\n this.get_payment_request = this.get_payment_request.bind(this);\n this.gateway_id = args.gateway_id;\n this.gateway_slug = args.gateway_slug;\n this.merchant_id = args.merchant_id;\n this.ajax_url = args.ajax_url;\n this.validate_nonce = args.validate_nonce;\n this.recalculate_totals_nonce = args.recalculate_totals_nonce;\n this.process_nonce = args.process_nonce;\n this.payment_request = args.payment_request;\n this.generic_error = args.generic_error;\n this.wrapper = '.sv-wc-external-checkout';\n this.container = '.buttons-container';\n this.button = '.sv-wc-apple-pay-button';\n }\n\n // Determines if Apple Pay is available.\n\n // @since 4.7.0\n // @return bool\n is_available() {\n if (!window.ApplePaySession) {\n return false;\n }\n return ApplePaySession.canMakePaymentsWithActiveCard(this.merchant_id).then((canMakePayments) => {\n return canMakePayments;\n });\n }\n\n // Initializes the handler.\n\n // @since 4.7.0\n init() {\n // hide the wrapper if Apple Pay is the only button\n if ($(this.container).children().length === 1) {\n $(this.wrapper).hide();\n }\n if (!this.is_available()) {\n return;\n }\n // initialize for the various pages\n if ($('form.cart').length) {\n this.init_product_page();\n } else if ($('form.woocommerce-cart-form').length) {\n this.init_cart_page();\n } else if ($('form.woocommerce-checkout').length) {\n this.init_checkout_page();\n }\n // bail if no UI was initialized\n if (!this.ui_element) {\n return;\n }\n if (this.payment_request) {\n $(this.button).show();\n $(this.wrapper).show();\n }\n return $(document.body).on('click', '.sv-wc-apple-pay-button', (e) => {\n var error;\n e.preventDefault();\n this.block_ui();\n try {\n this.session = this.get_new_session(this.payment_request);\n // set the payment card events\n this.session.onvalidatemerchant = (event) => {\n return this.on_validate_merchant(event);\n };\n this.session.onpaymentmethodselected = (event) => {\n return this.on_payment_method_selected(event);\n };\n this.session.onshippingcontactselected = (event) => {\n return this.on_shipping_contact_selected(event);\n };\n this.session.onshippingmethodselected = (event) => {\n return this.on_shipping_method_selected(event);\n };\n this.session.onpaymentauthorized = (event) => {\n return this.on_payment_authorized(event);\n };\n this.session.oncancel = (event) => {\n return this.on_cancel_payment(event);\n };\n return this.session.begin();\n } catch (error1) {\n error = error1;\n return this.fail_payment(error);\n }\n });\n }\n\n init_product_page() {\n return this.ui_element = $('form.cart');\n }\n\n init_cart_page() {\n this.ui_element = $('form.woocommerce-cart-form').parents('div.woocommerce');\n // re-init if the cart totals are updated\n return $(document.body).on('updated_cart_totals', () => {\n return this.reset_payment_request();\n });\n }\n\n init_checkout_page() {\n this.ui_element = $('form.woocommerce-checkout');\n return $(document.body).on('updated_checkout', () => {\n // re-init if the checkout is updated\n return this.reset_payment_request();\n });\n }\n\n // Gets a new Apple Pay session.\n\n // @since 5.6.0\n\n // @param [Object] payment_request payment request object\n // @return ApplePaySession\n get_new_session(payment_request) {\n return new ApplePaySession(this.get_sdk_version(), payment_request);\n }\n\n // Gets the Apple SDK version to use.\n\n // @since 5.6.0\n // @return int\n get_sdk_version() {\n return 2;\n }\n\n on_validate_merchant(event) {\n return this.validate_merchant(event.validationURL).then((merchant_session) => {\n merchant_session = JSON.parse(merchant_session);\n return this.session.completeMerchantValidation(merchant_session);\n }, (response) => {\n this.session.abort();\n return this.fail_payment('Merchant could no be validated. ' + response.message);\n });\n }\n\n validate_merchant(url) {\n return new Promise((resolve, reject) => {\n var data;\n data = {\n 'action': `wc_${this.gateway_id}_apple_pay_validate_merchant`,\n 'nonce': this.validate_nonce,\n 'merchant_id': this.merchant_id,\n 'url': url\n };\n // retrieve a payment request object\n return $.post(this.ajax_url, data, (response) => {\n if (response.success) {\n return resolve(response.data);\n } else {\n return reject(response.data);\n }\n });\n });\n }\n\n on_payment_method_selected(event) {\n return new Promise((resolve, reject) => {\n var data;\n data = {\n 'action': `wc_${this.gateway_id}_apple_pay_recalculate_totals`,\n 'nonce': this.recalculate_totals_nonce\n };\n // retrieve a payment request object\n return $.post(this.ajax_url, data, (response) => {\n if (response.success) {\n data = response.data;\n return resolve(this.session.completePaymentMethodSelection(data.total, data.line_items));\n } else {\n console.error('[Apple Pay] Error selecting a shipping contact. ' + response.data.message);\n return reject(this.session.completePaymentMethodSelection(this.payment_request.total, this.payment_request.lineItems));\n }\n });\n });\n }\n\n on_shipping_contact_selected(event) {\n return new Promise((resolve, reject) => {\n var data;\n data = {\n 'action': `wc_${this.gateway_id}_apple_pay_recalculate_totals`,\n 'nonce': this.recalculate_totals_nonce,\n 'contact': event.shippingContact\n };\n // retrieve a payment request object\n return $.post(this.ajax_url, data, (response) => {\n if (response.success) {\n data = response.data;\n return resolve(this.session.completeShippingContactSelection(ApplePaySession.STATUS_SUCCESS, data.shipping_methods, data.total, data.line_items));\n } else {\n console.error('[Apple Pay] Error selecting a shipping contact. ' + response.data.message);\n return reject(this.session.completeShippingContactSelection(ApplePaySession.STATUS_FAILURE, [], this.payment_request.total, this.payment_request.lineItems));\n }\n });\n });\n }\n\n on_shipping_method_selected(event) {\n return new Promise((resolve, reject) => {\n var data;\n data = {\n 'action': `wc_${this.gateway_id}_apple_pay_recalculate_totals`,\n 'nonce': this.recalculate_totals_nonce,\n 'method': event.shippingMethod.identifier\n };\n // retrieve a payment request object\n return $.post(this.ajax_url, data, (response) => {\n if (response.success) {\n data = response.data;\n return resolve(this.session.completeShippingMethodSelection(ApplePaySession.STATUS_SUCCESS, data.total, data.line_items));\n } else {\n console.error('[Apple Pay] Error selecting a shipping method. ' + response.data.message);\n return reject(this.session.completeShippingMethodSelection(ApplePaySession.STATUS_FAILURE, this.payment_request.total, this.payment_request.lineItems));\n }\n });\n });\n }\n\n on_payment_authorized(event) {\n return this.process_authorization(event.payment).then((response) => {\n this.set_payment_status(true);\n return this.complete_purchase(response);\n }, (response) => {\n this.set_payment_status(false);\n return this.fail_payment('Payment could no be processed. ' + response.message);\n });\n }\n\n process_authorization(payment) {\n return new Promise((resolve, reject) => {\n var data;\n data = {\n action: `wc_${this.gateway_id}_apple_pay_process_payment`,\n nonce: this.process_nonce,\n payment: JSON.stringify(payment)\n };\n return $.post(this.ajax_url, data, (response) => {\n if (response.success) {\n return resolve(response.data);\n } else {\n return reject(response.data);\n }\n });\n });\n }\n\n on_cancel_payment(event) {\n return this.unblock_ui();\n }\n\n // Completes the purchase based on the gateway result.\n\n // @since 4.7.0\n complete_purchase(response) {\n return window.location = response.redirect;\n }\n\n // Fails the purchase based on the gateway result.\n\n // @since 4.7.0\n fail_payment(error) {\n console.error('[Apple Pay] ' + error);\n this.unblock_ui();\n return this.render_errors([this.generic_error]);\n }\n\n // Sets the Apple Pay payment status depending on the gateway result.\n\n // @since 4.7.0\n set_payment_status(success) {\n var status;\n if (success) {\n status = ApplePaySession.STATUS_SUCCESS;\n } else {\n status = ApplePaySession.STATUS_FAILURE;\n }\n return this.session.completePayment(status);\n }\n\n reset_payment_request(data = {}) {\n this.block_ui();\n return this.get_payment_request(data).then((response) => {\n $(this.button).show();\n $(this.wrapper).show();\n this.payment_request = JSON.parse(response);\n return this.unblock_ui();\n }, (response) => {\n console.error('[Apple Pay] Could not build payment request. ' + response.message);\n $(this.button).hide();\n // hide the wrapper if Apple Pay is the only button\n if ($(this.container).children().length === 1) {\n $(this.wrapper).hide();\n }\n return this.unblock_ui();\n });\n }\n\n get_payment_request(data) {\n return new Promise((resolve, reject) => {\n var base_data;\n base_data = {\n 'action': `wc_${this.gateway_id}_apple_pay_get_payment_request`\n };\n $.extend(data, base_data);\n // retrieve a payment request object\n return $.post(this.ajax_url, data, (response) => {\n if (response.success) {\n return resolve(response.data);\n } else {\n return reject(response.data);\n }\n });\n });\n }\n\n // Renders any new errors and bring them into the viewport.\n\n // @since 4.7.0\n render_errors(errors) {\n // hide and remove any previous errors\n $('.woocommerce-error, .woocommerce-message').remove();\n // add errors\n this.ui_element.prepend('
  • ' + errors.join('
  • ') + '
');\n // unblock UI\n this.ui_element.removeClass('processing').unblock();\n // scroll to top\n return $('html, body').animate({\n scrollTop: this.ui_element.offset().top - 100\n }, 1000);\n }\n\n // Blocks the payment form UI.\n\n // @since 4.7.0\n block_ui() {\n return this.ui_element.block({\n message: null,\n overlayCSS: {\n background: '#fff',\n opacity: 0.6\n }\n });\n }\n\n // Unblocks the payment form UI.\n\n // @since 4.7.0\n unblock_ui() {\n return this.ui_element.unblock();\n }\n\n };\n // dispatch loaded event\n return $(document.body).trigger('sv_wc_apple_pay_handler_v5_13_0_loaded');\n });\n\n}).call(this);\n"]} \ No newline at end of file +{"version":3,"sources":["frontend/sv-wc-payment-gateway-apple-pay.coffee"],"names":["jQuery","$","window","SV_WC_Apple_Pay_Handler_v5_13_1","args","init_product_page","bind","init_cart_page","init_checkout_page","on_validate_merchant","validate_merchant","on_payment_method_selected","on_shipping_contact_selected","on_shipping_method_selected","on_payment_authorized","process_authorization","on_cancel_payment","reset_payment_request","get_payment_request","gateway_id","gateway_slug","merchant_id","ajax_url","validate_nonce","recalculate_totals_nonce","process_nonce","payment_request","generic_error","wrapper","container","button","ApplePaySession","canMakePaymentsWithActiveCard","then","canMakePayments","children","length","hide","is_available","ui_element","show","document","body","on","e","error","preventDefault","block_ui","session","get_new_session","onvalidatemerchant","event","onpaymentmethodselected","onshippingcontactselected","onshippingmethodselected","onpaymentauthorized","oncancel","begin","error1","fail_payment","parents","get_sdk_version","validationURL","merchant_session","JSON","parse","completeMerchantValidation","response","abort","message","url","Promise","resolve","reject","data","post","success","completePaymentMethodSelection","total","line_items","console","lineItems","shippingContact","completeShippingContactSelection","STATUS_SUCCESS","shipping_methods","STATUS_FAILURE","shippingMethod","identifier","completeShippingMethodSelection","payment","set_payment_status","complete_purchase","action","nonce","stringify","unblock_ui","location","redirect","render_errors","status","completePayment","base_data","extend","errors","remove","prepend","join","removeClass","unblock","animate","scrollTop","offset","top","block","overlayCSS","background","opacity","trigger","call"],"mappings":";AAAA,SAAA,EAAA,GAAA,OAAA,EAAA,mBAAA,QAAA,iBAAA,OAAA,SAAA,SAAA,GAAA,cAAA,GAAA,SAAA,GAAA,OAAA,GAAA,mBAAA,QAAA,EAAA,cAAA,QAAA,IAAA,OAAA,UAAA,gBAAA,IAAA,GAAA,SAAA,EAAA,EAAA,GAAA,KAAA,aAAA,GAAA,MAAA,IAAA,UAAA,qCAAA,SAAA,EAAA,EAAA,GAAA,IAAA,IAAA,EAAA,EAAA,EAAA,EAAA,OAAA,IAAA,CAAA,IAAA,EAAA,EAAA,GAAA,EAAA,WAAA,EAAA,aAAA,EAAA,EAAA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,GAQLvG,OANPA,EAAE,4CAA4CwG,SAEzClE,KAAAA,WAAWmE,QAAQ,qCAAuCF,EAAOG,KAAK,aAAe,cAErFpE,KAAAA,WAAWqE,YAAY,cAAcC,UAEnC5G,EAAE,cAAc6G,QAAQ,CAC7BC,UAAW,KAAKxE,WAAWyE,SAASC,IAAM,KACzC,OAnYP,CAAA,IAAA,WAyYE,MAAA,WACS,OAAA,KAAK1E,WAAW2E,MAAM,CAC3B7C,QAAS,KACT8C,WAAY,CACVC,WAAY,OACZC,QAAS,QA9YjB,CAAA,IAAA,aAsZE,MAAA,WACS,OAAA,KAAK9E,WAAWsE,cAvZ3B,GA4ZO5G,EAAEwC,SAASC,MAAM4E,QAAQ,8CAGjCC,KAAK","file":"sv-wc-payment-gateway-apple-pay.js","sourceRoot":"../js","sourcesContent":["(function() {\n /*\n WooCommerce Apple Pay Handler\n Version 4.7.0\n\n Copyright (c) 2016, SkyVerge, Inc.\n Licensed under the GNU General Public License v3.0\n http://www.gnu.org/licenses/gpl-3.0.html\n */\n jQuery(function($) {\n \"use strict\";\n // The WooCommerce Apple Pay handler base class.\n\n // @since 4.7.0\n window.SV_WC_Apple_Pay_Handler_v5_13_1 = class SV_WC_Apple_Pay_Handler_v5_13_1 {\n // Constructs the handler.\n\n // @since 4.7.0\n constructor(args) {\n // Initializes the product page.\n\n // @since 5.6.0\n this.init_product_page = this.init_product_page.bind(this);\n // Initializes the cart page.\n\n // @since 5.6.0\n this.init_cart_page = this.init_cart_page.bind(this);\n // Initializes the checkout page.\n\n // @since 5.6.0\n this.init_checkout_page = this.init_checkout_page.bind(this);\n // The callback for after the merchant data is validated.\n\n // @since 4.7.0\n this.on_validate_merchant = this.on_validate_merchant.bind(this);\n // Validates the merchant data.\n\n // @since 4.7.0\n // @return object\n this.validate_merchant = this.validate_merchant.bind(this);\n // Fires after a payment method has been selected.\n\n // @since 4.7.0\n this.on_payment_method_selected = this.on_payment_method_selected.bind(this);\n // Fires after a shipping contact has been selected.\n\n // @since 4.7.0\n this.on_shipping_contact_selected = this.on_shipping_contact_selected.bind(this);\n // Fires after a shipping method has been selected.\n\n // @since 4.7.0\n this.on_shipping_method_selected = this.on_shipping_method_selected.bind(this);\n // The callback for after the payment data is authorized.\n\n // @since 4.7.0\n this.on_payment_authorized = this.on_payment_authorized.bind(this);\n // Processes the transaction data.\n\n // @since 4.7.0\n this.process_authorization = this.process_authorization.bind(this);\n // The callback for when the payment card is cancelled/dismissed.\n\n // @since 4.7.0\n this.on_cancel_payment = this.on_cancel_payment.bind(this);\n // Resets the payment request via AJAX.\n\n // Extending handlers can call this on change events to refresh the data.\n\n // @since 4.7.0\n this.reset_payment_request = this.reset_payment_request.bind(this);\n // Gets the payment request via AJAX.\n\n // @since 4.7.0\n this.get_payment_request = this.get_payment_request.bind(this);\n this.gateway_id = args.gateway_id;\n this.gateway_slug = args.gateway_slug;\n this.merchant_id = args.merchant_id;\n this.ajax_url = args.ajax_url;\n this.validate_nonce = args.validate_nonce;\n this.recalculate_totals_nonce = args.recalculate_totals_nonce;\n this.process_nonce = args.process_nonce;\n this.payment_request = args.payment_request;\n this.generic_error = args.generic_error;\n this.wrapper = '.sv-wc-external-checkout';\n this.container = '.buttons-container';\n this.button = '.sv-wc-apple-pay-button';\n }\n\n // Determines if Apple Pay is available.\n\n // @since 4.7.0\n // @return bool\n is_available() {\n if (!window.ApplePaySession) {\n return false;\n }\n return ApplePaySession.canMakePaymentsWithActiveCard(this.merchant_id).then((canMakePayments) => {\n return canMakePayments;\n });\n }\n\n // Initializes the handler.\n\n // @since 4.7.0\n init() {\n // hide the wrapper if Apple Pay is the only button\n if ($(this.container).children().length === 1) {\n $(this.wrapper).hide();\n }\n if (!this.is_available()) {\n return;\n }\n // initialize for the various pages\n if ($('form.cart').length) {\n this.init_product_page();\n } else if ($('form.woocommerce-cart-form').length) {\n this.init_cart_page();\n } else if ($('form.woocommerce-checkout').length) {\n this.init_checkout_page();\n }\n // bail if no UI was initialized\n if (!this.ui_element) {\n return;\n }\n if (this.payment_request) {\n $(this.button).show();\n $(this.wrapper).show();\n }\n return $(document.body).on('click', '.sv-wc-apple-pay-button', (e) => {\n var error;\n e.preventDefault();\n this.block_ui();\n try {\n this.session = this.get_new_session(this.payment_request);\n // set the payment card events\n this.session.onvalidatemerchant = (event) => {\n return this.on_validate_merchant(event);\n };\n this.session.onpaymentmethodselected = (event) => {\n return this.on_payment_method_selected(event);\n };\n this.session.onshippingcontactselected = (event) => {\n return this.on_shipping_contact_selected(event);\n };\n this.session.onshippingmethodselected = (event) => {\n return this.on_shipping_method_selected(event);\n };\n this.session.onpaymentauthorized = (event) => {\n return this.on_payment_authorized(event);\n };\n this.session.oncancel = (event) => {\n return this.on_cancel_payment(event);\n };\n return this.session.begin();\n } catch (error1) {\n error = error1;\n return this.fail_payment(error);\n }\n });\n }\n\n init_product_page() {\n return this.ui_element = $('form.cart');\n }\n\n init_cart_page() {\n this.ui_element = $('form.woocommerce-cart-form').parents('div.woocommerce');\n // re-init if the cart totals are updated\n return $(document.body).on('updated_cart_totals', () => {\n return this.reset_payment_request();\n });\n }\n\n init_checkout_page() {\n this.ui_element = $('form.woocommerce-checkout');\n return $(document.body).on('updated_checkout', () => {\n // re-init if the checkout is updated\n return this.reset_payment_request();\n });\n }\n\n // Gets a new Apple Pay session.\n\n // @since 5.6.0\n\n // @param [Object] payment_request payment request object\n // @return ApplePaySession\n get_new_session(payment_request) {\n return new ApplePaySession(this.get_sdk_version(), payment_request);\n }\n\n // Gets the Apple SDK version to use.\n\n // @since 5.6.0\n // @return int\n get_sdk_version() {\n return 2;\n }\n\n on_validate_merchant(event) {\n return this.validate_merchant(event.validationURL).then((merchant_session) => {\n merchant_session = JSON.parse(merchant_session);\n return this.session.completeMerchantValidation(merchant_session);\n }, (response) => {\n this.session.abort();\n return this.fail_payment('Merchant could no be validated. ' + response.message);\n });\n }\n\n validate_merchant(url) {\n return new Promise((resolve, reject) => {\n var data;\n data = {\n 'action': `wc_${this.gateway_id}_apple_pay_validate_merchant`,\n 'nonce': this.validate_nonce,\n 'merchant_id': this.merchant_id,\n 'url': url\n };\n // retrieve a payment request object\n return $.post(this.ajax_url, data, (response) => {\n if (response.success) {\n return resolve(response.data);\n } else {\n return reject(response.data);\n }\n });\n });\n }\n\n on_payment_method_selected(event) {\n return new Promise((resolve, reject) => {\n var data;\n data = {\n 'action': `wc_${this.gateway_id}_apple_pay_recalculate_totals`,\n 'nonce': this.recalculate_totals_nonce\n };\n // retrieve a payment request object\n return $.post(this.ajax_url, data, (response) => {\n if (response.success) {\n data = response.data;\n return resolve(this.session.completePaymentMethodSelection(data.total, data.line_items));\n } else {\n console.error('[Apple Pay] Error selecting a shipping contact. ' + response.data.message);\n return reject(this.session.completePaymentMethodSelection(this.payment_request.total, this.payment_request.lineItems));\n }\n });\n });\n }\n\n on_shipping_contact_selected(event) {\n return new Promise((resolve, reject) => {\n var data;\n data = {\n 'action': `wc_${this.gateway_id}_apple_pay_recalculate_totals`,\n 'nonce': this.recalculate_totals_nonce,\n 'contact': event.shippingContact\n };\n // retrieve a payment request object\n return $.post(this.ajax_url, data, (response) => {\n if (response.success) {\n data = response.data;\n return resolve(this.session.completeShippingContactSelection(ApplePaySession.STATUS_SUCCESS, data.shipping_methods, data.total, data.line_items));\n } else {\n console.error('[Apple Pay] Error selecting a shipping contact. ' + response.data.message);\n return reject(this.session.completeShippingContactSelection(ApplePaySession.STATUS_FAILURE, [], this.payment_request.total, this.payment_request.lineItems));\n }\n });\n });\n }\n\n on_shipping_method_selected(event) {\n return new Promise((resolve, reject) => {\n var data;\n data = {\n 'action': `wc_${this.gateway_id}_apple_pay_recalculate_totals`,\n 'nonce': this.recalculate_totals_nonce,\n 'method': event.shippingMethod.identifier\n };\n // retrieve a payment request object\n return $.post(this.ajax_url, data, (response) => {\n if (response.success) {\n data = response.data;\n return resolve(this.session.completeShippingMethodSelection(ApplePaySession.STATUS_SUCCESS, data.total, data.line_items));\n } else {\n console.error('[Apple Pay] Error selecting a shipping method. ' + response.data.message);\n return reject(this.session.completeShippingMethodSelection(ApplePaySession.STATUS_FAILURE, this.payment_request.total, this.payment_request.lineItems));\n }\n });\n });\n }\n\n on_payment_authorized(event) {\n return this.process_authorization(event.payment).then((response) => {\n this.set_payment_status(true);\n return this.complete_purchase(response);\n }, (response) => {\n this.set_payment_status(false);\n return this.fail_payment('Payment could no be processed. ' + response.message);\n });\n }\n\n process_authorization(payment) {\n return new Promise((resolve, reject) => {\n var data;\n data = {\n action: `wc_${this.gateway_id}_apple_pay_process_payment`,\n nonce: this.process_nonce,\n payment: JSON.stringify(payment)\n };\n return $.post(this.ajax_url, data, (response) => {\n if (response.success) {\n return resolve(response.data);\n } else {\n return reject(response.data);\n }\n });\n });\n }\n\n on_cancel_payment(event) {\n return this.unblock_ui();\n }\n\n // Completes the purchase based on the gateway result.\n\n // @since 4.7.0\n complete_purchase(response) {\n return window.location = response.redirect;\n }\n\n // Fails the purchase based on the gateway result.\n\n // @since 4.7.0\n fail_payment(error) {\n console.error('[Apple Pay] ' + error);\n this.unblock_ui();\n return this.render_errors([this.generic_error]);\n }\n\n // Sets the Apple Pay payment status depending on the gateway result.\n\n // @since 4.7.0\n set_payment_status(success) {\n var status;\n if (success) {\n status = ApplePaySession.STATUS_SUCCESS;\n } else {\n status = ApplePaySession.STATUS_FAILURE;\n }\n return this.session.completePayment(status);\n }\n\n reset_payment_request(data = {}) {\n this.block_ui();\n return this.get_payment_request(data).then((response) => {\n $(this.button).show();\n $(this.wrapper).show();\n this.payment_request = JSON.parse(response);\n return this.unblock_ui();\n }, (response) => {\n console.error('[Apple Pay] Could not build payment request. ' + response.message);\n $(this.button).hide();\n // hide the wrapper if Apple Pay is the only button\n if ($(this.container).children().length === 1) {\n $(this.wrapper).hide();\n }\n return this.unblock_ui();\n });\n }\n\n get_payment_request(data) {\n return new Promise((resolve, reject) => {\n var base_data;\n base_data = {\n 'action': `wc_${this.gateway_id}_apple_pay_get_payment_request`\n };\n $.extend(data, base_data);\n // retrieve a payment request object\n return $.post(this.ajax_url, data, (response) => {\n if (response.success) {\n return resolve(response.data);\n } else {\n return reject(response.data);\n }\n });\n });\n }\n\n // Renders any new errors and bring them into the viewport.\n\n // @since 4.7.0\n render_errors(errors) {\n // hide and remove any previous errors\n $('.woocommerce-error, .woocommerce-message').remove();\n // add errors\n this.ui_element.prepend('
  • ' + errors.join('
  • ') + '
');\n // unblock UI\n this.ui_element.removeClass('processing').unblock();\n // scroll to top\n return $('html, body').animate({\n scrollTop: this.ui_element.offset().top - 100\n }, 1000);\n }\n\n // Blocks the payment form UI.\n\n // @since 4.7.0\n block_ui() {\n return this.ui_element.block({\n message: null,\n overlayCSS: {\n background: '#fff',\n opacity: 0.6\n }\n });\n }\n\n // Unblocks the payment form UI.\n\n // @since 4.7.0\n unblock_ui() {\n return this.ui_element.unblock();\n }\n\n };\n // dispatch loaded event\n return $(document.body).trigger('sv_wc_apple_pay_handler_v5_13_1_loaded');\n });\n\n}).call(this);\n"]} diff --git a/woocommerce/payment-gateway/assets/dist/frontend/sv-wc-payment-gateway-google-pay.js b/woocommerce/payment-gateway/assets/dist/frontend/sv-wc-payment-gateway-google-pay.js index 4153b26ee..d4c8fb320 100644 --- a/woocommerce/payment-gateway/assets/dist/frontend/sv-wc-payment-gateway-google-pay.js +++ b/woocommerce/payment-gateway/assets/dist/frontend/sv-wc-payment-gateway-google-pay.js @@ -1,4 +1,4 @@ parcelRequire=function(e,r,t,n){var i,o="function"==typeof parcelRequire&&parcelRequire,u="function"==typeof require&&require;function f(t,n){if(!r[t]){if(!e[t]){var i="function"==typeof parcelRequire&&parcelRequire;if(!n&&i)return i(t,!0);if(o)return o(t,!0);if(u&&"string"==typeof t)return u(t);var c=new Error("Cannot find module '"+t+"'");throw c.code="MODULE_NOT_FOUND",c}p.resolve=function(r){return e[t][1][r]||r},p.cache={};var l=r[t]=new f.Module(t);e[t][0].call(l.exports,p,l,l.exports,this)}return r[t].exports;function p(e){return f(p.resolve(e))}}f.isParcelRequire=!0,f.Module=function(e){this.id=e,this.bundle=f,this.exports={}},f.modules=e,f.cache=r,f.parent=o,f.register=function(r,t){e[r]=[function(e,r){r.exports=t},{}]};for(var c=0;c
  • '+t.join("
  • ")+"
  • "),this.uiElement.removeClass("processing").unblock(),e("html, body").animate({scrollTop:this.uiElement.offset().top-100},1e3)}},{key:"blockUI",value:function(){this.uiElement.block({message:null,overlayCSS:{background:"#fff",opacity:.6}})}},{key:"unblockUI",value:function(){this.uiElement.unblock()}}])}(),e(document.body).trigger("sv_wc_google_pay_handler_v5_13_0_loaded")}); +function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(t)}function t(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function n(e,t){for(var n=0;n
  • '+t.join("
  • ")+"
  • "),this.uiElement.removeClass("processing").unblock(),e("html, body").animate({scrollTop:this.uiElement.offset().top-100},1e3)}},{key:"blockUI",value:function(){this.uiElement.block({message:null,overlayCSS:{background:"#fff",opacity:.6}})}},{key:"unblockUI",value:function(){this.uiElement.unblock()}}])}(),e(document.body).trigger("sv_wc_google_pay_handler_v5_13_1_loaded")}); },{}]},{},["O8A1"], null) -//# sourceMappingURL=../frontend/sv-wc-payment-gateway-google-pay.js.map \ No newline at end of file +//# sourceMappingURL=../frontend/sv-wc-payment-gateway-google-pay.js.map diff --git a/woocommerce/payment-gateway/assets/dist/frontend/sv-wc-payment-gateway-google-pay.js.map b/woocommerce/payment-gateway/assets/dist/frontend/sv-wc-payment-gateway-google-pay.js.map index 3f89b454f..4f62a31f6 100644 --- a/woocommerce/payment-gateway/assets/dist/frontend/sv-wc-payment-gateway-google-pay.js.map +++ b/woocommerce/payment-gateway/assets/dist/frontend/sv-wc-payment-gateway-google-pay.js.map @@ -1 +1 @@ -{"version":3,"sources":["frontend/sv-wc-payment-gateway-google-pay.js"],"names":["jQuery","$","window","SV_WC_Google_Pay_Handler_v5_13_0","params","plugin_id","merchant_id","merchant_name","gateway_id","environment","gateway_id_dasherized","ajax_url","recalculate_totals_nonce","process_nonce","button_style","card_types","available_countries","currency_code","needs_shipping","generic_error","gatewayID","merchantID","merchantName","ajaxURL","recalculateTotalsNonce","processNonce","buttonStyle","availableCountries","currencyCode","needsShipping","genericError","product_id","productID","allowedCardNetworks","baseRequest","apiVersion","apiVersionMinor","allowedCardAuthMethods","tokenizationSpecification","type","parameters","baseCardPaymentMethod","allowedAuthMethods","billingAddressRequired","billingAddressParameters","format","phoneNumberRequired","cardPaymentMethod","Object","assign","paymentsClient","allowedPaymentMethods","resolve","getGoogleTransactionInfo","transactionInfo","paymentDataRequest","merchantInfo","merchantId","emailRequired","callbackIntents","shippingAddressRequired","shippingAddressParameters","getGoogleShippingAddressParameters","shippingOptionRequired","args","paymentDataCallbacks","onPaymentAuthorized","paymentData","onPaymentDataChanged","google","payments","api","PaymentsClient","blockUI","Promise","reject","processPayment","err","transactionState","error","intent","message","reason","unblockUI","intermediatePaymentData","shippingAddress","shippingOptionData","chosenShippingMethod","callbackTrigger","id","getUpdatedTotals","paymentDataRequestUpdate","newShippingOptionParameters","shippingOptions","length","getGoogleUnserviceableAddressError","failPayment","data","action","post","response","success","JSON","parse","shippingMethod","allowedCountryCodes","button","getGooglePaymentsClient","createButton","onClick","event","onGooglePaymentButtonClicked","buttonColor","buttonSizeMode","document","getElementById","appendChild","getGooglePaymentDataRequest","totalPriceStatus","prefetchPaymentData","nonce","stringify","location","redirect","preventDefault","loadPaymentData","initProductPage","initCartPage","initCheckoutPage","initGooglePay","isReadyToPay","getGoogleIsReadyToPayRequest","then","result","addGooglePayButton","prefetchGooglePaymentData","catch","uiElement","parents","body","on","console","renderErrors","errors","remove","prepend","join","removeClass","unblock","animate","scrollTop","offset","top","block","overlayCSS","background","opacity","trigger"],"mappings":";AAAA,SAAA,EAAA,GAAA,OAAA,EAAA,mBAAA,QAAA,iBAAA,OAAA,SAAA,SAAA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,+BAGNC,MAAO,SAAE3D,GACT,EAAKmB,YAAa,4BAA8BnB,OA7gBpD,CAAA,IAAA,kBAohBC,MAAA,WACM4D,KAAAA,UAAYxI,EAAG,eArhBtB,CAAA,IAAA,eA2hBC,MAAA,WAAe,IAAA,EAAA,KACTwI,KAAAA,UAAYxI,EAAG,8BAA+ByI,QAAS,mBAG5DzI,EAAGiH,SAASyB,MAAOC,GAAI,sBAAuB,WAC7C,EAAKX,oBAhiBR,CAAA,IAAA,mBAuiBC,MAAA,WACMQ,KAAAA,UAAYxI,EAAG,+BAxiBtB,CAAA,IAAA,cA8iBC,MAAA,SAAa8E,GAEZ8D,QAAQ9D,MAAO,gBAAkBA,GAE5BI,KAAAA,YAEA2D,KAAAA,aAAc,CAAE,KAAKhH,iBApjB5B,CAAA,IAAA,eA0jBC,MAAA,SAAciH,GAGb9I,EAAG,4CAA6C+I,SAG3CP,KAAAA,UAAUQ,QAAS,qCAAuCF,EAAOG,KAAM,aAAgB,cAGvFT,KAAAA,UAAUU,YAAa,cAAeC,UAG3CnJ,EAAG,cAAeoJ,QAAS,CAAEC,UAAW,KAAKb,UAAUc,SAASC,IAAM,KAAO,OAtkB/E,CAAA,IAAA,UA4kBC,MAAA,WACMf,KAAAA,UAAUgB,MAAO,CAAExE,QAAS,KAAMyE,WAAY,CAAEC,WAAY,OAAQC,QAAS,QA7kBpF,CAAA,IAAA,YAmlBC,MAAA,WACMnB,KAAAA,UAAUW,cAplBjB,GAwlBAnJ,EAAGiH,SAASyB,MAAOkB,QAAS","file":"sv-wc-payment-gateway-google-pay.js","sourceRoot":"../js","sourcesContent":["jQuery( function( $ ) {\n\n\t\"use strict\"\n\n\t/**\n\t * Google Pay handler.\n\t *\n\t * @since 5.10.0\n\t *\n\t * @type {SV_WC_Google_Pay_Handler_v5_13_0} object\n\t */\n\twindow.SV_WC_Google_Pay_Handler_v5_13_0 = class SV_WC_Google_Pay_Handler_v5_13_0 {\n\n\t\t/**\n\t\t * Handler constructor.\n\t\t *\n\t\t * @since 5.10.0\n\t\t *\n\t\t * @param {Object} params The plugin ID\n\t\t * @param {string} params.plugin_id The plugin ID\n\t\t * @param {string} params.merchant_id The merchant ID\n\t\t * @param {string} params.merchant_name The site name\n\t\t * @param {string} params.gateway_id The gateway ID\n\t\t * @param {string} params.gateway_id_dasherized The gateway ID dasherized\n\t\t * @param {string} params.environment The gateway environment (PRODUCTION or TEST)\n\t\t * @param {string} params.ajax_url The AJAX URL\n\t\t * @param {string} params.recalculate_totals_nonce Nonce for the recalculate_totals AJAX action\n\t\t * @param {string} params.process_nonce Nonce for the process AJAX action\n\t\t * @param {string} params.button_style The button style\n\t\t * @param {string[]} params.card_types The supported card types\n\t\t * @param {string[]} params.available_countries Array of two-letter country codes the gateway is available for\n\t\t * @param {string[]} params.currency_code WC configured currency\n\t\t * @param {boolean} params.needs_shipping Whether or not the cart or product needs shipping\n\t\t * @param {string} params.generic_error The generic error message\n\t\t * @param {string} params.product_id The product ID if we are on a Product page\n\t\t */\n\t\tconstructor( params ) {\n\n\t\t\tlet {\n\t\t\t\tplugin_id,\n\t\t\t\tmerchant_id,\n\t\t\t\tmerchant_name,\n\t\t\t\tgateway_id,\n\t\t\t\tgateway_id_dasherized,\n\t\t\t\tenvironment,\n\t\t\t\tajax_url,\n\t\t\t\trecalculate_totals_nonce,\n\t\t\t\tprocess_nonce,\n\t\t\t\tbutton_style,\n\t\t\t\tcard_types,\n\t\t\t\tavailable_countries,\n\t\t\t\tcurrency_code,\n\t\t\t\tneeds_shipping,\n\t\t\t\tgeneric_error\n\t\t\t} = params;\n\n\t\t\tthis.gatewayID = gateway_id;\n\t\t\tthis.merchantID = merchant_id;\n\t\t\tthis.merchantName = merchant_name;\n\t\t\tthis.environment = environment;\n\t\t\tthis.ajaxURL = ajax_url;\n\t\t\tthis.recalculateTotalsNonce = recalculate_totals_nonce;\n\t\t\tthis.processNonce = process_nonce;\n\t\t\tthis.buttonStyle = button_style;\n\t\t\tthis.availableCountries = available_countries;\n\t\t\tthis.currencyCode = currency_code;\n\t\t\tthis.needsShipping = needs_shipping;\n\t\t\tthis.genericError = generic_error;\n\n\t\t\tif ( params.product_id ) {\n\t\t\t\tthis.productID = params.product_id;\n\t\t\t}\n\n\t\t\t/**\n\t\t\t * Card networks supported by your site and your gateway\n\t\t\t *\n\t\t\t * @see {@link https://developers.google.com/pay/api/web/reference/request-objects#CardParameters|CardParameters}\n\t\t\t */\n\t\t\tconst allowedCardNetworks = card_types;\n\n\t\t\t/**\n\t\t\t * Define the version of the Google Pay API referenced when creating your configuration\n\t\t\t *\n\t\t\t * @see {@link https://developers.google.com/pay/api/web/reference/request-objects#PaymentDataRequest|apiVersion in PaymentDataRequest}\n\t\t\t */\n\t\t\tthis.baseRequest = {\n\t\t\t\tapiVersion: 2,\n\t\t\t\tapiVersionMinor: 0\n\t\t\t};\n\n\t\t\t/**\n\t\t\t * Card authentication methods supported by your site and your gateway\n\t\t\t *\n\t\t\t * @see {@link https://developers.google.com/pay/api/web/reference/request-objects#CardParameters|CardParameters}\n\t\t\t *\n\t\t\t * @todo confirm your processor supports Android device tokens for your supported card networks\n\t\t\t */\n\t\t\tconst allowedCardAuthMethods = [ 'PAN_ONLY', 'CRYPTOGRAM_3DS' ];\n\n\t\t\t/**\n\t\t\t * Identify your gateway and your site's gateway merchant identifier\n\t\t\t *\n\t\t\t * The Google Pay API response will return an encrypted payment method capable\n\t\t\t * of being charged by a supported gateway after payer authorization\n\t\t\t *\n\t\t\t * @see {@link https://developers.google.com/pay/api/web/reference/request-objects#gateway|PaymentMethodTokenizationSpecification}\n\t\t\t */\n\t\t\tconst tokenizationSpecification = {\n\t\t\t\ttype: 'PAYMENT_GATEWAY',\n\t\t\t\tparameters: {\n\t\t\t\t\t'gateway': plugin_id,\n\t\t\t\t\t'gatewayMerchantId': this.merchantID\n\t\t\t\t}\n\t\t\t};\n\n\t\t\t/**\n\t\t\t * Describe your site's support for the CARD payment method and its required fields\n\t\t\t *\n\t\t\t * @see {@link https://developers.google.com/pay/api/web/reference/request-objects#CardParameters|CardParameters}\n\t\t\t */\n\t\t\tthis.baseCardPaymentMethod = {\n\t\t\t\ttype: 'CARD',\n\t\t\t\tparameters: {\n\t\t\t\t\tallowedAuthMethods: allowedCardAuthMethods,\n\t\t\t\t\tallowedCardNetworks: allowedCardNetworks,\n\t\t\t\t\tbillingAddressRequired: true,\n\t\t\t\t\tbillingAddressParameters: {\n\t\t\t\t\t\tformat: 'FULL',\n\t\t\t\t\t\tphoneNumberRequired: true\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t};\n\n\t\t\t/**\n\t\t\t * Describe your site's support for the CARD payment method including optional fields\n\t\t\t *\n\t\t\t * @see {@link https://developers.google.com/pay/api/web/reference/request-objects#CardParameters|CardParameters}\n\t\t\t */\n\t\t\tthis.cardPaymentMethod = Object.assign(\n\t\t\t\t{},\n\t\t\t\tthis.baseCardPaymentMethod,\n\t\t\t\t{\n\t\t\t\t\ttokenizationSpecification: tokenizationSpecification\n\t\t\t\t}\n\t\t\t);\n\n\t\t\t/**\n\t\t\t * An initialized google.payments.api.PaymentsClient object or null if not yet set\n\t\t\t *\n\t\t\t * @see {@link getGooglePaymentsClient}\n\t\t\t */\n\t\t\tthis.paymentsClient = null;\n\t\t}\n\n\t\t/**\n\t\t * Configure your site's support for payment methods supported by the Google Pay\n\t\t * API.\n\t\t *\n\t\t * Each member of allowedPaymentMethods should contain only the required fields,\n\t\t * allowing reuse of this base request when determining a viewer's ability\n\t\t * to pay and later requesting a supported payment method\n\t\t *\n\t\t * @returns {object} Google Pay API version, payment methods supported by the site\n\t\t */\n\t\tgetGoogleIsReadyToPayRequest() {\n\n\t\t\treturn Object.assign(\n\t\t\t\t{},\n\t\t\t\tthis.baseRequest,\n\t\t\t\t{\n\t\t\t\t\tallowedPaymentMethods: [ this.baseCardPaymentMethod ]\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\n\t\t/**\n\t\t * Configure support for the Google Pay API\n\t\t *\n\t\t * @see {@link https://developers.google.com/pay/api/web/reference/request-objects#PaymentDataRequest|PaymentDataRequest}\n\t\t *\n\t\t * @param {function} resolve callback\n\t\t * @returns {object} PaymentDataRequest fields\n\t\t */\n\t\tgetGooglePaymentDataRequest( resolve ) {\n\n\t\t\treturn this.getGoogleTransactionInfo( ( transactionInfo ) => {\n\n\t\t\t\tconst paymentDataRequest = Object.assign( {}, this.baseRequest );\n\t\t\t\tpaymentDataRequest.allowedPaymentMethods = [ this.cardPaymentMethod ];\n\t\t\t\tpaymentDataRequest.transactionInfo = transactionInfo;\n\t\t\t\tpaymentDataRequest.merchantInfo = {\n\t\t\t\t\tmerchantId: this.merchantID,\n\t\t\t\t\tmerchantName: this.merchantName\n\t\t\t\t};\n\n\t\t\t\tpaymentDataRequest.emailRequired = true;\n\t\t\t\tpaymentDataRequest.callbackIntents = [ 'PAYMENT_AUTHORIZATION' ];\n\n\t\t\t\tif ( this.needsShipping ) {\n\t\t\t\t\tpaymentDataRequest.callbackIntents = [ 'SHIPPING_ADDRESS', 'SHIPPING_OPTION', 'PAYMENT_AUTHORIZATION' ];\n\t\t\t\t\tpaymentDataRequest.shippingAddressRequired = true;\n\t\t\t\t\tpaymentDataRequest.shippingAddressParameters = this.getGoogleShippingAddressParameters();\n\t\t\t\t\tpaymentDataRequest.shippingOptionRequired = true;\n\t\t\t\t}\n\n\t\t\t\tresolve( paymentDataRequest );\n\t\t\t} );\n\t\t}\n\n\t\t/**\n\t\t * Return an active PaymentsClient or initialize\n\t\t *\n\t\t * @see {@link https://developers.google.com/pay/api/web/reference/client#PaymentsClient|PaymentsClient constructor}\n\t\t * @returns {google.payments.api.PaymentsClient} Google Pay API client\n\t\t */\n\t\tgetGooglePaymentsClient() {\n\t\t\tif ( this.paymentsClient === null ) {\n\t\t\t\tlet args = {\n\t\t\t\t\tenvironment: this.environment,\n\t\t\t\t\tmerchantInfo: {\n\t\t\t\t\t\tmerchantName: this.merchantName,\n\t\t\t\t\t\tmerchantId: this.merchantID\n\t\t\t\t\t},\n\t\t\t\t\tpaymentDataCallbacks: {\n\t\t\t\t\t\tonPaymentAuthorized: ( paymentData ) => this.onPaymentAuthorized( paymentData ),\n\t\t\t\t\t}\n\t\t\t\t};\n\n\t\t\t\tif ( this.needsShipping ) {\n\t\t\t\t\targs.paymentDataCallbacks.onPaymentDataChanged = ( paymentData ) => this.onPaymentDataChanged( paymentData );\n\t\t\t\t}\n\n\t\t\t\tthis.paymentsClient = new google.payments.api.PaymentsClient( args );\n\t\t\t}\n\t\t\treturn this.paymentsClient;\n\t\t}\n\n\t\t/**\n\t\t * Handles payment authorization callback intent.\n\t\t *\n\t\t * @param {object} paymentData response from Google Pay API after a payer approves payment.\n\t\t * @see {@link https://developers.google.com/pay/api/web/reference/response-objects#PaymentData|PaymentData object reference}\n\t\t *\n\t\t * @returns Promise<{object}> Promise object to complete or fail the transaction.\n\t\t */\n\t\tonPaymentAuthorized( paymentData ) {\n\n\t\t\tthis.blockUI();\n\n\t\t\treturn new Promise( (resolve, reject) => {\n\n\t\t\t\t// handle the response\n\t\t\t\ttry {\n\t\t\t\t\tthis.processPayment( paymentData, resolve );\n\t\t\t\t}\tcatch( err ) {\n\t\t\t\t\treject( {\n\t\t\t\t\t\ttransactionState: 'ERROR',\n\t\t\t\t\t\terror: {\n\t\t\t\t\t\t\tintent: 'PAYMENT_AUTHORIZATION',\n\t\t\t\t\t\t\tmessage: 'Payment could not be processed',\n\t\t\t\t\t\t\treason: 'PAYMENT_DATA_INVALID'\n\t\t\t\t\t\t}\n\t\t\t\t\t} );\n\t\t\t\t}\n\n\t\t\t\tthis.unblockUI();\n\t\t\t} );\n\t\t}\n\n\t\t/**\n\t\t * Handles dynamic buy flow shipping address and shipping options callback intents.\n\t\t *\n\t\t * @param {object} intermediatePaymentData response from Google Pay API a shipping address or shipping option is selected in the payment sheet.\n\t\t * @see {@link https://developers.google.com/pay/api/web/reference/response-objects#IntermediatePaymentData|IntermediatePaymentData object reference}\n\t\t *\n\t\t * @see {@link https://developers.google.com/pay/api/web/reference/response-objects#PaymentDataRequestUpdate|PaymentDataRequestUpdate}\n\t\t * @returns Promise<{object}> Promise of PaymentDataRequestUpdate object to update the payment sheet.\n\t\t */\n\t\tonPaymentDataChanged( intermediatePaymentData ) {\n\n\t\t\tthis.blockUI();\n\n\t\t\treturn new Promise(( resolve, reject ) => {\n\n\t\t\t\ttry {\n\t\t\t\t\tlet shippingAddress = intermediatePaymentData.shippingAddress;\n\t\t\t\t\tlet shippingOptionData = intermediatePaymentData.shippingOptionData;\n\t\t\t\t\tlet chosenShippingMethod = '';\n\n\t\t\t\t\tif ( intermediatePaymentData.callbackTrigger == 'SHIPPING_OPTION' ) {\n\t\t\t\t\t\tchosenShippingMethod = shippingOptionData.id;\n\t\t\t\t\t}\n\n\t\t\t\t\tthis.getUpdatedTotals( shippingAddress, chosenShippingMethod, ( paymentDataRequestUpdate ) => {\n\n\t\t\t\t\t\tif ( paymentDataRequestUpdate.newShippingOptionParameters.shippingOptions.length == 0 ) {\n\t\t\t\t\t\t\tpaymentDataRequestUpdate = {\n\t\t\t\t\t\t\t\terror: this.getGoogleUnserviceableAddressError()\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tresolve( paymentDataRequestUpdate );\n\t\t\t\t\t} );\n\n\t\t\t\t}\tcatch( err ) {\n\t\t\t\t\tthis.failPayment( 'Could not load updated totals or process payment data request update. ' + err );\n\t\t\t\t}\n\n\t\t\t\tthis.unblockUI();\n\t\t\t} );\n\t\t}\n\n\t\t/**\n\t\t * Provide Google Pay API with a payment amount, currency, and amount status\n\t\t *\n\t\t * @see {@link https://developers.google.com/pay/api/web/reference/request-objects#TransactionInfo|TransactionInfo}\n\t\t *\n\t\t * @param {function} resolve callback\n\t\t * @returns {object} transaction info, suitable for use as transactionInfo property of PaymentDataRequest\n\t\t */\n\t\tgetGoogleTransactionInfo( resolve ) {\n\n\t\t\t// get transaction info from cart\n\t\t\tconst data = {\n\t\t\t\taction: `wc_${this.gatewayID}_google_pay_get_transaction_info`,\n\t\t\t}\n\n\t\t\tif ( this.productID ) {\n\t\t\t\tdata.productID = this.productID;\n\t\t\t}\n\n\t\t\t$.post( this.ajaxURL, data, ( response ) => {\n\n\t\t\t\tif ( response.success ) {\n\t\t\t\t\tresolve( JSON.parse( response.data ) )\n\t\t\t\t} else {\n\t\t\t\t\tthis.failPayment( 'Could not build transaction info. ' + response.data.message );\n\t\t\t\t}\n\t\t\t} );\n\t\t}\n\n\t\t/**\n\t\t * Get updated totals and shipping options via AJAX for use in the PaymentDataRequest\n\t\t *\n\t\t * @see {@link https://developers.google.com/pay/api/web/reference/response-objects#PaymentDataRequestUpdate|PaymentDataRequestUpdate}\n\t\t *\n\t\t * @param {object} shippingAddress shipping address\n\t\t * @param {object} shippingMethod chosen shipping method\n\t\t * @param {function} resolve callback\n\t\t */\n\t\tgetUpdatedTotals( shippingAddress, shippingMethod, resolve ) {\n\n\t\t\tconst data = {\n\t\t\t\taction: `wc_${this.gatewayID}_google_pay_recalculate_totals`,\n\t\t\t\t'nonce': this.recalculateTotalsNonce,\n\t\t\t\tshippingAddress,\n\t\t\t\tshippingMethod\n\t\t\t}\n\n\t\t\tif ( this.productID ) {\n\t\t\t\tdata.productID = this.productID;\n\t\t\t}\n\n\t\t\t$.post( this.ajaxURL, data, ( response ) => {\n\n\t\t\t\tif ( response.success ) {\n\t\t\t\t\tresolve( JSON.parse( response.data ) )\n\t\t\t\t} else {\n\t\t\t\t\tthis.failPayment( 'Could not recalculate totals. ' + response.data.message );\n\t\t\t\t}\n\t\t\t} );\n\t\t}\n\n\t\t/**\n\t\t * Provide Google Pay API with shipping address parameters when using dynamic buy flow.\n\t\t *\n\t\t * @see {@link https://developers.google.com/pay/api/web/reference/request-objects#ShippingAddressParameters|ShippingAddressParameters}\n\t\t * @returns {object} shipping address details, suitable for use as shippingAddressParameters property of PaymentDataRequest\n\t\t */\n\t\tgetGoogleShippingAddressParameters() {\n\n\t\t\treturn {\n\t\t\t\tallowedCountryCodes: this.availableCountries\n\t\t\t};\n\t\t}\n\n\t\t/**\n\t\t * Provide Google Pay API with a payment data error.\n\t\t *\n\t\t * @see {@link https://developers.google.com/pay/api/web/reference/response-objects#PaymentDataError|PaymentDataError}\n\t\t * @returns {object} payment data error, suitable for use as error property of PaymentDataRequestUpdate\n\t\t */\n\t\tgetGoogleUnserviceableAddressError() {\n\t\t\treturn {\n\t\t\t\treason: 'SHIPPING_ADDRESS_UNSERVICEABLE',\n\t\t\t\tmessage: 'Cannot ship to the selected address',\n\t\t\t\tintent: 'SHIPPING_ADDRESS'\n\t\t\t};\n\t\t}\n\n\t\t/**\n\t\t * Add a Google Pay purchase button alongside an existing checkout button\n\t\t *\n\t\t * @see {@link https://developers.google.com/pay/api/web/reference/request-objects#ButtonOptions|Button options}\n\t\t * @see {@link https://developers.google.com/pay/api/web/guides/brand-guidelines|Google Pay brand guidelines}\n\t\t */\n\t\taddGooglePayButton() {\n\n\t\t\tconst paymentsClient = this.getGooglePaymentsClient();\n\t\t\tconst button = paymentsClient.createButton( {\n\t\t\t\tonClick: ( event ) => this.onGooglePaymentButtonClicked( event ),\n\t\t\t\tbuttonColor: this.buttonStyle,\n\t\t\t\tbuttonSizeMode: 'fill'\n\t\t\t} );\n\t\t\tdocument.getElementById( 'sv-wc-google-pay-button-container' ).appendChild( button );\n\t\t}\n\n\t\t/**\n\t\t * Prefetch payment data to improve performance\n\t\t *\n\t\t * @see {@link https://developers.google.com/pay/api/web/reference/client#prefetchPaymentData|prefetchPaymentData()}\n\t\t */\n\t\tprefetchGooglePaymentData() {\n\n\t\t\tthis.getGooglePaymentDataRequest( ( paymentDataRequest ) => {\n\n\t\t\t\t// transactionInfo must be set but does not affect cache\n\t\t\t\tpaymentDataRequest.transactionInfo = {\n\t\t\t\t\ttotalPriceStatus: 'NOT_CURRENTLY_KNOWN',\n\t\t\t\t\tcurrencyCode: this.currencyCode\n\t\t\t\t};\n\t\t\t\tconst paymentsClient = this.getGooglePaymentsClient();\n\t\t\t\tpaymentsClient.prefetchPaymentData( paymentDataRequest );\n\t\t\t} );\n\t\t}\n\n\t\t/**\n\t\t * Process payment data returned by the Google Pay API\n\t\t *\n\t\t * @see {@link https://developers.google.com/pay/api/web/reference/response-objects#PaymentData|PaymentData object reference}\n\t\t *\n\t\t * @param {object} paymentData response from Google Pay API after user approves payment\n\t\t * @param {function} resolve callback\n\t\t */\n\t\tprocessPayment( paymentData, resolve ) {\n\n\t\t\t// pass payment token to your gateway to process payment\n\t\t\tconst data = {\n\t\t\t\taction: `wc_${this.gatewayID}_google_pay_process_payment`,\n\t\t\t\tnonce: this.processNonce,\n\t\t\t\tpaymentData: JSON.stringify( paymentData ),\n\t\t\t}\n\n\t\t\tif ( this.productID && ! this.needsShipping ) {\n\t\t\t\tdata.productID = this.productID;\n\t\t\t}\n\n\t\t\treturn $.post( this.ajaxURL, data, ( response ) => {\n\t\t\t\tif ( response.success ) {\n\t\t\t\t\tresolve( {\n\t\t\t\t\t\ttransactionState: 'SUCCESS'\n\t\t\t\t\t} );\n\t\t\t\t\twindow.location = response.data.redirect;\n\t\t\t\t} else {\n\t\t\t\t\tresolve( {\n\t\t\t\t\t\ttransactionState: 'ERROR',\n\t\t\t\t\t\terror: {\n\t\t\t\t\t\t\tintent: 'SHIPPING_ADDRESS',\n\t\t\t\t\t\t\tmessage: 'Invalid data',\n\t\t\t\t\t\t\treason: 'PAYMENT_DATA_INVALID'\n\t\t\t\t\t\t}\n\t\t\t\t\t} );\n\t\t\t\t\tthis.failPayment( 'Payment could not be processed. ' + response.data.message );\n\t\t\t\t}\n\t\t\t} );\n\t\t}\n\n\t\t/**\n\t\t * Show Google Pay payment sheet when Google Pay payment button is clicked\n\t\t */\n\t\tonGooglePaymentButtonClicked( event ) {\n\n\t\t\tevent.preventDefault();\n\n\t\t\tthis.blockUI();\n\n\t\t\tthis.getGooglePaymentDataRequest( ( paymentDataRequest ) => {\n\n\t\t\t\tconst paymentsClient = this.getGooglePaymentsClient();\n\t\t\t\ttry {\n\t\t\t\t\tpaymentsClient.loadPaymentData( paymentDataRequest );\n\t\t\t\t} catch ( err ) {\n\t\t\t\t\tthis.failPayment( 'Could not load payment data. ' + err );\n\t\t\t\t}\n\n\t\t\t\tthis.unblockUI();\n\t\t\t} );\n\t\t}\n\n\t\t/**\n\t\t * Initialize Google PaymentsClient after Google-hosted JavaScript has loaded\n\t\t *\n\t\t * Display a Google Pay payment button after confirmation of the viewer's\n\t\t * ability to pay.\n\t\t */\n\t\tinit() {\n\n\t\t\t// initialize for the various pages\n\t\t\tif ( $( 'form.cart' ).length ) {\n\t\t\t\tthis.initProductPage();\n\t\t\t} else if ( $( 'form.woocommerce-cart-form' ).length ) {\n\t\t\t\tthis.initCartPage();\n\t\t\t} else if ( $( 'form.woocommerce-checkout' ).length) {\n\t\t\t\tthis.initCheckoutPage()\n\t\t\t} else {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tthis.initGooglePay();\n\t\t}\n\n\t\t/**\n\t\t * Initializes Google Pay.\n\t\t */\n\t\tinitGooglePay() {\n\n\t\t\tconst paymentsClient = this.getGooglePaymentsClient();\n\t\t\tpaymentsClient.isReadyToPay( this.getGoogleIsReadyToPayRequest() )\n\t\t\t\t.then( ( response ) => {\n\t\t\t\t\tif ( response.result ) {\n\t\t\t\t\t\tthis.addGooglePayButton();\n\t\t\t\t\t\t// prefetch payment data to improve performance\n\t\t\t\t\t\tthis.prefetchGooglePaymentData();\n\t\t\t\t\t}\n\t\t\t\t} )\n\t\t\t\t.catch( ( err ) => {\n\t\t\t\t\tthis.failPayment( 'Google Pay is not ready. ' + err );\n\t\t\t\t} );\n\t\t}\n\n\t\t/**\n\t\t * Initializes the product page.\n\t\t */\n\t\tinitProductPage() {\n\t\t\tthis.uiElement = $( 'form.cart' );\n\t\t}\n\n\t\t/**\n\t\t * Initializes the cart page.\n\t\t */\n\t\tinitCartPage() {\n\t\t\tthis.uiElement = $( 'form.woocommerce-cart-form' ).parents( 'div.woocommerce' );\n\n\t\t\t// re-init if the cart totals are updated\n\t\t\t$( document.body ).on( 'updated_cart_totals', () => {\n\t\t\t\tthis.initGooglePay();\n\t\t\t} );\n\t\t}\n\n\t\t/**\n\t\t * Initializes the checkout page.\n\t\t */\n\t\tinitCheckoutPage() {\n\t\t\tthis.uiElement = $( 'form.woocommerce-checkout' );\n\t\t}\n\n\t\t/**\n\t\t * Fails the purchase based on the gateway result.\n\t\t */\n\t\tfailPayment( error ) {\n\n\t\t\tconsole.error( '[Google Pay] ' + error );\n\n\t\t\tthis.unblockUI();\n\n\t\t\tthis.renderErrors( [ this.genericError ] );\n\t\t}\n\n\t\t/**\n\t\t * Renders any new errors and bring them into the viewport.\n \t\t */\n\t\trenderErrors( errors ) {\n\n\t\t\t// hide and remove any previous errors\n\t\t\t$( '.woocommerce-error, .woocommerce-message' ).remove();\n\n\t\t\t// add errors\n\t\t\tthis.uiElement.prepend( '
    • ' + errors.join( '
    • ' ) + '
    ' );\n\n\t\t\t// unblock UI\n\t\t\tthis.uiElement.removeClass( 'processing' ).unblock();\n\n\t\t\t// scroll to top\n\t\t\t$( 'html, body' ).animate( { scrollTop: this.uiElement.offset().top - 100 }, 1000 );\n\t\t}\n\n\t\t/**\n\t\t * Blocks the payment form UI.\n\t\t */\n\t\tblockUI() {\n\t\t\tthis.uiElement.block( { message: null, overlayCSS: { background: '#fff', opacity: 0.6 } } );\n\t\t}\n\n\t\t/**\n\t\t * Unblocks the payment form UI.\n\t\t */\n\t\tunblockUI() {\n\t\t\tthis.uiElement.unblock();\n\t\t}\n\t}\n\n\t$( document.body ).trigger( 'sv_wc_google_pay_handler_v5_13_0_loaded' );\n\n} );\n"]} \ No newline at end of file +{"version":3,"sources":["frontend/sv-wc-payment-gateway-google-pay.js"],"names":["jQuery","$","window","SV_WC_Google_Pay_Handler_v5_13_1","params","plugin_id","merchant_id","merchant_name","gateway_id","environment","gateway_id_dasherized","ajax_url","recalculate_totals_nonce","process_nonce","button_style","card_types","available_countries","currency_code","needs_shipping","generic_error","gatewayID","merchantID","merchantName","ajaxURL","recalculateTotalsNonce","processNonce","buttonStyle","availableCountries","currencyCode","needsShipping","genericError","product_id","productID","allowedCardNetworks","baseRequest","apiVersion","apiVersionMinor","allowedCardAuthMethods","tokenizationSpecification","type","parameters","baseCardPaymentMethod","allowedAuthMethods","billingAddressRequired","billingAddressParameters","format","phoneNumberRequired","cardPaymentMethod","Object","assign","paymentsClient","allowedPaymentMethods","resolve","getGoogleTransactionInfo","transactionInfo","paymentDataRequest","merchantInfo","merchantId","emailRequired","callbackIntents","shippingAddressRequired","shippingAddressParameters","getGoogleShippingAddressParameters","shippingOptionRequired","args","paymentDataCallbacks","onPaymentAuthorized","paymentData","onPaymentDataChanged","google","payments","api","PaymentsClient","blockUI","Promise","reject","processPayment","err","transactionState","error","intent","message","reason","unblockUI","intermediatePaymentData","shippingAddress","shippingOptionData","chosenShippingMethod","callbackTrigger","id","getUpdatedTotals","paymentDataRequestUpdate","newShippingOptionParameters","shippingOptions","length","getGoogleUnserviceableAddressError","failPayment","data","action","post","response","success","JSON","parse","shippingMethod","allowedCountryCodes","button","getGooglePaymentsClient","createButton","onClick","event","onGooglePaymentButtonClicked","buttonColor","buttonSizeMode","document","getElementById","appendChild","getGooglePaymentDataRequest","totalPriceStatus","prefetchPaymentData","nonce","stringify","location","redirect","preventDefault","loadPaymentData","initProductPage","initCartPage","initCheckoutPage","initGooglePay","isReadyToPay","getGoogleIsReadyToPayRequest","then","result","addGooglePayButton","prefetchGooglePaymentData","catch","uiElement","parents","body","on","console","renderErrors","errors","remove","prepend","join","removeClass","unblock","animate","scrollTop","offset","top","block","overlayCSS","background","opacity","trigger"],"mappings":";AAAA,SAAA,EAAA,GAAA,OAAA,EAAA,mBAAA,QAAA,iBAAA,OAAA,SAAA,SAAA,GAAA,cAAA,GAAA,SAAA,GAAA,OAAA,GAAA,mBAAA,QAAA,EAAA,cAAA,QAAA,IAAA,OAAA,UAAA,gBAAA,IAAA,GAAA,SAAA,EAAA,EAAA,G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A,IAAA,eA2hBC,MAAA,WAAe,IAAA,EAAA,KACTwI,KAAAA,UAAYxI,EAAG,8BAA+ByI,QAAS,mBAG5DzI,EAAGiH,SAASyB,MAAOC,GAAI,sBAAuB,WAC7C,EAAKX,oBAhiBR,CAAA,IAAA,mBAuiBC,MAAA,WACMQ,KAAAA,UAAYxI,EAAG,+BAxiBtB,CAAA,IAAA,cA8iBC,MAAA,SAAa8E,GAEZ8D,QAAQ9D,MAAO,gBAAkBA,GAE5BI,KAAAA,YAEA2D,KAAAA,aAAc,CAAE,KAAKhH,iBApjB5B,CAAA,IAAA,eA0jBC,MAAA,SAAciH,GAGb9I,EAAG,4CAA6C+I,SAG3CP,KAAAA,UAAUQ,QAAS,qCAAuCF,EAAOG,KAAM,aAAgB,cAGvFT,KAAAA,UAAUU,YAAa,cAAeC,UAG3CnJ,EAAG,cAAeoJ,QAAS,CAAEC,UAAW,KAAKb,UAAUc,SAASC,IAAM,KAAO,OAtkB/E,CAAA,IAAA,UA4kBC,MAAA,WACMf,KAAAA,UAAUgB,MAAO,CAAExE,QAAS,KAAMyE,WAAY,CAAEC,WAAY,OAAQC,QAAS,QA7kBpF,CAAA,IAAA,YAmlBC,MAAA,WACMnB,KAAAA,UAAUW,cAplBjB,GAwlBAnJ,EAAGiH,SAASyB,MAAOkB,QAAS","file":"sv-wc-payment-gateway-google-pay.js","sourceRoot":"../js","sourcesContent":["jQuery( function( $ ) {\n\n\t\"use strict\"\n\n\t/**\n\t * Google Pay handler.\n\t *\n\t * @since 5.10.0\n\t *\n\t * @type {SV_WC_Google_Pay_Handler_v5_13_1} object\n\t */\n\twindow.SV_WC_Google_Pay_Handler_v5_13_1 = class SV_WC_Google_Pay_Handler_v5_13_1 {\n\n\t\t/**\n\t\t * Handler constructor.\n\t\t *\n\t\t * @since 5.10.0\n\t\t *\n\t\t * @param {Object} params The plugin ID\n\t\t * @param {string} params.plugin_id The plugin ID\n\t\t * @param {string} params.merchant_id The merchant ID\n\t\t * @param {string} params.merchant_name The site name\n\t\t * @param {string} params.gateway_id The gateway ID\n\t\t * @param {string} params.gateway_id_dasherized The gateway ID dasherized\n\t\t * @param {string} params.environment The gateway environment (PRODUCTION or TEST)\n\t\t * @param {string} params.ajax_url The AJAX URL\n\t\t * @param {string} params.recalculate_totals_nonce Nonce for the recalculate_totals AJAX action\n\t\t * @param {string} params.process_nonce Nonce for the process AJAX action\n\t\t * @param {string} params.button_style The button style\n\t\t * @param {string[]} params.card_types The supported card types\n\t\t * @param {string[]} params.available_countries Array of two-letter country codes the gateway is available for\n\t\t * @param {string[]} params.currency_code WC configured currency\n\t\t * @param {boolean} params.needs_shipping Whether or not the cart or product needs shipping\n\t\t * @param {string} params.generic_error The generic error message\n\t\t * @param {string} params.product_id The product ID if we are on a Product page\n\t\t */\n\t\tconstructor( params ) {\n\n\t\t\tlet {\n\t\t\t\tplugin_id,\n\t\t\t\tmerchant_id,\n\t\t\t\tmerchant_name,\n\t\t\t\tgateway_id,\n\t\t\t\tgateway_id_dasherized,\n\t\t\t\tenvironment,\n\t\t\t\tajax_url,\n\t\t\t\trecalculate_totals_nonce,\n\t\t\t\tprocess_nonce,\n\t\t\t\tbutton_style,\n\t\t\t\tcard_types,\n\t\t\t\tavailable_countries,\n\t\t\t\tcurrency_code,\n\t\t\t\tneeds_shipping,\n\t\t\t\tgeneric_error\n\t\t\t} = params;\n\n\t\t\tthis.gatewayID = gateway_id;\n\t\t\tthis.merchantID = merchant_id;\n\t\t\tthis.merchantName = merchant_name;\n\t\t\tthis.environment = environment;\n\t\t\tthis.ajaxURL = ajax_url;\n\t\t\tthis.recalculateTotalsNonce = recalculate_totals_nonce;\n\t\t\tthis.processNonce = process_nonce;\n\t\t\tthis.buttonStyle = button_style;\n\t\t\tthis.availableCountries = available_countries;\n\t\t\tthis.currencyCode = currency_code;\n\t\t\tthis.needsShipping = needs_shipping;\n\t\t\tthis.genericError = generic_error;\n\n\t\t\tif ( params.product_id ) {\n\t\t\t\tthis.productID = params.product_id;\n\t\t\t}\n\n\t\t\t/**\n\t\t\t * Card networks supported by your site and your gateway\n\t\t\t *\n\t\t\t * @see {@link https://developers.google.com/pay/api/web/reference/request-objects#CardParameters|CardParameters}\n\t\t\t */\n\t\t\tconst allowedCardNetworks = card_types;\n\n\t\t\t/**\n\t\t\t * Define the version of the Google Pay API referenced when creating your configuration\n\t\t\t *\n\t\t\t * @see {@link https://developers.google.com/pay/api/web/reference/request-objects#PaymentDataRequest|apiVersion in PaymentDataRequest}\n\t\t\t */\n\t\t\tthis.baseRequest = {\n\t\t\t\tapiVersion: 2,\n\t\t\t\tapiVersionMinor: 0\n\t\t\t};\n\n\t\t\t/**\n\t\t\t * Card authentication methods supported by your site and your gateway\n\t\t\t *\n\t\t\t * @see {@link https://developers.google.com/pay/api/web/reference/request-objects#CardParameters|CardParameters}\n\t\t\t *\n\t\t\t * @todo confirm your processor supports Android device tokens for your supported card networks\n\t\t\t */\n\t\t\tconst allowedCardAuthMethods = [ 'PAN_ONLY', 'CRYPTOGRAM_3DS' ];\n\n\t\t\t/**\n\t\t\t * Identify your gateway and your site's gateway merchant identifier\n\t\t\t *\n\t\t\t * The Google Pay API response will return an encrypted payment method capable\n\t\t\t * of being charged by a supported gateway after payer authorization\n\t\t\t *\n\t\t\t * @see {@link https://developers.google.com/pay/api/web/reference/request-objects#gateway|PaymentMethodTokenizationSpecification}\n\t\t\t */\n\t\t\tconst tokenizationSpecification = {\n\t\t\t\ttype: 'PAYMENT_GATEWAY',\n\t\t\t\tparameters: {\n\t\t\t\t\t'gateway': plugin_id,\n\t\t\t\t\t'gatewayMerchantId': this.merchantID\n\t\t\t\t}\n\t\t\t};\n\n\t\t\t/**\n\t\t\t * Describe your site's support for the CARD payment method and its required fields\n\t\t\t *\n\t\t\t * @see {@link https://developers.google.com/pay/api/web/reference/request-objects#CardParameters|CardParameters}\n\t\t\t */\n\t\t\tthis.baseCardPaymentMethod = {\n\t\t\t\ttype: 'CARD',\n\t\t\t\tparameters: {\n\t\t\t\t\tallowedAuthMethods: allowedCardAuthMethods,\n\t\t\t\t\tallowedCardNetworks: allowedCardNetworks,\n\t\t\t\t\tbillingAddressRequired: true,\n\t\t\t\t\tbillingAddressParameters: {\n\t\t\t\t\t\tformat: 'FULL',\n\t\t\t\t\t\tphoneNumberRequired: true\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t};\n\n\t\t\t/**\n\t\t\t * Describe your site's support for the CARD payment method including optional fields\n\t\t\t *\n\t\t\t * @see {@link https://developers.google.com/pay/api/web/reference/request-objects#CardParameters|CardParameters}\n\t\t\t */\n\t\t\tthis.cardPaymentMethod = Object.assign(\n\t\t\t\t{},\n\t\t\t\tthis.baseCardPaymentMethod,\n\t\t\t\t{\n\t\t\t\t\ttokenizationSpecification: tokenizationSpecification\n\t\t\t\t}\n\t\t\t);\n\n\t\t\t/**\n\t\t\t * An initialized google.payments.api.PaymentsClient object or null if not yet set\n\t\t\t *\n\t\t\t * @see {@link getGooglePaymentsClient}\n\t\t\t */\n\t\t\tthis.paymentsClient = null;\n\t\t}\n\n\t\t/**\n\t\t * Configure your site's support for payment methods supported by the Google Pay\n\t\t * API.\n\t\t *\n\t\t * Each member of allowedPaymentMethods should contain only the required fields,\n\t\t * allowing reuse of this base request when determining a viewer's ability\n\t\t * to pay and later requesting a supported payment method\n\t\t *\n\t\t * @returns {object} Google Pay API version, payment methods supported by the site\n\t\t */\n\t\tgetGoogleIsReadyToPayRequest() {\n\n\t\t\treturn Object.assign(\n\t\t\t\t{},\n\t\t\t\tthis.baseRequest,\n\t\t\t\t{\n\t\t\t\t\tallowedPaymentMethods: [ this.baseCardPaymentMethod ]\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\n\t\t/**\n\t\t * Configure support for the Google Pay API\n\t\t *\n\t\t * @see {@link https://developers.google.com/pay/api/web/reference/request-objects#PaymentDataRequest|PaymentDataRequest}\n\t\t *\n\t\t * @param {function} resolve callback\n\t\t * @returns {object} PaymentDataRequest fields\n\t\t */\n\t\tgetGooglePaymentDataRequest( resolve ) {\n\n\t\t\treturn this.getGoogleTransactionInfo( ( transactionInfo ) => {\n\n\t\t\t\tconst paymentDataRequest = Object.assign( {}, this.baseRequest );\n\t\t\t\tpaymentDataRequest.allowedPaymentMethods = [ this.cardPaymentMethod ];\n\t\t\t\tpaymentDataRequest.transactionInfo = transactionInfo;\n\t\t\t\tpaymentDataRequest.merchantInfo = {\n\t\t\t\t\tmerchantId: this.merchantID,\n\t\t\t\t\tmerchantName: this.merchantName\n\t\t\t\t};\n\n\t\t\t\tpaymentDataRequest.emailRequired = true;\n\t\t\t\tpaymentDataRequest.callbackIntents = [ 'PAYMENT_AUTHORIZATION' ];\n\n\t\t\t\tif ( this.needsShipping ) {\n\t\t\t\t\tpaymentDataRequest.callbackIntents = [ 'SHIPPING_ADDRESS', 'SHIPPING_OPTION', 'PAYMENT_AUTHORIZATION' ];\n\t\t\t\t\tpaymentDataRequest.shippingAddressRequired = true;\n\t\t\t\t\tpaymentDataRequest.shippingAddressParameters = this.getGoogleShippingAddressParameters();\n\t\t\t\t\tpaymentDataRequest.shippingOptionRequired = true;\n\t\t\t\t}\n\n\t\t\t\tresolve( paymentDataRequest );\n\t\t\t} );\n\t\t}\n\n\t\t/**\n\t\t * Return an active PaymentsClient or initialize\n\t\t *\n\t\t * @see {@link https://developers.google.com/pay/api/web/reference/client#PaymentsClient|PaymentsClient constructor}\n\t\t * @returns {google.payments.api.PaymentsClient} Google Pay API client\n\t\t */\n\t\tgetGooglePaymentsClient() {\n\t\t\tif ( this.paymentsClient === null ) {\n\t\t\t\tlet args = {\n\t\t\t\t\tenvironment: this.environment,\n\t\t\t\t\tmerchantInfo: {\n\t\t\t\t\t\tmerchantName: this.merchantName,\n\t\t\t\t\t\tmerchantId: this.merchantID\n\t\t\t\t\t},\n\t\t\t\t\tpaymentDataCallbacks: {\n\t\t\t\t\t\tonPaymentAuthorized: ( paymentData ) => this.onPaymentAuthorized( paymentData ),\n\t\t\t\t\t}\n\t\t\t\t};\n\n\t\t\t\tif ( this.needsShipping ) {\n\t\t\t\t\targs.paymentDataCallbacks.onPaymentDataChanged = ( paymentData ) => this.onPaymentDataChanged( paymentData );\n\t\t\t\t}\n\n\t\t\t\tthis.paymentsClient = new google.payments.api.PaymentsClient( args );\n\t\t\t}\n\t\t\treturn this.paymentsClient;\n\t\t}\n\n\t\t/**\n\t\t * Handles payment authorization callback intent.\n\t\t *\n\t\t * @param {object} paymentData response from Google Pay API after a payer approves payment.\n\t\t * @see {@link https://developers.google.com/pay/api/web/reference/response-objects#PaymentData|PaymentData object reference}\n\t\t *\n\t\t * @returns Promise<{object}> Promise object to complete or fail the transaction.\n\t\t */\n\t\tonPaymentAuthorized( paymentData ) {\n\n\t\t\tthis.blockUI();\n\n\t\t\treturn new Promise( (resolve, reject) => {\n\n\t\t\t\t// handle the response\n\t\t\t\ttry {\n\t\t\t\t\tthis.processPayment( paymentData, resolve );\n\t\t\t\t}\tcatch( err ) {\n\t\t\t\t\treject( {\n\t\t\t\t\t\ttransactionState: 'ERROR',\n\t\t\t\t\t\terror: {\n\t\t\t\t\t\t\tintent: 'PAYMENT_AUTHORIZATION',\n\t\t\t\t\t\t\tmessage: 'Payment could not be processed',\n\t\t\t\t\t\t\treason: 'PAYMENT_DATA_INVALID'\n\t\t\t\t\t\t}\n\t\t\t\t\t} );\n\t\t\t\t}\n\n\t\t\t\tthis.unblockUI();\n\t\t\t} );\n\t\t}\n\n\t\t/**\n\t\t * Handles dynamic buy flow shipping address and shipping options callback intents.\n\t\t *\n\t\t * @param {object} intermediatePaymentData response from Google Pay API a shipping address or shipping option is selected in the payment sheet.\n\t\t * @see {@link https://developers.google.com/pay/api/web/reference/response-objects#IntermediatePaymentData|IntermediatePaymentData object reference}\n\t\t *\n\t\t * @see {@link https://developers.google.com/pay/api/web/reference/response-objects#PaymentDataRequestUpdate|PaymentDataRequestUpdate}\n\t\t * @returns Promise<{object}> Promise of PaymentDataRequestUpdate object to update the payment sheet.\n\t\t */\n\t\tonPaymentDataChanged( intermediatePaymentData ) {\n\n\t\t\tthis.blockUI();\n\n\t\t\treturn new Promise(( resolve, reject ) => {\n\n\t\t\t\ttry {\n\t\t\t\t\tlet shippingAddress = intermediatePaymentData.shippingAddress;\n\t\t\t\t\tlet shippingOptionData = intermediatePaymentData.shippingOptionData;\n\t\t\t\t\tlet chosenShippingMethod = '';\n\n\t\t\t\t\tif ( intermediatePaymentData.callbackTrigger == 'SHIPPING_OPTION' ) {\n\t\t\t\t\t\tchosenShippingMethod = shippingOptionData.id;\n\t\t\t\t\t}\n\n\t\t\t\t\tthis.getUpdatedTotals( shippingAddress, chosenShippingMethod, ( paymentDataRequestUpdate ) => {\n\n\t\t\t\t\t\tif ( paymentDataRequestUpdate.newShippingOptionParameters.shippingOptions.length == 0 ) {\n\t\t\t\t\t\t\tpaymentDataRequestUpdate = {\n\t\t\t\t\t\t\t\terror: this.getGoogleUnserviceableAddressError()\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tresolve( paymentDataRequestUpdate );\n\t\t\t\t\t} );\n\n\t\t\t\t}\tcatch( err ) {\n\t\t\t\t\tthis.failPayment( 'Could not load updated totals or process payment data request update. ' + err );\n\t\t\t\t}\n\n\t\t\t\tthis.unblockUI();\n\t\t\t} );\n\t\t}\n\n\t\t/**\n\t\t * Provide Google Pay API with a payment amount, currency, and amount status\n\t\t *\n\t\t * @see {@link https://developers.google.com/pay/api/web/reference/request-objects#TransactionInfo|TransactionInfo}\n\t\t *\n\t\t * @param {function} resolve callback\n\t\t * @returns {object} transaction info, suitable for use as transactionInfo property of PaymentDataRequest\n\t\t */\n\t\tgetGoogleTransactionInfo( resolve ) {\n\n\t\t\t// get transaction info from cart\n\t\t\tconst data = {\n\t\t\t\taction: `wc_${this.gatewayID}_google_pay_get_transaction_info`,\n\t\t\t}\n\n\t\t\tif ( this.productID ) {\n\t\t\t\tdata.productID = this.productID;\n\t\t\t}\n\n\t\t\t$.post( this.ajaxURL, data, ( response ) => {\n\n\t\t\t\tif ( response.success ) {\n\t\t\t\t\tresolve( JSON.parse( response.data ) )\n\t\t\t\t} else {\n\t\t\t\t\tthis.failPayment( 'Could not build transaction info. ' + response.data.message );\n\t\t\t\t}\n\t\t\t} );\n\t\t}\n\n\t\t/**\n\t\t * Get updated totals and shipping options via AJAX for use in the PaymentDataRequest\n\t\t *\n\t\t * @see {@link https://developers.google.com/pay/api/web/reference/response-objects#PaymentDataRequestUpdate|PaymentDataRequestUpdate}\n\t\t *\n\t\t * @param {object} shippingAddress shipping address\n\t\t * @param {object} shippingMethod chosen shipping method\n\t\t * @param {function} resolve callback\n\t\t */\n\t\tgetUpdatedTotals( shippingAddress, shippingMethod, resolve ) {\n\n\t\t\tconst data = {\n\t\t\t\taction: `wc_${this.gatewayID}_google_pay_recalculate_totals`,\n\t\t\t\t'nonce': this.recalculateTotalsNonce,\n\t\t\t\tshippingAddress,\n\t\t\t\tshippingMethod\n\t\t\t}\n\n\t\t\tif ( this.productID ) {\n\t\t\t\tdata.productID = this.productID;\n\t\t\t}\n\n\t\t\t$.post( this.ajaxURL, data, ( response ) => {\n\n\t\t\t\tif ( response.success ) {\n\t\t\t\t\tresolve( JSON.parse( response.data ) )\n\t\t\t\t} else {\n\t\t\t\t\tthis.failPayment( 'Could not recalculate totals. ' + response.data.message );\n\t\t\t\t}\n\t\t\t} );\n\t\t}\n\n\t\t/**\n\t\t * Provide Google Pay API with shipping address parameters when using dynamic buy flow.\n\t\t *\n\t\t * @see {@link https://developers.google.com/pay/api/web/reference/request-objects#ShippingAddressParameters|ShippingAddressParameters}\n\t\t * @returns {object} shipping address details, suitable for use as shippingAddressParameters property of PaymentDataRequest\n\t\t */\n\t\tgetGoogleShippingAddressParameters() {\n\n\t\t\treturn {\n\t\t\t\tallowedCountryCodes: this.availableCountries\n\t\t\t};\n\t\t}\n\n\t\t/**\n\t\t * Provide Google Pay API with a payment data error.\n\t\t *\n\t\t * @see {@link https://developers.google.com/pay/api/web/reference/response-objects#PaymentDataError|PaymentDataError}\n\t\t * @returns {object} payment data error, suitable for use as error property of PaymentDataRequestUpdate\n\t\t */\n\t\tgetGoogleUnserviceableAddressError() {\n\t\t\treturn {\n\t\t\t\treason: 'SHIPPING_ADDRESS_UNSERVICEABLE',\n\t\t\t\tmessage: 'Cannot ship to the selected address',\n\t\t\t\tintent: 'SHIPPING_ADDRESS'\n\t\t\t};\n\t\t}\n\n\t\t/**\n\t\t * Add a Google Pay purchase button alongside an existing checkout button\n\t\t *\n\t\t * @see {@link https://developers.google.com/pay/api/web/reference/request-objects#ButtonOptions|Button options}\n\t\t * @see {@link https://developers.google.com/pay/api/web/guides/brand-guidelines|Google Pay brand guidelines}\n\t\t */\n\t\taddGooglePayButton() {\n\n\t\t\tconst paymentsClient = this.getGooglePaymentsClient();\n\t\t\tconst button = paymentsClient.createButton( {\n\t\t\t\tonClick: ( event ) => this.onGooglePaymentButtonClicked( event ),\n\t\t\t\tbuttonColor: this.buttonStyle,\n\t\t\t\tbuttonSizeMode: 'fill'\n\t\t\t} );\n\t\t\tdocument.getElementById( 'sv-wc-google-pay-button-container' ).appendChild( button );\n\t\t}\n\n\t\t/**\n\t\t * Prefetch payment data to improve performance\n\t\t *\n\t\t * @see {@link https://developers.google.com/pay/api/web/reference/client#prefetchPaymentData|prefetchPaymentData()}\n\t\t */\n\t\tprefetchGooglePaymentData() {\n\n\t\t\tthis.getGooglePaymentDataRequest( ( paymentDataRequest ) => {\n\n\t\t\t\t// transactionInfo must be set but does not affect cache\n\t\t\t\tpaymentDataRequest.transactionInfo = {\n\t\t\t\t\ttotalPriceStatus: 'NOT_CURRENTLY_KNOWN',\n\t\t\t\t\tcurrencyCode: this.currencyCode\n\t\t\t\t};\n\t\t\t\tconst paymentsClient = this.getGooglePaymentsClient();\n\t\t\t\tpaymentsClient.prefetchPaymentData( paymentDataRequest );\n\t\t\t} );\n\t\t}\n\n\t\t/**\n\t\t * Process payment data returned by the Google Pay API\n\t\t *\n\t\t * @see {@link https://developers.google.com/pay/api/web/reference/response-objects#PaymentData|PaymentData object reference}\n\t\t *\n\t\t * @param {object} paymentData response from Google Pay API after user approves payment\n\t\t * @param {function} resolve callback\n\t\t */\n\t\tprocessPayment( paymentData, resolve ) {\n\n\t\t\t// pass payment token to your gateway to process payment\n\t\t\tconst data = {\n\t\t\t\taction: `wc_${this.gatewayID}_google_pay_process_payment`,\n\t\t\t\tnonce: this.processNonce,\n\t\t\t\tpaymentData: JSON.stringify( paymentData ),\n\t\t\t}\n\n\t\t\tif ( this.productID && ! this.needsShipping ) {\n\t\t\t\tdata.productID = this.productID;\n\t\t\t}\n\n\t\t\treturn $.post( this.ajaxURL, data, ( response ) => {\n\t\t\t\tif ( response.success ) {\n\t\t\t\t\tresolve( {\n\t\t\t\t\t\ttransactionState: 'SUCCESS'\n\t\t\t\t\t} );\n\t\t\t\t\twindow.location = response.data.redirect;\n\t\t\t\t} else {\n\t\t\t\t\tresolve( {\n\t\t\t\t\t\ttransactionState: 'ERROR',\n\t\t\t\t\t\terror: {\n\t\t\t\t\t\t\tintent: 'SHIPPING_ADDRESS',\n\t\t\t\t\t\t\tmessage: 'Invalid data',\n\t\t\t\t\t\t\treason: 'PAYMENT_DATA_INVALID'\n\t\t\t\t\t\t}\n\t\t\t\t\t} );\n\t\t\t\t\tthis.failPayment( 'Payment could not be processed. ' + response.data.message );\n\t\t\t\t}\n\t\t\t} );\n\t\t}\n\n\t\t/**\n\t\t * Show Google Pay payment sheet when Google Pay payment button is clicked\n\t\t */\n\t\tonGooglePaymentButtonClicked( event ) {\n\n\t\t\tevent.preventDefault();\n\n\t\t\tthis.blockUI();\n\n\t\t\tthis.getGooglePaymentDataRequest( ( paymentDataRequest ) => {\n\n\t\t\t\tconst paymentsClient = this.getGooglePaymentsClient();\n\t\t\t\ttry {\n\t\t\t\t\tpaymentsClient.loadPaymentData( paymentDataRequest );\n\t\t\t\t} catch ( err ) {\n\t\t\t\t\tthis.failPayment( 'Could not load payment data. ' + err );\n\t\t\t\t}\n\n\t\t\t\tthis.unblockUI();\n\t\t\t} );\n\t\t}\n\n\t\t/**\n\t\t * Initialize Google PaymentsClient after Google-hosted JavaScript has loaded\n\t\t *\n\t\t * Display a Google Pay payment button after confirmation of the viewer's\n\t\t * ability to pay.\n\t\t */\n\t\tinit() {\n\n\t\t\t// initialize for the various pages\n\t\t\tif ( $( 'form.cart' ).length ) {\n\t\t\t\tthis.initProductPage();\n\t\t\t} else if ( $( 'form.woocommerce-cart-form' ).length ) {\n\t\t\t\tthis.initCartPage();\n\t\t\t} else if ( $( 'form.woocommerce-checkout' ).length) {\n\t\t\t\tthis.initCheckoutPage()\n\t\t\t} else {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tthis.initGooglePay();\n\t\t}\n\n\t\t/**\n\t\t * Initializes Google Pay.\n\t\t */\n\t\tinitGooglePay() {\n\n\t\t\tconst paymentsClient = this.getGooglePaymentsClient();\n\t\t\tpaymentsClient.isReadyToPay( this.getGoogleIsReadyToPayRequest() )\n\t\t\t\t.then( ( response ) => {\n\t\t\t\t\tif ( response.result ) {\n\t\t\t\t\t\tthis.addGooglePayButton();\n\t\t\t\t\t\t// prefetch payment data to improve performance\n\t\t\t\t\t\tthis.prefetchGooglePaymentData();\n\t\t\t\t\t}\n\t\t\t\t} )\n\t\t\t\t.catch( ( err ) => {\n\t\t\t\t\tthis.failPayment( 'Google Pay is not ready. ' + err );\n\t\t\t\t} );\n\t\t}\n\n\t\t/**\n\t\t * Initializes the product page.\n\t\t */\n\t\tinitProductPage() {\n\t\t\tthis.uiElement = $( 'form.cart' );\n\t\t}\n\n\t\t/**\n\t\t * Initializes the cart page.\n\t\t */\n\t\tinitCartPage() {\n\t\t\tthis.uiElement = $( 'form.woocommerce-cart-form' ).parents( 'div.woocommerce' );\n\n\t\t\t// re-init if the cart totals are updated\n\t\t\t$( document.body ).on( 'updated_cart_totals', () => {\n\t\t\t\tthis.initGooglePay();\n\t\t\t} );\n\t\t}\n\n\t\t/**\n\t\t * Initializes the checkout page.\n\t\t */\n\t\tinitCheckoutPage() {\n\t\t\tthis.uiElement = $( 'form.woocommerce-checkout' );\n\t\t}\n\n\t\t/**\n\t\t * Fails the purchase based on the gateway result.\n\t\t */\n\t\tfailPayment( error ) {\n\n\t\t\tconsole.error( '[Google Pay] ' + error );\n\n\t\t\tthis.unblockUI();\n\n\t\t\tthis.renderErrors( [ this.genericError ] );\n\t\t}\n\n\t\t/**\n\t\t * Renders any new errors and bring them into the viewport.\n \t\t */\n\t\trenderErrors( errors ) {\n\n\t\t\t// hide and remove any previous errors\n\t\t\t$( '.woocommerce-error, .woocommerce-message' ).remove();\n\n\t\t\t// add errors\n\t\t\tthis.uiElement.prepend( '
    • ' + errors.join( '
    • ' ) + '
    ' );\n\n\t\t\t// unblock UI\n\t\t\tthis.uiElement.removeClass( 'processing' ).unblock();\n\n\t\t\t// scroll to top\n\t\t\t$( 'html, body' ).animate( { scrollTop: this.uiElement.offset().top - 100 }, 1000 );\n\t\t}\n\n\t\t/**\n\t\t * Blocks the payment form UI.\n\t\t */\n\t\tblockUI() {\n\t\t\tthis.uiElement.block( { message: null, overlayCSS: { background: '#fff', opacity: 0.6 } } );\n\t\t}\n\n\t\t/**\n\t\t * Unblocks the payment form UI.\n\t\t */\n\t\tunblockUI() {\n\t\t\tthis.uiElement.unblock();\n\t\t}\n\t}\n\n\t$( document.body ).trigger( 'sv_wc_google_pay_handler_v5_13_1_loaded' );\n\n} );\n"]} diff --git a/woocommerce/payment-gateway/assets/dist/frontend/sv-wc-payment-gateway-my-payment-methods.js b/woocommerce/payment-gateway/assets/dist/frontend/sv-wc-payment-gateway-my-payment-methods.js index fbc015ca9..c107dd5aa 100644 --- a/woocommerce/payment-gateway/assets/dist/frontend/sv-wc-payment-gateway-my-payment-methods.js +++ b/woocommerce/payment-gateway/assets/dist/frontend/sv-wc-payment-gateway-my-payment-methods.js @@ -1,4 +1,4 @@ parcelRequire=function(e,r,t,n){var i,o="function"==typeof parcelRequire&&parcelRequire,u="function"==typeof require&&require;function f(t,n){if(!r[t]){if(!e[t]){var i="function"==typeof parcelRequire&&parcelRequire;if(!n&&i)return i(t,!0);if(o)return o(t,!0);if(u&&"string"==typeof t)return u(t);var c=new Error("Cannot find module '"+t+"'");throw c.code="MODULE_NOT_FOUND",c}p.resolve=function(r){return e[t][1][r]||r},p.cache={};var l=r[t]=new f.Module(t);e[t][0].call(l.exports,p,l,l.exports,this)}return r[t].exports;function p(e){return f(p.resolve(e))}}f.isParcelRequire=!0,f.Module=function(e){this.id=e,this.bundle=f,this.exports={}},f.modules=e,f.cache=r,f.parent=o,f.register=function(r,t){e[r]=[function(e,r){r.exports=t},{}]};for(var c=0;c0&&e(o).find("td.woocommerce-PaymentMethod--method").html(i.html()),e(o).find("td.woocommerce-PaymentMethod--title").remove()})}},{key:"remove_duplicate_default_marks",value:function(){return e(".woocommerce-MyAccount-paymentMethods").find("tr").each(function(t,n){return e(n).find("td.woocommerce-PaymentMethod--default").find("mark.default:not(:first-child)").remove()})}},{key:"edit_method",value:function(t){var n,o;if(t.preventDefault(),0!==(o=(n=e(t.currentTarget)).parents("tr")).find("input[name=plugin-id][value=".concat(this.slug,"]")).length)return o.find("div.view").hide(),o.find("div.edit").show(),o.addClass("editing"),n.text(this.i18n.cancel_button).removeClass("edit").addClass("cancel-edit").removeClass("button"),this.enable_editing_ui()}},{key:"save_method",value:function(t){var n,o,i,a=this;if(t.preventDefault(),n=e(t.currentTarget),0!==(i=n.parents("tr")).find("input[name=plugin-id][value=".concat(this.slug,"]")).length)return this.block_ui(),i.next(".error").remove(),o={action:"wc_".concat(this.id,"_save_payment_method"),nonce:this.ajax_nonce,token_id:i.find("input[name=token-id]").val(),data:i.find("input[name]").serialize()},e.post(this.ajax_url,o).done(function(e){return e.success?(null!=e.data.title&&i.find(".woocommerce-PaymentMethod--method").html(e.data.title),null!=e.data.nonce&&(a.ajax_nonce=e.data.nonce),n.siblings(".cancel-edit").removeClass("cancel-edit").addClass("edit").text(a.i18n.edit_button).addClass("button"),i.removeClass("editing"),a.disable_editing_ui()):a.display_error(i,e.data)}).fail(function(e,t,n){return a.display_error(i,n)}).always(function(){return a.unblock_ui()})}},{key:"cancel_edit",value:function(t){var n,o;if(t.preventDefault(),0!==(o=(n=e(t.currentTarget)).parents("tr")).find("input[name=plugin-id][value=".concat(this.slug,"]")).length)return o.find("div.view").show(),o.find("div.edit").hide(),o.removeClass("editing"),n.removeClass("cancel-edit").addClass("edit").text(this.i18n.edit_button).addClass("button"),this.disable_editing_ui()}},{key:"enable_editing_ui",value:function(){return e(".woocommerce-MyAccount-paymentMethods").addClass("editing"),e('.button[href*="add-payment-method"]').addClass("disabled")}},{key:"disable_editing_ui",value:function(){return e(".woocommerce-MyAccount-paymentMethods").removeClass("editing"),e('.button[href*="add-payment-method"]').removeClass("disabled")}},{key:"block_ui",value:function(){return e(".woocommerce-MyAccount-paymentMethods").parent("div").block({message:null,overlayCSS:{background:"#fff",opacity:.6}})}},{key:"unblock_ui",value:function(){return e(".woocommerce-MyAccount-paymentMethods").parent("div").unblock()}},{key:"display_error",value:function(t,n){var o,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";return console.error(n),i||(i=this.i18n.save_error),o=e(".woocommerce-MyAccount-paymentMethods thead tr th").length,e(''+i+"").insertAfter(t).find("td").delay(8e3).slideUp(200)}}])}(),e(document.body).trigger("sv_wc_payment_methods_handler_v5_13_0_loaded")})}).call(this); +function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(t)}function t(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function n(e,t){for(var n=0;n0&&e(o).find("td.woocommerce-PaymentMethod--method").html(i.html()),e(o).find("td.woocommerce-PaymentMethod--title").remove()})}},{key:"remove_duplicate_default_marks",value:function(){return e(".woocommerce-MyAccount-paymentMethods").find("tr").each(function(t,n){return e(n).find("td.woocommerce-PaymentMethod--default").find("mark.default:not(:first-child)").remove()})}},{key:"edit_method",value:function(t){var n,o;if(t.preventDefault(),0!==(o=(n=e(t.currentTarget)).parents("tr")).find("input[name=plugin-id][value=".concat(this.slug,"]")).length)return o.find("div.view").hide(),o.find("div.edit").show(),o.addClass("editing"),n.text(this.i18n.cancel_button).removeClass("edit").addClass("cancel-edit").removeClass("button"),this.enable_editing_ui()}},{key:"save_method",value:function(t){var n,o,i,a=this;if(t.preventDefault(),n=e(t.currentTarget),0!==(i=n.parents("tr")).find("input[name=plugin-id][value=".concat(this.slug,"]")).length)return this.block_ui(),i.next(".error").remove(),o={action:"wc_".concat(this.id,"_save_payment_method"),nonce:this.ajax_nonce,token_id:i.find("input[name=token-id]").val(),data:i.find("input[name]").serialize()},e.post(this.ajax_url,o).done(function(e){return e.success?(null!=e.data.title&&i.find(".woocommerce-PaymentMethod--method").html(e.data.title),null!=e.data.nonce&&(a.ajax_nonce=e.data.nonce),n.siblings(".cancel-edit").removeClass("cancel-edit").addClass("edit").text(a.i18n.edit_button).addClass("button"),i.removeClass("editing"),a.disable_editing_ui()):a.display_error(i,e.data)}).fail(function(e,t,n){return a.display_error(i,n)}).always(function(){return a.unblock_ui()})}},{key:"cancel_edit",value:function(t){var n,o;if(t.preventDefault(),0!==(o=(n=e(t.currentTarget)).parents("tr")).find("input[name=plugin-id][value=".concat(this.slug,"]")).length)return o.find("div.view").show(),o.find("div.edit").hide(),o.removeClass("editing"),n.removeClass("cancel-edit").addClass("edit").text(this.i18n.edit_button).addClass("button"),this.disable_editing_ui()}},{key:"enable_editing_ui",value:function(){return e(".woocommerce-MyAccount-paymentMethods").addClass("editing"),e('.button[href*="add-payment-method"]').addClass("disabled")}},{key:"disable_editing_ui",value:function(){return e(".woocommerce-MyAccount-paymentMethods").removeClass("editing"),e('.button[href*="add-payment-method"]').removeClass("disabled")}},{key:"block_ui",value:function(){return e(".woocommerce-MyAccount-paymentMethods").parent("div").block({message:null,overlayCSS:{background:"#fff",opacity:.6}})}},{key:"unblock_ui",value:function(){return e(".woocommerce-MyAccount-paymentMethods").parent("div").unblock()}},{key:"display_error",value:function(t,n){var o,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";return console.error(n),i||(i=this.i18n.save_error),o=e(".woocommerce-MyAccount-paymentMethods thead tr th").length,e(''+i+"").insertAfter(t).find("td").delay(8e3).slideUp(200)}}])}(),e(document.body).trigger("sv_wc_payment_methods_handler_v5_13_1_loaded")})}).call(this); },{}]},{},["nDDW"], null) -//# sourceMappingURL=../frontend/sv-wc-payment-gateway-my-payment-methods.js.map \ No newline at end of file +//# sourceMappingURL=../frontend/sv-wc-payment-gateway-my-payment-methods.js.map diff --git a/woocommerce/payment-gateway/assets/dist/frontend/sv-wc-payment-gateway-my-payment-methods.js.map b/woocommerce/payment-gateway/assets/dist/frontend/sv-wc-payment-gateway-my-payment-methods.js.map index ea1e2df90..d9171fe90 100644 --- a/woocommerce/payment-gateway/assets/dist/frontend/sv-wc-payment-gateway-my-payment-methods.js.map +++ b/woocommerce/payment-gateway/assets/dist/frontend/sv-wc-payment-gateway-my-payment-methods.js.map @@ -1 +1 @@ -{"version":3,"sources":["frontend/sv-wc-payment-gateway-my-payment-methods.coffee"],"names":["jQuery","$","window","SV_WC_Payment_Methods_Handler_v5_13_0","args","replace_method_column","bind","remove_duplicate_default_marks","edit_method","save_method","cancel_edit","id","slug","i18n","ajax_url","ajax_nonce","on","event","row","currentTarget","parents","find","length","confirm","delete_ays","preventDefault","hasClass","each","index","element","titleColumn","remove","children","html","button","hide","show","addClass","text","cancel_button","removeClass","enable_editing_ui","data","block_ui","next","action","nonce","token_id","val","serialize","post","done","response","success","title","siblings","edit_button","disable_editing_ui","display_error","fail","jqXHR","textStatus","error","always","unblock_ui","parent","block","message","overlayCSS","background","opacity","unblock","columns","console","save_error","insertAfter","delay","slideUp","document","body","trigger","call"],"mappings":";AAAA,SAAA,EAAA,GAAA,OAAA,EAAA,mBAAA,QAAA,iBAAA,OAAA,SAAA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K,MAAMuD,MAAM,KAAMC,QAAQ,SA9O1I,GAmPO5E,EAAE6E,SAASC,MAAMC,QAAQ,oDAGjCC,KAAK","file":"sv-wc-payment-gateway-my-payment-methods.js","sourceRoot":"../js","sourcesContent":["(function() {\n /*\n WooCommerce SkyVerge Payment Gateway My Payment Methods CoffeeScript\n Version 5.1.0\n\n Copyright (c) 2014-2024, SkyVerge, Inc.\n Licensed under the GNU General Public License v3.0\n http://www.gnu.org/licenses/gpl-3.0.html\n */\n jQuery(function($) {\n \"use strict\";\n // The My Payment Methods handler.\n\n // @since 5.1.0\n window.SV_WC_Payment_Methods_Handler_v5_13_0 = class SV_WC_Payment_Methods_Handler_v5_13_0 {\n // Constructs the class.\n\n // @since 5.1.0\n\n // @param [Object] args, with the properties:\n // id: [String] plugin ID\n // slug: [String] plugin slug or dasherized ID\n // i18n: [Object] localized text strings\n // ajax_url: [String] URL for AJAX requests\n // ajax_nonce: [String] nonce for AJAX requests\n constructor(args) {\n // Replace Method column content with Title column content, for FW tokens.\n\n // @since 5.8.0\n this.replace_method_column = this.replace_method_column.bind(this);\n // Removes duplicate \"Default\" marks.\n\n // They are already hidden using CSS, but should also be removed for accessibility.\n\n // @since 5.8.0\n this.remove_duplicate_default_marks = this.remove_duplicate_default_marks.bind(this);\n // Edits a payment method.\n\n // @since 5.1.0\n\n // @param [Object] event jQuery event object\n this.edit_method = this.edit_method.bind(this);\n // Saves a payment method.\n\n // @since 5.1.0\n\n // @param [Object] event jQuery event object\n this.save_method = this.save_method.bind(this);\n // Cancels/stop editing a payment method.\n\n // @since 5.1.0\n\n // @param [Object] event jQuery event object\n this.cancel_edit = this.cancel_edit.bind(this);\n this.id = args.id;\n this.slug = args.slug;\n this.i18n = args.i18n;\n this.ajax_url = args.ajax_url;\n this.ajax_nonce = args.ajax_nonce;\n // replace the \"Method\" column content for FW tokens\n this.replace_method_column();\n // remove duplicate \"Default\" marks\n this.remove_duplicate_default_marks();\n // handle the edit action\n $(\".woocommerce-MyAccount-paymentMethods\").on('click', \".woocommerce-PaymentMethod--actions .button.edit\", (event) => {\n return this.edit_method(event);\n });\n // handle the save action\n $(\".woocommerce-MyAccount-paymentMethods\").on('click', \".woocommerce-PaymentMethod--actions .button.save\", (event) => {\n return this.save_method(event);\n });\n // handle the cancel action\n $(\".woocommerce-MyAccount-paymentMethods\").on('click', \".woocommerce-PaymentMethod--actions .cancel-edit\", (event) => {\n return this.cancel_edit(event);\n });\n // handle the delete action\n $(\".woocommerce-MyAccount-paymentMethods\").on('click', \".woocommerce-PaymentMethod--actions .button.delete\", (event) => {\n var button, row;\n button = $(event.currentTarget);\n row = button.parents('tr');\n // check if the method belongs to this plugin\n if (row.find(`input[name=plugin-id][value=${this.slug}]`).length === 0) {\n return;\n }\n if (!confirm(this.i18n.delete_ays)) {\n return event.preventDefault();\n }\n });\n // don't follow the Add Payment Method button URL if it's disabled\n $('.button[href*=\"add-payment-method\"]').on('click', event(function() {\n if ($(this).hasClass('disabled')) {\n return event.preventDefault();\n }\n }));\n }\n\n replace_method_column() {\n return $('.woocommerce-MyAccount-paymentMethods').find('tr').each((index, element) => {\n var titleColumn;\n // check if the method belongs to this plugin\n if ($(element).find(`input[name=plugin-id][value=${this.slug}]`).length === 0) {\n return;\n }\n // delete the Title header\n $(element).find('th.woocommerce-PaymentMethod--title').remove();\n titleColumn = $(element).find('td.woocommerce-PaymentMethod--title');\n // Title column is not empty, this is a FW token\n if (titleColumn.children().length > 0) {\n // replace Method column\n $(element).find('td.woocommerce-PaymentMethod--method').html(titleColumn.html());\n }\n // delete Title column\n return $(element).find('td.woocommerce-PaymentMethod--title').remove();\n });\n }\n\n remove_duplicate_default_marks() {\n return $('.woocommerce-MyAccount-paymentMethods').find('tr').each((index, element) => {\n return $(element).find('td.woocommerce-PaymentMethod--default').find('mark.default:not(:first-child)').remove();\n });\n }\n\n edit_method(event) {\n var button, row;\n event.preventDefault();\n button = $(event.currentTarget);\n row = button.parents('tr');\n // check if the method belongs to this plugin\n if (row.find(`input[name=plugin-id][value=${this.slug}]`).length === 0) {\n return;\n }\n row.find('div.view').hide();\n row.find('div.edit').show();\n row.addClass('editing');\n // change the Edit button to \"Cancel\"\n button.text(this.i18n.cancel_button).removeClass('edit').addClass('cancel-edit').removeClass('button');\n return this.enable_editing_ui();\n }\n\n save_method(event) {\n var button, data, row;\n event.preventDefault();\n button = $(event.currentTarget);\n row = button.parents('tr');\n // check if the method belongs to this plugin\n if (row.find(`input[name=plugin-id][value=${this.slug}]`).length === 0) {\n return;\n }\n this.block_ui();\n // remove any previous errors\n row.next('.error').remove();\n data = {\n action: `wc_${this.id}_save_payment_method`,\n nonce: this.ajax_nonce,\n token_id: row.find('input[name=token-id]').val(),\n data: row.find('input[name]').serialize()\n };\n return $.post(this.ajax_url, data).done((response) => {\n if (!response.success) {\n return this.display_error(row, response.data);\n }\n if (response.data.title != null) {\n row.find('.woocommerce-PaymentMethod--method').html(response.data.title);\n }\n if (response.data.nonce != null) {\n this.ajax_nonce = response.data.nonce;\n }\n // change the \"Cancel\" button back to \"Edit\"\n button.siblings('.cancel-edit').removeClass('cancel-edit').addClass('edit').text(this.i18n.edit_button).addClass('button');\n row.removeClass('editing');\n return this.disable_editing_ui();\n }).fail((jqXHR, textStatus, error) => {\n return this.display_error(row, error);\n }).always(() => {\n return this.unblock_ui();\n });\n }\n\n cancel_edit(event) {\n var button, row;\n event.preventDefault();\n button = $(event.currentTarget);\n row = button.parents('tr');\n // check if the method belongs to this plugin\n if (row.find(`input[name=plugin-id][value=${this.slug}]`).length === 0) {\n return;\n }\n row.find('div.view').show();\n row.find('div.edit').hide();\n row.removeClass('editing');\n // change the \"Cancel\" button back to \"Edit\"\n button.removeClass('cancel-edit').addClass('edit').text(this.i18n.edit_button).addClass('button');\n return this.disable_editing_ui();\n }\n\n // Sets the page UI to the \"editing\" state.\n\n // This brings proper focus to the method being edited and prevents\n // other available buttons/actions until the editing is finished or cancelled.\n\n // @since 5.1.1\n enable_editing_ui() {\n // set the methods table as 'editing'\n $(\".woocommerce-MyAccount-paymentMethods\").addClass('editing');\n // disable the Add Payment Method button\n return $('.button[href*=\"add-payment-method\"]').addClass('disabled');\n }\n\n // Sets the page UI back to the default state.\n\n // @since 5.1.1\n disable_editing_ui() {\n // removes the methods table's \"editing\" status\n $(\".woocommerce-MyAccount-paymentMethods\").removeClass('editing');\n // re-enable the Add Payment Method button\n return $('.button[href*=\"add-payment-method\"]').removeClass('disabled');\n }\n\n // Blocks the payment methods table UI.\n\n // @since 5.1.0\n block_ui() {\n return $(\".woocommerce-MyAccount-paymentMethods\").parent('div').block({\n message: null,\n overlayCSS: {\n background: '#fff',\n opacity: 0.6\n }\n });\n }\n\n // Unblocks the payment methods table UI.\n\n // @since 5.1.0\n unblock_ui() {\n return $(\".woocommerce-MyAccount-paymentMethods\").parent('div').unblock();\n }\n\n // Displays an error message to the user.\n\n // @since 5.1.0\n\n // @param [Object] row payment method table row\n // @param [String] error raw error message\n // @param [String] message user error message\n display_error(row, error, message = '') {\n var columns;\n console.error(error);\n if (!message) {\n message = this.i18n.save_error;\n }\n columns = $(\".woocommerce-MyAccount-paymentMethods thead tr th\").length;\n return $('' + message + '').insertAfter(row).find('td').delay(8000).slideUp(200);\n }\n\n };\n // dispatch loaded event\n return $(document.body).trigger('sv_wc_payment_methods_handler_v5_13_0_loaded');\n });\n\n}).call(this);\n"]} \ No newline at end of file +{"version":3,"sources":["frontend/sv-wc-payment-gateway-my-payment-methods.coffee"],"names":["jQuery","$","window","SV_WC_Payment_Methods_Handler_v5_13_1","args","replace_method_column","bind","remove_duplicate_default_marks","edit_method","save_method","cancel_edit","id","slug","i18n","ajax_url","ajax_nonce","on","event","row","currentTarget","parents","find","length","confirm","delete_ays","preventDefault","hasClass","each","index","element","titleColumn","remove","children","html","button","hide","show","addClass","text","cancel_button","removeClass","enable_editing_ui","data","block_ui","next","action","nonce","token_id","val","serialize","post","done","response","success","title","siblings","edit_button","disable_editing_ui","display_error","fail","jqXHR","textStatus","error","always","unblock_ui","parent","block","message","overlayCSS","background","opacity","unblock","columns","console","save_error","insertAfter","delay","slideUp","document","body","trigger","call"],"mappings":";AAAA,SAAA,EAAA,GAAA,OAAA,EAAA,mBAAA,QAAA,iBAAA,OAAA,SAAA,SAAA,GAAA,cAAA,GAAA,SAAA,GAAA,OAAA,GAAA,mBAAA,QAAA,EAAA,cAAA,QAAA,IAAA,OAAA,UAAA,gBAAA,IAAA,GAAA,SAAA,EAAA,EAAA,GAAA,KAAA,aAAA,GAAA,MAAA,IAAA,UAAA,qCAAA,SAAA,EAAA,EAAA,GAAA,IAAA,IAAA,EAAA,EAAA,EAAA,EAAA,OAAA,IAAA,CAAA,IAAA,EAAA,EAAA,GAAA,EAAA,WAAA,EAAA,aAAA,EAAA,EAAA,cAAA,EAAA,UAAA,IAAA,EAAA,UAAA,GAAA,OAAA,eAAA,EAAA,EAAA,EAAA,KAAA,IAAA,SAAA,EAAA,EAAA,EAAA,GAAA,OAAA,GAAA,EAAA,EAAA,UAAA,GAAA,GAAA,EAAA,EAAA,GAAA,OAAA,eAAA,EAAA,YAAA,CAAA,UAAA,IAAA,EAAA,SAAA,EAAA,GAAA,IAAA,EAAA,EAAA,EAAA,UAAA,MAAA,UAAA,EAAA,GAAA,EAAA,EAAA,GAAA,SAAA,EAAA,EAAA,GAAA,GAAA,UAAA,EAAA,KAAA,EAAA,OAAA,EAAA,IAAA,EAAA,EAAA,OAAA,aAAA,QAAA,IAAA,EAAA,CAAA,IAAA,EAAA,EAAA,KAAA,EAAA,GAAA,WAAA,GAAA,UAAA,EAAA,GAAA,OAAA,EAAA,MAAA,IAAA,UAAA,gDAAA,OAAA,WAAA,EAAA,OAAA,QAAA,IAAA,WASEA,OAAO,SAASC,GAAG,aAwPVA,OAnPPC,OAAOC,sCAAP,WAAA,OAAA,EAWcC,SAAAA,EAAAA,GAAM,IAAA,EAAA,KAAA,EAAA,KAAA,GAIXC,KAAAA,sBAAwB,KAAKA,sBAAsBC,KAAK,MAMxDC,KAAAA,+BAAiC,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ACTK,IACHA,EAAU,KAAKtD,KAAK6D,YAEtBF,EAAUvE,EAAE,qDAAqDqB,OAC1DrB,EAAE,kCAAoCuE,EAAU,KAAOL,EAAU,cAAcQ,YAAYzD,GAAKG,KAAK,MAAMuD,MAAM,KAAMC,QAAQ,SA9O1I,GAmPO5E,EAAE6E,SAASC,MAAMC,QAAQ,oDAGjCC,KAAK","file":"sv-wc-payment-gateway-my-payment-methods.js","sourceRoot":"../js","sourcesContent":["(function() {\n /*\n WooCommerce SkyVerge Payment Gateway My Payment Methods CoffeeScript\n Version 5.1.0\n\n Copyright (c) 2014-2024, SkyVerge, Inc.\n Licensed under the GNU General Public License v3.0\n http://www.gnu.org/licenses/gpl-3.0.html\n */\n jQuery(function($) {\n \"use strict\";\n // The My Payment Methods handler.\n\n // @since 5.1.0\n window.SV_WC_Payment_Methods_Handler_v5_13_1 = class SV_WC_Payment_Methods_Handler_v5_13_1 {\n // Constructs the class.\n\n // @since 5.1.0\n\n // @param [Object] args, with the properties:\n // id: [String] plugin ID\n // slug: [String] plugin slug or dasherized ID\n // i18n: [Object] localized text strings\n // ajax_url: [String] URL for AJAX requests\n // ajax_nonce: [String] nonce for AJAX requests\n constructor(args) {\n // Replace Method column content with Title column content, for FW tokens.\n\n // @since 5.8.0\n this.replace_method_column = this.replace_method_column.bind(this);\n // Removes duplicate \"Default\" marks.\n\n // They are already hidden using CSS, but should also be removed for accessibility.\n\n // @since 5.8.0\n this.remove_duplicate_default_marks = this.remove_duplicate_default_marks.bind(this);\n // Edits a payment method.\n\n // @since 5.1.0\n\n // @param [Object] event jQuery event object\n this.edit_method = this.edit_method.bind(this);\n // Saves a payment method.\n\n // @since 5.1.0\n\n // @param [Object] event jQuery event object\n this.save_method = this.save_method.bind(this);\n // Cancels/stop editing a payment method.\n\n // @since 5.1.0\n\n // @param [Object] event jQuery event object\n this.cancel_edit = this.cancel_edit.bind(this);\n this.id = args.id;\n this.slug = args.slug;\n this.i18n = args.i18n;\n this.ajax_url = args.ajax_url;\n this.ajax_nonce = args.ajax_nonce;\n // replace the \"Method\" column content for FW tokens\n this.replace_method_column();\n // remove duplicate \"Default\" marks\n this.remove_duplicate_default_marks();\n // handle the edit action\n $(\".woocommerce-MyAccount-paymentMethods\").on('click', \".woocommerce-PaymentMethod--actions .button.edit\", (event) => {\n return this.edit_method(event);\n });\n // handle the save action\n $(\".woocommerce-MyAccount-paymentMethods\").on('click', \".woocommerce-PaymentMethod--actions .button.save\", (event) => {\n return this.save_method(event);\n });\n // handle the cancel action\n $(\".woocommerce-MyAccount-paymentMethods\").on('click', \".woocommerce-PaymentMethod--actions .cancel-edit\", (event) => {\n return this.cancel_edit(event);\n });\n // handle the delete action\n $(\".woocommerce-MyAccount-paymentMethods\").on('click', \".woocommerce-PaymentMethod--actions .button.delete\", (event) => {\n var button, row;\n button = $(event.currentTarget);\n row = button.parents('tr');\n // check if the method belongs to this plugin\n if (row.find(`input[name=plugin-id][value=${this.slug}]`).length === 0) {\n return;\n }\n if (!confirm(this.i18n.delete_ays)) {\n return event.preventDefault();\n }\n });\n // don't follow the Add Payment Method button URL if it's disabled\n $('.button[href*=\"add-payment-method\"]').on('click', event(function() {\n if ($(this).hasClass('disabled')) {\n return event.preventDefault();\n }\n }));\n }\n\n replace_method_column() {\n return $('.woocommerce-MyAccount-paymentMethods').find('tr').each((index, element) => {\n var titleColumn;\n // check if the method belongs to this plugin\n if ($(element).find(`input[name=plugin-id][value=${this.slug}]`).length === 0) {\n return;\n }\n // delete the Title header\n $(element).find('th.woocommerce-PaymentMethod--title').remove();\n titleColumn = $(element).find('td.woocommerce-PaymentMethod--title');\n // Title column is not empty, this is a FW token\n if (titleColumn.children().length > 0) {\n // replace Method column\n $(element).find('td.woocommerce-PaymentMethod--method').html(titleColumn.html());\n }\n // delete Title column\n return $(element).find('td.woocommerce-PaymentMethod--title').remove();\n });\n }\n\n remove_duplicate_default_marks() {\n return $('.woocommerce-MyAccount-paymentMethods').find('tr').each((index, element) => {\n return $(element).find('td.woocommerce-PaymentMethod--default').find('mark.default:not(:first-child)').remove();\n });\n }\n\n edit_method(event) {\n var button, row;\n event.preventDefault();\n button = $(event.currentTarget);\n row = button.parents('tr');\n // check if the method belongs to this plugin\n if (row.find(`input[name=plugin-id][value=${this.slug}]`).length === 0) {\n return;\n }\n row.find('div.view').hide();\n row.find('div.edit').show();\n row.addClass('editing');\n // change the Edit button to \"Cancel\"\n button.text(this.i18n.cancel_button).removeClass('edit').addClass('cancel-edit').removeClass('button');\n return this.enable_editing_ui();\n }\n\n save_method(event) {\n var button, data, row;\n event.preventDefault();\n button = $(event.currentTarget);\n row = button.parents('tr');\n // check if the method belongs to this plugin\n if (row.find(`input[name=plugin-id][value=${this.slug}]`).length === 0) {\n return;\n }\n this.block_ui();\n // remove any previous errors\n row.next('.error').remove();\n data = {\n action: `wc_${this.id}_save_payment_method`,\n nonce: this.ajax_nonce,\n token_id: row.find('input[name=token-id]').val(),\n data: row.find('input[name]').serialize()\n };\n return $.post(this.ajax_url, data).done((response) => {\n if (!response.success) {\n return this.display_error(row, response.data);\n }\n if (response.data.title != null) {\n row.find('.woocommerce-PaymentMethod--method').html(response.data.title);\n }\n if (response.data.nonce != null) {\n this.ajax_nonce = response.data.nonce;\n }\n // change the \"Cancel\" button back to \"Edit\"\n button.siblings('.cancel-edit').removeClass('cancel-edit').addClass('edit').text(this.i18n.edit_button).addClass('button');\n row.removeClass('editing');\n return this.disable_editing_ui();\n }).fail((jqXHR, textStatus, error) => {\n return this.display_error(row, error);\n }).always(() => {\n return this.unblock_ui();\n });\n }\n\n cancel_edit(event) {\n var button, row;\n event.preventDefault();\n button = $(event.currentTarget);\n row = button.parents('tr');\n // check if the method belongs to this plugin\n if (row.find(`input[name=plugin-id][value=${this.slug}]`).length === 0) {\n return;\n }\n row.find('div.view').show();\n row.find('div.edit').hide();\n row.removeClass('editing');\n // change the \"Cancel\" button back to \"Edit\"\n button.removeClass('cancel-edit').addClass('edit').text(this.i18n.edit_button).addClass('button');\n return this.disable_editing_ui();\n }\n\n // Sets the page UI to the \"editing\" state.\n\n // This brings proper focus to the method being edited and prevents\n // other available buttons/actions until the editing is finished or cancelled.\n\n // @since 5.1.1\n enable_editing_ui() {\n // set the methods table as 'editing'\n $(\".woocommerce-MyAccount-paymentMethods\").addClass('editing');\n // disable the Add Payment Method button\n return $('.button[href*=\"add-payment-method\"]').addClass('disabled');\n }\n\n // Sets the page UI back to the default state.\n\n // @since 5.1.1\n disable_editing_ui() {\n // removes the methods table's \"editing\" status\n $(\".woocommerce-MyAccount-paymentMethods\").removeClass('editing');\n // re-enable the Add Payment Method button\n return $('.button[href*=\"add-payment-method\"]').removeClass('disabled');\n }\n\n // Blocks the payment methods table UI.\n\n // @since 5.1.0\n block_ui() {\n return $(\".woocommerce-MyAccount-paymentMethods\").parent('div').block({\n message: null,\n overlayCSS: {\n background: '#fff',\n opacity: 0.6\n }\n });\n }\n\n // Unblocks the payment methods table UI.\n\n // @since 5.1.0\n unblock_ui() {\n return $(\".woocommerce-MyAccount-paymentMethods\").parent('div').unblock();\n }\n\n // Displays an error message to the user.\n\n // @since 5.1.0\n\n // @param [Object] row payment method table row\n // @param [String] error raw error message\n // @param [String] message user error message\n display_error(row, error, message = '') {\n var columns;\n console.error(error);\n if (!message) {\n message = this.i18n.save_error;\n }\n columns = $(\".woocommerce-MyAccount-paymentMethods thead tr th\").length;\n return $('' + message + '').insertAfter(row).find('td').delay(8000).slideUp(200);\n }\n\n };\n // dispatch loaded event\n return $(document.body).trigger('sv_wc_payment_methods_handler_v5_13_1_loaded');\n });\n\n}).call(this);\n"]} diff --git a/woocommerce/payment-gateway/assets/dist/frontend/sv-wc-payment-gateway-payment-form.js b/woocommerce/payment-gateway/assets/dist/frontend/sv-wc-payment-gateway-payment-form.js index 3d6522020..4e69a7d12 100644 --- a/woocommerce/payment-gateway/assets/dist/frontend/sv-wc-payment-gateway-payment-form.js +++ b/woocommerce/payment-gateway/assets/dist/frontend/sv-wc-payment-gateway-payment-form.js @@ -1,4 +1,4 @@ parcelRequire=function(e,r,t,n){var i,o="function"==typeof parcelRequire&&parcelRequire,u="function"==typeof require&&require;function f(t,n){if(!r[t]){if(!e[t]){var i="function"==typeof parcelRequire&&parcelRequire;if(!n&&i)return i(t,!0);if(o)return o(t,!0);if(u&&"string"==typeof t)return u(t);var c=new Error("Cannot find module '"+t+"'");throw c.code="MODULE_NOT_FOUND",c}p.resolve=function(r){return e[t][1][r]||r},p.cache={};var l=r[t]=new f.Module(t);e[t][0].call(l.exports,p,l,l.exports,this)}return r[t].exports;function p(e){return f(p.resolve(e))}}f.isParcelRequire=!0,f.Module=function(e){this.id=e,this.bundle=f,this.exports={}},f.modules=e,f.cache=r,f.parent=o,f.register=function(r,t){e[r]=[function(e,r){r.exports=t},{}]};for(var c=0;c0&&e.trigger("change"),r.val()&&r.val().length>0&&r.trigger("change"),t.val()&&t.val().length>0&&t.trigger("change"),a(".js-sv-wc-payment-gateway-credit-card-form-input").on("change paste keyup",function(){return n.do_inline_credit_card_validation()})}},{key:"do_inline_credit_card_validation",value:function(){var t,r,n,i;return t=a(".js-sv-wc-payment-gateway-credit-card-form-account-number"),i=a(".js-sv-wc-payment-gateway-credit-card-form-expiry"),n=a(".js-sv-wc-payment-gateway-credit-card-form-csc"),r=a.payment.cardType(t.val()),e.call(this.enabled_card_types,r)<0?t.addClass("invalid-card-type"):t.removeClass("invalid-card-type"),a.payment.validateCardExpiry(i.payment("cardExpiryVal"))?i.addClass("identified"):i.removeClass("identified"),a.payment.validateCardCVC(n.val())?n.addClass("identified"):n.removeClass("identified")}},{key:"validate_card_data",value:function(){var e,t,r,n;return r=[],null!=(t=this.payment_fields.find(".js-sv-wc-payment-gateway-credit-card-form-csc").val())&&(t?(/\D/.test(t)&&r.push(this.params.cvv_digits_invalid),(t.length<3||t.length>4)&&r.push(this.params.cvv_length_invalid)):this.csc_required&&(this.saved_payment_method_selected&&!this.csc_required_for_tokens||r.push(this.params.cvv_missing))),this.saved_payment_method_selected||(e=this.payment_fields.find(".js-sv-wc-payment-gateway-credit-card-form-account-number").val(),n=a.payment.cardExpiryVal(this.payment_fields.find(".js-sv-wc-payment-gateway-credit-card-form-expiry").val()),(e=e.replace(/-|\s/g,""))?((e.length<12||e.length>19)&&r.push(this.params.card_number_length_invalid),/\D/.test(e)&&r.push(this.params.card_number_digits_invalid),a.payment.validateCardNumber(e)||r.push(this.params.card_number_invalid)):r.push(this.params.card_number_missing),a.payment.validateCardExpiry(n)||r.push(this.params.card_exp_date_invalid)),r.length>0?(this.render_errors(r),!1):(this.payment_fields.find(".js-sv-wc-payment-gateway-credit-card-form-account-number").val(e),!0)}},{key:"validate_account_data",value:function(){var e,t,a;return!!this.saved_payment_method_selected||(t=[],a=this.payment_fields.find(".js-sv-wc-payment-gateway-echeck-form-routing-number").val(),e=this.payment_fields.find(".js-sv-wc-payment-gateway-echeck-form-account-number").val(),a?(9!==a.length&&t.push(this.params.routing_number_length_invalid),/\D/.test(a)&&t.push(this.params.routing_number_digits_invalid)):t.push(this.params.routing_number_missing),e?((e.length<3||e.length>17)&&t.push(this.params.account_number_length_invalid),/\D/.test(e)&&t.push(this.params.account_number_invalid)):t.push(this.params.account_number_missing),t.length>0?(this.render_errors(t),!1):(this.payment_fields.find(".js-sv-wc-payment-gateway-echeck-form-account-number").val(e),!0))}},{key:"render_errors",value:function(e){return a(".woocommerce-error, .woocommerce-message").remove(),this.form.prepend('
    • '+e.join("
    • ")+"
    "),this.form.removeClass("processing").unblock(),this.form.find(".input-text, select").blur(),a("html, body").animate({scrollTop:this.form.offset().top-100},1e3)}},{key:"handle_saved_payment_methods",value:function(){var e,t,r,n;if(n=this.id_dasherized,this.csc_required,r=this.csc_required_for_tokens,t=a("div.js-wc-".concat(n,"-new-payment-method-form")),e=t.find(".js-sv-wc-payment-gateway-credit-card-form-csc").closest(".form-row"),a("input.js-wc-".concat(this.id_dasherized,"-payment-token")).on("change",function(){if(a("input.js-wc-".concat(n,"-payment-token:checked")).val()){if(t.slideUp(200),r)return e.removeClass("form-row-last").addClass("form-row-first"),t.after(e)}else if(t.slideDown(200),r)return e.removeClass("form-row-first").addClass("form-row-last"),t.find(".js-sv-wc-payment-gateway-credit-card-form-expiry").closest(".form-row").after(e)}).change(),a("input#createaccount").on("change",function(){var e;return e=a("input.js-wc-".concat(n,"-tokenize-payment-method")).closest("p.form-row"),a(this).is(":checked")?(e.slideDown(),e.next().show()):(e.hide(),e.next().hide())}),!a("input#createaccount").is(":checked"))return a("input#createaccount").change()}},{key:"handle_sample_check_hint",value:function(){var e;return(e=this.payment_fields.find(".js-sv-wc-payment-gateway-echeck-form-sample-check")).is(":visible")?e.slideUp():e.slideDown()}},{key:"block_ui",value:function(){return this.form.block({message:null,overlayCSS:{background:"#fff",opacity:.6}})}},{key:"unblock_ui",value:function(){return this.form.unblock()}}])}(),a(document.body).trigger("sv_wc_payment_form_handler_v5_13_0_loaded")})}).call(this); +function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(t)}function t(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){for(var a=0;a0&&e.trigger("change"),r.val()&&r.val().length>0&&r.trigger("change"),t.val()&&t.val().length>0&&t.trigger("change"),a(".js-sv-wc-payment-gateway-credit-card-form-input").on("change paste keyup",function(){return n.do_inline_credit_card_validation()})}},{key:"do_inline_credit_card_validation",value:function(){var t,r,n,i;return t=a(".js-sv-wc-payment-gateway-credit-card-form-account-number"),i=a(".js-sv-wc-payment-gateway-credit-card-form-expiry"),n=a(".js-sv-wc-payment-gateway-credit-card-form-csc"),r=a.payment.cardType(t.val()),e.call(this.enabled_card_types,r)<0?t.addClass("invalid-card-type"):t.removeClass("invalid-card-type"),a.payment.validateCardExpiry(i.payment("cardExpiryVal"))?i.addClass("identified"):i.removeClass("identified"),a.payment.validateCardCVC(n.val())?n.addClass("identified"):n.removeClass("identified")}},{key:"validate_card_data",value:function(){var e,t,r,n;return r=[],null!=(t=this.payment_fields.find(".js-sv-wc-payment-gateway-credit-card-form-csc").val())&&(t?(/\D/.test(t)&&r.push(this.params.cvv_digits_invalid),(t.length<3||t.length>4)&&r.push(this.params.cvv_length_invalid)):this.csc_required&&(this.saved_payment_method_selected&&!this.csc_required_for_tokens||r.push(this.params.cvv_missing))),this.saved_payment_method_selected||(e=this.payment_fields.find(".js-sv-wc-payment-gateway-credit-card-form-account-number").val(),n=a.payment.cardExpiryVal(this.payment_fields.find(".js-sv-wc-payment-gateway-credit-card-form-expiry").val()),(e=e.replace(/-|\s/g,""))?((e.length<12||e.length>19)&&r.push(this.params.card_number_length_invalid),/\D/.test(e)&&r.push(this.params.card_number_digits_invalid),a.payment.validateCardNumber(e)||r.push(this.params.card_number_invalid)):r.push(this.params.card_number_missing),a.payment.validateCardExpiry(n)||r.push(this.params.card_exp_date_invalid)),r.length>0?(this.render_errors(r),!1):(this.payment_fields.find(".js-sv-wc-payment-gateway-credit-card-form-account-number").val(e),!0)}},{key:"validate_account_data",value:function(){var e,t,a;return!!this.saved_payment_method_selected||(t=[],a=this.payment_fields.find(".js-sv-wc-payment-gateway-echeck-form-routing-number").val(),e=this.payment_fields.find(".js-sv-wc-payment-gateway-echeck-form-account-number").val(),a?(9!==a.length&&t.push(this.params.routing_number_length_invalid),/\D/.test(a)&&t.push(this.params.routing_number_digits_invalid)):t.push(this.params.routing_number_missing),e?((e.length<3||e.length>17)&&t.push(this.params.account_number_length_invalid),/\D/.test(e)&&t.push(this.params.account_number_invalid)):t.push(this.params.account_number_missing),t.length>0?(this.render_errors(t),!1):(this.payment_fields.find(".js-sv-wc-payment-gateway-echeck-form-account-number").val(e),!0))}},{key:"render_errors",value:function(e){return a(".woocommerce-error, .woocommerce-message").remove(),this.form.prepend('
    • '+e.join("
    • ")+"
    "),this.form.removeClass("processing").unblock(),this.form.find(".input-text, select").blur(),a("html, body").animate({scrollTop:this.form.offset().top-100},1e3)}},{key:"handle_saved_payment_methods",value:function(){var e,t,r,n;if(n=this.id_dasherized,this.csc_required,r=this.csc_required_for_tokens,t=a("div.js-wc-".concat(n,"-new-payment-method-form")),e=t.find(".js-sv-wc-payment-gateway-credit-card-form-csc").closest(".form-row"),a("input.js-wc-".concat(this.id_dasherized,"-payment-token")).on("change",function(){if(a("input.js-wc-".concat(n,"-payment-token:checked")).val()){if(t.slideUp(200),r)return e.removeClass("form-row-last").addClass("form-row-first"),t.after(e)}else if(t.slideDown(200),r)return e.removeClass("form-row-first").addClass("form-row-last"),t.find(".js-sv-wc-payment-gateway-credit-card-form-expiry").closest(".form-row").after(e)}).change(),a("input#createaccount").on("change",function(){var e;return e=a("input.js-wc-".concat(n,"-tokenize-payment-method")).closest("p.form-row"),a(this).is(":checked")?(e.slideDown(),e.next().show()):(e.hide(),e.next().hide())}),!a("input#createaccount").is(":checked"))return a("input#createaccount").change()}},{key:"handle_sample_check_hint",value:function(){var e;return(e=this.payment_fields.find(".js-sv-wc-payment-gateway-echeck-form-sample-check")).is(":visible")?e.slideUp():e.slideDown()}},{key:"block_ui",value:function(){return this.form.block({message:null,overlayCSS:{background:"#fff",opacity:.6}})}},{key:"unblock_ui",value:function(){return this.form.unblock()}}])}(),a(document.body).trigger("sv_wc_payment_form_handler_v5_13_1_loaded")})}).call(this); },{}]},{},["7JA8"], null) -//# sourceMappingURL=../frontend/sv-wc-payment-gateway-payment-form.js.map \ No newline at end of file +//# sourceMappingURL=../frontend/sv-wc-payment-gateway-payment-form.js.map diff --git a/woocommerce/payment-gateway/assets/dist/frontend/sv-wc-payment-gateway-payment-form.js.map b/woocommerce/payment-gateway/assets/dist/frontend/sv-wc-payment-gateway-payment-form.js.map index 7206dd600..aa4a96b11 100644 --- a/woocommerce/payment-gateway/assets/dist/frontend/sv-wc-payment-gateway-payment-form.js.map +++ b/woocommerce/payment-gateway/assets/dist/frontend/sv-wc-payment-gateway-payment-form.js.map @@ -1 +1 @@ -{"version":3,"sources":["frontend/sv-wc-payment-gateway-payment-form.coffee"],"names":["indexOf","jQuery","$","window","SV_WC_Payment_Form_Handler_v5_13_0","args","id","id_dasherized","plugin_id","type","csc_required","csc_required_for_tokens","enabled_card_types","length","form","handle_checkout_page","handle_pay_page","console","log","handle_add_payment_method_page","params","on","handle_sample_check_hint","document","trigger","instance","body","format_credit_card_inputs","set_payment_fields","handle_saved_payment_methods","validate_payment_data","submit","val","$required_fields","payment_fields","find","each","i","input","handler","valid","is","saved_payment_method_selected","validate_card_data","validate_account_data","triggerHandler","payment_form","passed_validation","$card_number","$csc","$expiry","payment","do_inline_credit_card_validation","$card_type","cardType","call","addClass","removeClass","validateCardExpiry","validateCardCVC","account_number","csc","errors","expiry","test","push","cvv_digits_invalid","cvv_length_invalid","cvv_missing","cardExpiryVal","replace","card_number_length_invalid","card_number_digits_invalid","validateCardNumber","card_number_invalid","card_number_missing","card_exp_date_invalid","render_errors","routing_number","routing_number_length_invalid","routing_number_digits_invalid","routing_number_missing","account_number_length_invalid","account_number_invalid","account_number_missing","remove","prepend","join","unblock","blur","animate","scrollTop","offset","top","$csc_field","$new_payment_method_selection","closest","tokenized_payment_method_selected","slideUp","after","slideDown","change","$parent_row","next","show","hide","$sample_check","block","message","overlayCSS","background","opacity"],"mappings":";AAAA,SAAA,EAAA,GAAA,OAAA,EAAA,mBAAA,QAAA,iBAAA,OAAA,SAAA,SAAA,GAAA,cAAA,GAAA,SAAA,GAAA,OAAA,GAAA,mBAAA,QAAA,EAAA,cAAA,QAAA,IAAA,OAAA,UAAA,gBAAA,IAAA,GAAA,SAAA,EAAA,EAAA,GAAA,KAAA,aAAA,GAAA,MAAA,IAAA,UAAA,qCAAA,SAAA,EAAA,EAAA,GAAA,IAAA,IAAA,EAAA,EAAA,EAAA,EAAA,OAAA,IAAA,CAAA,IAAA,EAAA,EAAA,GAAA,EAAA,WAAA,EAAA,aAAA,EAAA,EAAA,cAAA,EAAA,UAAA,IAAA,EAAA,UAAA,GAAA,OAAA,eAAA,EAAA,E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O,SAGHnG,EAAE,uBAAuBmB,GAAG,SAAU,WAChCiF,IAAAA,EAEApG,OADJoG,EAAcpG,EAAiBK,eAAAA,OAAAA,EAAjB,6BAA0DyF,QAAQ,cAC5E9F,EAAE,MAAMuC,GAAG,aACb6D,EAAYF,YACLE,EAAYC,OAAOC,SAE1BF,EAAYG,OACLH,EAAYC,OAAOE,WAGzBvG,EAAE,uBAAuBuC,GAAG,YACxBvC,OAAAA,EAAE,uBAAuBmG,WA9WtC,CAAA,IAAA,2BAqXE,MAAA,WACMK,IAAAA,EAEAA,OADJA,EAAgB,KAAKxE,eAAeC,KAAK,uDACvBM,GAAG,YACZiE,EAAcR,UAEdQ,EAAcN,cA3X3B,CAAA,IAAA,WAkYE,MAAA,WACS,OAAA,KAAKtF,KAAK6F,MAAM,CACrBC,QAAS,KACTC,WAAY,CACVC,WAAY,OACZC,QAAS,QAvYjB,CAAA,IAAA,aA+YE,MAAA,WACS,OAAA,KAAKjG,KAAK0E,cAhZrB,GAqZOtF,EAAEqB,SAASG,MAAMF,QAAQ,iDAGjC+B,KAAK","file":"sv-wc-payment-gateway-payment-form.js","sourceRoot":"../js","sourcesContent":["(function() {\n /*\n WooCommerce SkyVerge Payment Gateway Framework Payment Form CoffeeScript\n Version 4.3.0\n\n Copyright (c) 2014-2024, SkyVerge, Inc.\n Licensed under the GNU General Public License v3.0\n http://www.gnu.org/licenses/gpl-3.0.html\n */\n var indexOf = [].indexOf;\n\n jQuery(function($) {\n \"use strict\";\n window.SV_WC_Payment_Form_Handler_v5_13_0 = class SV_WC_Payment_Form_Handler_v5_13_0 {\n // Public: Instantiate Payment Form Handler\n\n // args - object with properties:\n // id - gateway ID\n // id_dasherized - gateway ID dasherized\n // plugin_id - plugin ID\n // type - gateway type, either `credit-card` or `echeck`\n // csc_required - true if the gateway requires the CSC field to be displayed\n\n // Returns SV_WC_Payment_Form_Handler_v5_13_0 instance\n constructor(args) {\n this.id = args.id;\n this.id_dasherized = args.id_dasherized;\n this.plugin_id = args.plugin_id;\n this.type = args.type;\n this.csc_required = args.csc_required;\n this.csc_required_for_tokens = args.csc_required_for_tokens;\n this.enabled_card_types = args.enabled_card_types;\n // which payment form?\n if ($('form.checkout').length) {\n this.form = $('form.checkout');\n this.handle_checkout_page();\n } else if ($('form#order_review').length) {\n this.form = $('form#order_review');\n this.handle_pay_page();\n } else if ($('form#add_payment_method').length) {\n this.form = $('form#add_payment_method');\n this.handle_add_payment_method_page();\n } else {\n console.log('No payment form found!');\n return;\n }\n // localized error messages\n this.params = window[\"sv_wc_payment_gateway_payment_form_params\"];\n if (this.type === 'echeck') {\n // handle sample check image hint\n this.form.on('click', '.js-sv-wc-payment-gateway-echeck-form-check-hint, .js-sv-wc-payment-gateway-echeck-form-sample-check', () => {\n return this.handle_sample_check_hint();\n });\n }\n $(document).trigger('sv_wc_payment_form_handler_init', {\n id: this.id,\n instance: this\n });\n }\n\n // Public: Handle required actions on the checkout page\n\n // Returns nothing.\n handle_checkout_page() {\n if (this.type === 'credit-card') {\n // format/validate credit card inputs using jQuery.payment\n $(document.body).on('updated_checkout', () => {\n return this.format_credit_card_inputs();\n });\n }\n // updated payment fields jQuery object on each checkout update (prevents stale data)\n $(document.body).on('updated_checkout', () => {\n return this.set_payment_fields();\n });\n // handle saved payment methods\n // note on the checkout page, this is bound to `updated_checkout` so it\n // fires even when other parts of the checkout are changed\n $(document.body).on('updated_checkout', () => {\n return this.handle_saved_payment_methods();\n });\n // validate payment data before order is submitted\n return this.form.on(`checkout_place_order_${this.id}`, () => {\n return this.validate_payment_data();\n });\n }\n\n // Public: Handle required actions on the Order > Pay page\n\n // Returns nothing.\n handle_pay_page() {\n this.set_payment_fields();\n // format/validate credit card inputs using jQuery.payment\n if (this.type === 'credit-card') {\n this.format_credit_card_inputs();\n }\n // handle saved payment methods\n this.handle_saved_payment_methods();\n // validate payment data before order is submitted\n return this.form.submit(() => {\n if ($('#order_review input[name=payment_method]:checked').val() === this.id) {\n // but only when one of our payment gateways is selected\n return this.validate_payment_data();\n }\n });\n }\n\n // Public: Handle required actions on the Add Payment Method page\n\n // Returns nothing.\n handle_add_payment_method_page() {\n this.set_payment_fields();\n // format/validate credit card inputs using jQuery.payment\n if (this.type === 'credit-card') {\n this.format_credit_card_inputs();\n }\n // validate payment data before order is submitted\n return this.form.submit(() => {\n if ($('#add_payment_method input[name=payment_method]:checked').val() === this.id) {\n // but only when one of our payment gateways is selected\n return this.validate_payment_data();\n }\n });\n }\n\n // Public: Set payment fields class variable, this is done\n // during the updated_checkout event as otherwise the reference to\n // the checkout fields becomes stale (somehow ¯\\_(ツ)_/¯)\n\n // This ensures payment fields are not marked as \"invalid\" before the customer has interacted with them.\n\n // Returns nothing.\n set_payment_fields() {\n var $required_fields;\n this.payment_fields = $(`.payment_method_${this.id}`);\n $required_fields = this.payment_fields.find('.validate-required .input-text');\n return $required_fields.each((i, input) => {\n // if any of the required fields have a value, bail this loop and proceed with WooCommerce validation\n if ($(input).val()) {\n return false;\n }\n // otherwise remove all validation result classes from the inputs, since the form is freshly loaded\n return $(input).trigger('input');\n });\n }\n\n // Public: Validate Payment data when order is placed\n\n // Returns boolean, true if payment data is valid, false otherwise\n validate_payment_data() {\n var handler, valid;\n if (this.form.is('.processing')) {\n // bail when already processing\n return false;\n }\n this.saved_payment_method_selected = this.payment_fields.find('.js-sv-wc-payment-gateway-payment-token:checked').val();\n // perform internal validations (all fields present & valid, etc)\n valid = this.type === 'credit-card' ? this.validate_card_data() : this.validate_account_data();\n // let gateways perform their own validation prior to form submission\n handler = $(document.body).triggerHandler('sv_wc_payment_form_valid_payment_data', {\n payment_form: this,\n passed_validation: valid\n }) !== false;\n return valid && handler;\n }\n\n // Public: format card data using jQuery.Payment\n\n // Returns nothing.\n format_credit_card_inputs() {\n var $card_number, $csc, $expiry;\n $card_number = $('.js-sv-wc-payment-gateway-credit-card-form-account-number').payment('formatCardNumber');\n $expiry = $('.js-sv-wc-payment-gateway-credit-card-form-expiry').payment('formatCardExpiry');\n $csc = $('.js-sv-wc-payment-gateway-credit-card-form-csc').payment('formatCardCVC');\n if ($card_number.val() && $card_number.val().length > 0) {\n $card_number.trigger('change');\n }\n if ($expiry.val() && $expiry.val().length > 0) {\n $expiry.trigger('change');\n }\n if ($csc.val() && $csc.val().length > 0) {\n $csc.trigger('change');\n }\n // perform inline validation on credit card inputs\n return $('.js-sv-wc-payment-gateway-credit-card-form-input').on('change paste keyup', () => {\n return this.do_inline_credit_card_validation();\n });\n }\n\n // Public: perform inline validation on credit card fields\n\n // Returns nothing.\n do_inline_credit_card_validation() {\n var $card_number, $card_type, $csc, $expiry;\n $card_number = $('.js-sv-wc-payment-gateway-credit-card-form-account-number');\n $expiry = $('.js-sv-wc-payment-gateway-credit-card-form-expiry');\n $csc = $('.js-sv-wc-payment-gateway-credit-card-form-csc');\n $card_type = $.payment.cardType($card_number.val());\n if (indexOf.call(this.enabled_card_types, $card_type) < 0) {\n $card_number.addClass('invalid-card-type');\n } else {\n $card_number.removeClass('invalid-card-type');\n }\n if ($.payment.validateCardExpiry($expiry.payment('cardExpiryVal'))) {\n $expiry.addClass('identified');\n } else {\n $expiry.removeClass('identified');\n }\n if ($.payment.validateCardCVC($csc.val())) {\n return $csc.addClass('identified');\n } else {\n return $csc.removeClass('identified');\n }\n }\n\n // Public: Perform validation on the credit card info entered\n\n // Return boolean, true if credit card info is valid, false otherwise\n validate_card_data() {\n var account_number, csc, errors, expiry;\n errors = [];\n csc = this.payment_fields.find('.js-sv-wc-payment-gateway-credit-card-form-csc').val();\n // always validate the CSC if present\n if (csc != null) {\n if (csc) {\n if (/\\D/.test(csc)) {\n errors.push(this.params.cvv_digits_invalid);\n }\n if (csc.length < 3 || csc.length > 4) {\n errors.push(this.params.cvv_length_invalid);\n }\n } else if (this.csc_required) {\n if (!this.saved_payment_method_selected || this.csc_required_for_tokens) {\n errors.push(this.params.cvv_missing);\n }\n }\n }\n // Only validate the other CC fields if necessary\n if (!this.saved_payment_method_selected) {\n account_number = this.payment_fields.find('.js-sv-wc-payment-gateway-credit-card-form-account-number').val();\n expiry = $.payment.cardExpiryVal(this.payment_fields.find('.js-sv-wc-payment-gateway-credit-card-form-expiry').val());\n // replace any dashes or spaces in the card number\n account_number = account_number.replace(/-|\\s/g, '');\n // validate card number\n if (!account_number) {\n errors.push(this.params.card_number_missing);\n } else {\n if (account_number.length < 12 || account_number.length > 19) {\n errors.push(this.params.card_number_length_invalid);\n }\n if (/\\D/.test(account_number)) {\n errors.push(this.params.card_number_digits_invalid);\n }\n if (!$.payment.validateCardNumber(account_number)) { // performs luhn check\n errors.push(this.params.card_number_invalid);\n }\n }\n if (!$.payment.validateCardExpiry(expiry)) { // validates future date\n \n // validate expiration date\n errors.push(this.params.card_exp_date_invalid);\n }\n }\n if (errors.length > 0) {\n this.render_errors(errors);\n return false;\n } else {\n // get rid of any space/dash characters\n this.payment_fields.find('.js-sv-wc-payment-gateway-credit-card-form-account-number').val(account_number);\n return true;\n }\n }\n\n // Public: Perform validation on the eCheck info entered\n\n // Return boolean, true if eCheck info is valid, false otherwise\n validate_account_data() {\n var account_number, errors, routing_number;\n if (this.saved_payment_method_selected) {\n return true;\n }\n errors = [];\n routing_number = this.payment_fields.find('.js-sv-wc-payment-gateway-echeck-form-routing-number').val();\n account_number = this.payment_fields.find('.js-sv-wc-payment-gateway-echeck-form-account-number').val();\n // validate routing number\n if (!routing_number) {\n errors.push(this.params.routing_number_missing);\n } else {\n if (9 !== routing_number.length) {\n errors.push(this.params.routing_number_length_invalid);\n }\n if (/\\D/.test(routing_number)) {\n errors.push(this.params.routing_number_digits_invalid);\n }\n }\n // validate account number\n if (!account_number) {\n errors.push(this.params.account_number_missing);\n } else {\n if (account_number.length < 3 || account_number.length > 17) {\n errors.push(this.params.account_number_length_invalid);\n }\n if (/\\D/.test(account_number)) {\n errors.push(this.params.account_number_invalid);\n }\n }\n if (errors.length > 0) {\n this.render_errors(errors);\n return false;\n } else {\n // get rid of any space/dash characters\n this.payment_fields.find('.js-sv-wc-payment-gateway-echeck-form-account-number').val(account_number);\n return true;\n }\n }\n\n // Public: Render any new errors and bring them into the viewport\n\n // Returns nothing.\n render_errors(errors) {\n // hide and remove any previous errors\n $('.woocommerce-error, .woocommerce-message').remove();\n // add errors\n this.form.prepend('
    • ' + errors.join('
    • ') + '
    ');\n // unblock UI\n this.form.removeClass('processing').unblock();\n this.form.find('.input-text, select').blur();\n // scroll to top\n return $('html, body').animate({\n scrollTop: this.form.offset().top - 100\n }, 1000);\n }\n\n // Public: Handle associated actions for saved payment methods\n\n // Returns nothing.\n handle_saved_payment_methods() {\n var $csc_field, $new_payment_method_selection, csc_required, csc_required_for_tokens, id_dasherized;\n // make available inside change events\n id_dasherized = this.id_dasherized;\n csc_required = this.csc_required;\n csc_required_for_tokens = this.csc_required_for_tokens;\n $new_payment_method_selection = $(`div.js-wc-${id_dasherized}-new-payment-method-form`);\n $csc_field = $new_payment_method_selection.find('.js-sv-wc-payment-gateway-credit-card-form-csc').closest('.form-row');\n // show/hide the saved payment methods when a saved payment method is de-selected/selected\n $(`input.js-wc-${this.id_dasherized}-payment-token`).on('change', function() {\n var tokenized_payment_method_selected;\n tokenized_payment_method_selected = $(`input.js-wc-${id_dasherized}-payment-token:checked`).val();\n if (tokenized_payment_method_selected) {\n // using an existing tokenized payment method, hide the 'new method' fields\n $new_payment_method_selection.slideUp(200);\n // move the CSC field out of the 'new method' fields so it can be used with the tokenized transaction\n if (csc_required_for_tokens) {\n $csc_field.removeClass('form-row-last').addClass('form-row-first');\n return $new_payment_method_selection.after($csc_field);\n }\n } else {\n // use new payment method, display the 'new method' fields\n $new_payment_method_selection.slideDown(200);\n // move the CSC field back into its regular spot\n if (csc_required_for_tokens) {\n $csc_field.removeClass('form-row-first').addClass('form-row-last');\n return $new_payment_method_selection.find('.js-sv-wc-payment-gateway-credit-card-form-expiry').closest('.form-row').after($csc_field);\n }\n }\n }).change();\n // display the 'save payment method' option for guest checkouts if the 'create account' option is checked\n // but only hide the input if there is a 'create account' checkbox (some themes just display the password)\n $('input#createaccount').on('change', function() {\n var $parent_row;\n $parent_row = $(`input.js-wc-${id_dasherized}-tokenize-payment-method`).closest('p.form-row');\n if ($(this).is(':checked')) {\n $parent_row.slideDown();\n return $parent_row.next().show();\n } else {\n $parent_row.hide();\n return $parent_row.next().hide();\n }\n });\n if (!$('input#createaccount').is(':checked')) {\n return $('input#createaccount').change();\n }\n }\n\n // Public: Handle showing/hiding the sample check image\n\n // Returns nothing.\n handle_sample_check_hint() {\n var $sample_check;\n $sample_check = this.payment_fields.find('.js-sv-wc-payment-gateway-echeck-form-sample-check');\n if ($sample_check.is(\":visible\")) {\n return $sample_check.slideUp();\n } else {\n return $sample_check.slideDown();\n }\n }\n\n // Blocks the payment form UI\n\n // @since 3.0.0\n block_ui() {\n return this.form.block({\n message: null,\n overlayCSS: {\n background: '#fff',\n opacity: 0.6\n }\n });\n }\n\n // Unblocks the payment form UI\n\n // @since 3.0.0\n unblock_ui() {\n return this.form.unblock();\n }\n\n };\n // dispatch loaded event\n return $(document.body).trigger(\"sv_wc_payment_form_handler_v5_13_0_loaded\");\n });\n\n}).call(this);\n"]} \ No newline at end of file +{"version":3,"sources":["frontend/sv-wc-payment-gateway-payment-form.coffee"],"names":["indexOf","jQuery","$","window","SV_WC_Payment_Form_Handler_v5_13_1","args","id","id_dasherized","plugin_id","type","csc_required","csc_required_for_tokens","enabled_card_types","length","form","handle_checkout_page","handle_pay_page","console","log","handle_add_payment_method_page","params","on","handle_sample_check_hint","document","trigger","instance","body","format_credit_card_inputs","set_payment_fields","handle_saved_payment_methods","validate_payment_data","submit","val","$required_fields","payment_fields","find","each","i","input","handler","valid","is","saved_payment_method_selected","validate_card_data","validate_account_data","triggerHandler","payment_form","passed_validation","$card_number","$csc","$expiry","payment","do_inline_credit_card_validation","$card_type","cardType","call","addClass","removeClass","validateCardExpiry","validateCardCVC","account_number","csc","errors","expiry","test","push","cvv_digits_invalid","cvv_length_invalid","cvv_missing","cardExpiryVal","replace","card_number_length_invalid","card_number_digits_invalid","validateCardNumber","card_number_invalid","card_number_missing","card_exp_date_invalid","render_errors","routing_number","routing_number_length_invalid","routing_number_digits_invalid","routing_number_missing","account_number_length_invalid","account_number_invalid","account_number_missing","remove","prepend","join","unblock","blur","animate","scrollTop","offset","top","$csc_field","$new_payment_method_selection","closest","tokenized_payment_method_selected","slideUp","after","slideDown","change","$parent_row","next","show","hide","$sample_check","block","message","overlayCSS","background","opacity"],"mappings":";AAAA,SAAA,EAAA,GAAA,OAAA,EAAA,mBAAA,QAAA,iBAAA,OAAA,SAAA,SAAA,GAAA,cAAA,GAAA,SAAA,GAAA,OAAA,GAAA,mBAAA,QAAA,EAAA,cAAA,QAAA,IAAA,OAAA,UAAA,gBAAA,IAAA,GAAA,SAAA,EAAA,EAAA,GAAA,KAAA,aAAA,GAAA,MAAA,IAAA,UAAA,qCAAA,SAAA,EAAA,EAAA,GAAA,IAAA,IAAA,EAAA,EAAA,EAAA,EAAA,OAAA,IAAA,CAAA,IAAA,EAAA,EAAA,GAAA,EAAA,WAAA,EAAA,aAAA,EAAA,EAAA,cAAA,EAAA,UAAA,IAAA,EAAA,UAAA,GAAA,OAAA,eAAA,EAAA,EAAA,EAAA,KAAA,IAAA,SAAA,EAAA,EAAA,EAAA,GAAA,OAAA,GAAA,EAAA,EAAA,UAAA,GAAA,GAAA,EAAA,EAAA,GAAA,OAAA,eAAA,EAAA,YAAA,CAAA,UAAA,IAAA,EAAA,SAAA,EAAA,GAAA,IAAA,EAAA,EAAA,EAAA,UAAA,MAAA,UAAA,EAAA,GAAA,EAAA,EAAA,GAAA,SAAA,EAAA,EAAA,GAAA,GAAA,UAAA,EAAA,KAAA,EAAA,OAAA,EAAA,IAAA,EAAA,EAAA,OAAA,aAAA,QAAA,IAAA,EAAA,CAAA,IAAA,EAAA,EAAA,KAAA,EAAA,GAAA,WAAA,GAAA,UAAA,EAAA,GAAA,OAAA,EAAA,MAAA,IAAA,UAAA,gDAAA,OAAA,WAAA,EAAA,OAAA,QAAA,IAAA,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C,WAAY,CACVC,WAAY,OACZC,QAAS,QAvYjB,CAAA,IAAA,aA+YE,MAAA,WACS,OAAA,KAAKjG,KAAK0E,cAhZrB,GAqZOtF,EAAEqB,SAASG,MAAMF,QAAQ,iDAGjC+B,KAAK","file":"sv-wc-payment-gateway-payment-form.js","sourceRoot":"../js","sourcesContent":["(function() {\n /*\n WooCommerce SkyVerge Payment Gateway Framework Payment Form CoffeeScript\n Version 4.3.0\n\n Copyright (c) 2014-2024, SkyVerge, Inc.\n Licensed under the GNU General Public License v3.0\n http://www.gnu.org/licenses/gpl-3.0.html\n */\n var indexOf = [].indexOf;\n\n jQuery(function($) {\n \"use strict\";\n window.SV_WC_Payment_Form_Handler_v5_13_1 = class SV_WC_Payment_Form_Handler_v5_13_1 {\n // Public: Instantiate Payment Form Handler\n\n // args - object with properties:\n // id - gateway ID\n // id_dasherized - gateway ID dasherized\n // plugin_id - plugin ID\n // type - gateway type, either `credit-card` or `echeck`\n // csc_required - true if the gateway requires the CSC field to be displayed\n\n // Returns SV_WC_Payment_Form_Handler_v5_13_1 instance\n constructor(args) {\n this.id = args.id;\n this.id_dasherized = args.id_dasherized;\n this.plugin_id = args.plugin_id;\n this.type = args.type;\n this.csc_required = args.csc_required;\n this.csc_required_for_tokens = args.csc_required_for_tokens;\n this.enabled_card_types = args.enabled_card_types;\n // which payment form?\n if ($('form.checkout').length) {\n this.form = $('form.checkout');\n this.handle_checkout_page();\n } else if ($('form#order_review').length) {\n this.form = $('form#order_review');\n this.handle_pay_page();\n } else if ($('form#add_payment_method').length) {\n this.form = $('form#add_payment_method');\n this.handle_add_payment_method_page();\n } else {\n console.log('No payment form found!');\n return;\n }\n // localized error messages\n this.params = window[\"sv_wc_payment_gateway_payment_form_params\"];\n if (this.type === 'echeck') {\n // handle sample check image hint\n this.form.on('click', '.js-sv-wc-payment-gateway-echeck-form-check-hint, .js-sv-wc-payment-gateway-echeck-form-sample-check', () => {\n return this.handle_sample_check_hint();\n });\n }\n $(document).trigger('sv_wc_payment_form_handler_init', {\n id: this.id,\n instance: this\n });\n }\n\n // Public: Handle required actions on the checkout page\n\n // Returns nothing.\n handle_checkout_page() {\n if (this.type === 'credit-card') {\n // format/validate credit card inputs using jQuery.payment\n $(document.body).on('updated_checkout', () => {\n return this.format_credit_card_inputs();\n });\n }\n // updated payment fields jQuery object on each checkout update (prevents stale data)\n $(document.body).on('updated_checkout', () => {\n return this.set_payment_fields();\n });\n // handle saved payment methods\n // note on the checkout page, this is bound to `updated_checkout` so it\n // fires even when other parts of the checkout are changed\n $(document.body).on('updated_checkout', () => {\n return this.handle_saved_payment_methods();\n });\n // validate payment data before order is submitted\n return this.form.on(`checkout_place_order_${this.id}`, () => {\n return this.validate_payment_data();\n });\n }\n\n // Public: Handle required actions on the Order > Pay page\n\n // Returns nothing.\n handle_pay_page() {\n this.set_payment_fields();\n // format/validate credit card inputs using jQuery.payment\n if (this.type === 'credit-card') {\n this.format_credit_card_inputs();\n }\n // handle saved payment methods\n this.handle_saved_payment_methods();\n // validate payment data before order is submitted\n return this.form.submit(() => {\n if ($('#order_review input[name=payment_method]:checked').val() === this.id) {\n // but only when one of our payment gateways is selected\n return this.validate_payment_data();\n }\n });\n }\n\n // Public: Handle required actions on the Add Payment Method page\n\n // Returns nothing.\n handle_add_payment_method_page() {\n this.set_payment_fields();\n // format/validate credit card inputs using jQuery.payment\n if (this.type === 'credit-card') {\n this.format_credit_card_inputs();\n }\n // validate payment data before order is submitted\n return this.form.submit(() => {\n if ($('#add_payment_method input[name=payment_method]:checked').val() === this.id) {\n // but only when one of our payment gateways is selected\n return this.validate_payment_data();\n }\n });\n }\n\n // Public: Set payment fields class variable, this is done\n // during the updated_checkout event as otherwise the reference to\n // the checkout fields becomes stale (somehow ¯\\_(ツ)_/¯)\n\n // This ensures payment fields are not marked as \"invalid\" before the customer has interacted with them.\n\n // Returns nothing.\n set_payment_fields() {\n var $required_fields;\n this.payment_fields = $(`.payment_method_${this.id}`);\n $required_fields = this.payment_fields.find('.validate-required .input-text');\n return $required_fields.each((i, input) => {\n // if any of the required fields have a value, bail this loop and proceed with WooCommerce validation\n if ($(input).val()) {\n return false;\n }\n // otherwise remove all validation result classes from the inputs, since the form is freshly loaded\n return $(input).trigger('input');\n });\n }\n\n // Public: Validate Payment data when order is placed\n\n // Returns boolean, true if payment data is valid, false otherwise\n validate_payment_data() {\n var handler, valid;\n if (this.form.is('.processing')) {\n // bail when already processing\n return false;\n }\n this.saved_payment_method_selected = this.payment_fields.find('.js-sv-wc-payment-gateway-payment-token:checked').val();\n // perform internal validations (all fields present & valid, etc)\n valid = this.type === 'credit-card' ? this.validate_card_data() : this.validate_account_data();\n // let gateways perform their own validation prior to form submission\n handler = $(document.body).triggerHandler('sv_wc_payment_form_valid_payment_data', {\n payment_form: this,\n passed_validation: valid\n }) !== false;\n return valid && handler;\n }\n\n // Public: format card data using jQuery.Payment\n\n // Returns nothing.\n format_credit_card_inputs() {\n var $card_number, $csc, $expiry;\n $card_number = $('.js-sv-wc-payment-gateway-credit-card-form-account-number').payment('formatCardNumber');\n $expiry = $('.js-sv-wc-payment-gateway-credit-card-form-expiry').payment('formatCardExpiry');\n $csc = $('.js-sv-wc-payment-gateway-credit-card-form-csc').payment('formatCardCVC');\n if ($card_number.val() && $card_number.val().length > 0) {\n $card_number.trigger('change');\n }\n if ($expiry.val() && $expiry.val().length > 0) {\n $expiry.trigger('change');\n }\n if ($csc.val() && $csc.val().length > 0) {\n $csc.trigger('change');\n }\n // perform inline validation on credit card inputs\n return $('.js-sv-wc-payment-gateway-credit-card-form-input').on('change paste keyup', () => {\n return this.do_inline_credit_card_validation();\n });\n }\n\n // Public: perform inline validation on credit card fields\n\n // Returns nothing.\n do_inline_credit_card_validation() {\n var $card_number, $card_type, $csc, $expiry;\n $card_number = $('.js-sv-wc-payment-gateway-credit-card-form-account-number');\n $expiry = $('.js-sv-wc-payment-gateway-credit-card-form-expiry');\n $csc = $('.js-sv-wc-payment-gateway-credit-card-form-csc');\n $card_type = $.payment.cardType($card_number.val());\n if (indexOf.call(this.enabled_card_types, $card_type) < 0) {\n $card_number.addClass('invalid-card-type');\n } else {\n $card_number.removeClass('invalid-card-type');\n }\n if ($.payment.validateCardExpiry($expiry.payment('cardExpiryVal'))) {\n $expiry.addClass('identified');\n } else {\n $expiry.removeClass('identified');\n }\n if ($.payment.validateCardCVC($csc.val())) {\n return $csc.addClass('identified');\n } else {\n return $csc.removeClass('identified');\n }\n }\n\n // Public: Perform validation on the credit card info entered\n\n // Return boolean, true if credit card info is valid, false otherwise\n validate_card_data() {\n var account_number, csc, errors, expiry;\n errors = [];\n csc = this.payment_fields.find('.js-sv-wc-payment-gateway-credit-card-form-csc').val();\n // always validate the CSC if present\n if (csc != null) {\n if (csc) {\n if (/\\D/.test(csc)) {\n errors.push(this.params.cvv_digits_invalid);\n }\n if (csc.length < 3 || csc.length > 4) {\n errors.push(this.params.cvv_length_invalid);\n }\n } else if (this.csc_required) {\n if (!this.saved_payment_method_selected || this.csc_required_for_tokens) {\n errors.push(this.params.cvv_missing);\n }\n }\n }\n // Only validate the other CC fields if necessary\n if (!this.saved_payment_method_selected) {\n account_number = this.payment_fields.find('.js-sv-wc-payment-gateway-credit-card-form-account-number').val();\n expiry = $.payment.cardExpiryVal(this.payment_fields.find('.js-sv-wc-payment-gateway-credit-card-form-expiry').val());\n // replace any dashes or spaces in the card number\n account_number = account_number.replace(/-|\\s/g, '');\n // validate card number\n if (!account_number) {\n errors.push(this.params.card_number_missing);\n } else {\n if (account_number.length < 12 || account_number.length > 19) {\n errors.push(this.params.card_number_length_invalid);\n }\n if (/\\D/.test(account_number)) {\n errors.push(this.params.card_number_digits_invalid);\n }\n if (!$.payment.validateCardNumber(account_number)) { // performs luhn check\n errors.push(this.params.card_number_invalid);\n }\n }\n if (!$.payment.validateCardExpiry(expiry)) { // validates future date\n \n // validate expiration date\n errors.push(this.params.card_exp_date_invalid);\n }\n }\n if (errors.length > 0) {\n this.render_errors(errors);\n return false;\n } else {\n // get rid of any space/dash characters\n this.payment_fields.find('.js-sv-wc-payment-gateway-credit-card-form-account-number').val(account_number);\n return true;\n }\n }\n\n // Public: Perform validation on the eCheck info entered\n\n // Return boolean, true if eCheck info is valid, false otherwise\n validate_account_data() {\n var account_number, errors, routing_number;\n if (this.saved_payment_method_selected) {\n return true;\n }\n errors = [];\n routing_number = this.payment_fields.find('.js-sv-wc-payment-gateway-echeck-form-routing-number').val();\n account_number = this.payment_fields.find('.js-sv-wc-payment-gateway-echeck-form-account-number').val();\n // validate routing number\n if (!routing_number) {\n errors.push(this.params.routing_number_missing);\n } else {\n if (9 !== routing_number.length) {\n errors.push(this.params.routing_number_length_invalid);\n }\n if (/\\D/.test(routing_number)) {\n errors.push(this.params.routing_number_digits_invalid);\n }\n }\n // validate account number\n if (!account_number) {\n errors.push(this.params.account_number_missing);\n } else {\n if (account_number.length < 3 || account_number.length > 17) {\n errors.push(this.params.account_number_length_invalid);\n }\n if (/\\D/.test(account_number)) {\n errors.push(this.params.account_number_invalid);\n }\n }\n if (errors.length > 0) {\n this.render_errors(errors);\n return false;\n } else {\n // get rid of any space/dash characters\n this.payment_fields.find('.js-sv-wc-payment-gateway-echeck-form-account-number').val(account_number);\n return true;\n }\n }\n\n // Public: Render any new errors and bring them into the viewport\n\n // Returns nothing.\n render_errors(errors) {\n // hide and remove any previous errors\n $('.woocommerce-error, .woocommerce-message').remove();\n // add errors\n this.form.prepend('
    • ' + errors.join('
    • ') + '
    ');\n // unblock UI\n this.form.removeClass('processing').unblock();\n this.form.find('.input-text, select').blur();\n // scroll to top\n return $('html, body').animate({\n scrollTop: this.form.offset().top - 100\n }, 1000);\n }\n\n // Public: Handle associated actions for saved payment methods\n\n // Returns nothing.\n handle_saved_payment_methods() {\n var $csc_field, $new_payment_method_selection, csc_required, csc_required_for_tokens, id_dasherized;\n // make available inside change events\n id_dasherized = this.id_dasherized;\n csc_required = this.csc_required;\n csc_required_for_tokens = this.csc_required_for_tokens;\n $new_payment_method_selection = $(`div.js-wc-${id_dasherized}-new-payment-method-form`);\n $csc_field = $new_payment_method_selection.find('.js-sv-wc-payment-gateway-credit-card-form-csc').closest('.form-row');\n // show/hide the saved payment methods when a saved payment method is de-selected/selected\n $(`input.js-wc-${this.id_dasherized}-payment-token`).on('change', function() {\n var tokenized_payment_method_selected;\n tokenized_payment_method_selected = $(`input.js-wc-${id_dasherized}-payment-token:checked`).val();\n if (tokenized_payment_method_selected) {\n // using an existing tokenized payment method, hide the 'new method' fields\n $new_payment_method_selection.slideUp(200);\n // move the CSC field out of the 'new method' fields so it can be used with the tokenized transaction\n if (csc_required_for_tokens) {\n $csc_field.removeClass('form-row-last').addClass('form-row-first');\n return $new_payment_method_selection.after($csc_field);\n }\n } else {\n // use new payment method, display the 'new method' fields\n $new_payment_method_selection.slideDown(200);\n // move the CSC field back into its regular spot\n if (csc_required_for_tokens) {\n $csc_field.removeClass('form-row-first').addClass('form-row-last');\n return $new_payment_method_selection.find('.js-sv-wc-payment-gateway-credit-card-form-expiry').closest('.form-row').after($csc_field);\n }\n }\n }).change();\n // display the 'save payment method' option for guest checkouts if the 'create account' option is checked\n // but only hide the input if there is a 'create account' checkbox (some themes just display the password)\n $('input#createaccount').on('change', function() {\n var $parent_row;\n $parent_row = $(`input.js-wc-${id_dasherized}-tokenize-payment-method`).closest('p.form-row');\n if ($(this).is(':checked')) {\n $parent_row.slideDown();\n return $parent_row.next().show();\n } else {\n $parent_row.hide();\n return $parent_row.next().hide();\n }\n });\n if (!$('input#createaccount').is(':checked')) {\n return $('input#createaccount').change();\n }\n }\n\n // Public: Handle showing/hiding the sample check image\n\n // Returns nothing.\n handle_sample_check_hint() {\n var $sample_check;\n $sample_check = this.payment_fields.find('.js-sv-wc-payment-gateway-echeck-form-sample-check');\n if ($sample_check.is(\":visible\")) {\n return $sample_check.slideUp();\n } else {\n return $sample_check.slideDown();\n }\n }\n\n // Blocks the payment form UI\n\n // @since 3.0.0\n block_ui() {\n return this.form.block({\n message: null,\n overlayCSS: {\n background: '#fff',\n opacity: 0.6\n }\n });\n }\n\n // Unblocks the payment form UI\n\n // @since 3.0.0\n unblock_ui() {\n return this.form.unblock();\n }\n\n };\n // dispatch loaded event\n return $(document.body).trigger(\"sv_wc_payment_form_handler_v5_13_1_loaded\");\n });\n\n}).call(this);\n"]} diff --git a/woocommerce/payment-gateway/assets/js/frontend/sv-wc-payment-gateway-apple-pay.coffee b/woocommerce/payment-gateway/assets/js/frontend/sv-wc-payment-gateway-apple-pay.coffee index 5b5d94f5c..6866e594b 100644 --- a/woocommerce/payment-gateway/assets/js/frontend/sv-wc-payment-gateway-apple-pay.coffee +++ b/woocommerce/payment-gateway/assets/js/frontend/sv-wc-payment-gateway-apple-pay.coffee @@ -14,7 +14,7 @@ jQuery ( $ ) -> # The WooCommerce Apple Pay handler base class. # # @since 4.7.0 - class window.SV_WC_Apple_Pay_Handler_v5_13_0 + class window.SV_WC_Apple_Pay_Handler_v5_13_1 # Constructs the handler. @@ -440,4 +440,4 @@ jQuery ( $ ) -> # dispatch loaded event - $( document.body ).trigger( 'sv_wc_apple_pay_handler_v5_13_0_loaded' ) + $( document.body ).trigger( 'sv_wc_apple_pay_handler_v5_13_1_loaded' ) diff --git a/woocommerce/payment-gateway/assets/js/frontend/sv-wc-payment-gateway-google-pay.js b/woocommerce/payment-gateway/assets/js/frontend/sv-wc-payment-gateway-google-pay.js index 61df2b4fc..da6159aec 100644 --- a/woocommerce/payment-gateway/assets/js/frontend/sv-wc-payment-gateway-google-pay.js +++ b/woocommerce/payment-gateway/assets/js/frontend/sv-wc-payment-gateway-google-pay.js @@ -7,9 +7,9 @@ jQuery( function( $ ) { * * @since 5.10.0 * - * @type {SV_WC_Google_Pay_Handler_v5_13_0} object + * @type {SV_WC_Google_Pay_Handler_v5_13_1} object */ - window.SV_WC_Google_Pay_Handler_v5_13_0 = class SV_WC_Google_Pay_Handler_v5_13_0 { + window.SV_WC_Google_Pay_Handler_v5_13_1 = class SV_WC_Google_Pay_Handler_v5_13_1 { /** * Handler constructor. @@ -609,6 +609,6 @@ jQuery( function( $ ) { } } - $( document.body ).trigger( 'sv_wc_google_pay_handler_v5_13_0_loaded' ); + $( document.body ).trigger( 'sv_wc_google_pay_handler_v5_13_1_loaded' ); } ); diff --git a/woocommerce/payment-gateway/assets/js/frontend/sv-wc-payment-gateway-my-payment-methods.coffee b/woocommerce/payment-gateway/assets/js/frontend/sv-wc-payment-gateway-my-payment-methods.coffee index c30f1fad3..447662f81 100644 --- a/woocommerce/payment-gateway/assets/js/frontend/sv-wc-payment-gateway-my-payment-methods.coffee +++ b/woocommerce/payment-gateway/assets/js/frontend/sv-wc-payment-gateway-my-payment-methods.coffee @@ -12,7 +12,7 @@ jQuery ( $ ) -> # The My Payment Methods handler. # # @since 5.1.0 - class window.SV_WC_Payment_Methods_Handler_v5_13_0 + class window.SV_WC_Payment_Methods_Handler_v5_13_1 # Constructs the class. @@ -270,4 +270,4 @@ jQuery ( $ ) -> # dispatch loaded event - $( document.body ).trigger( 'sv_wc_payment_methods_handler_v5_13_0_loaded' ) + $( document.body ).trigger( 'sv_wc_payment_methods_handler_v5_13_1_loaded' ) diff --git a/woocommerce/payment-gateway/assets/js/frontend/sv-wc-payment-gateway-payment-form.coffee b/woocommerce/payment-gateway/assets/js/frontend/sv-wc-payment-gateway-payment-form.coffee index d0e552645..31920e3ac 100644 --- a/woocommerce/payment-gateway/assets/js/frontend/sv-wc-payment-gateway-payment-form.coffee +++ b/woocommerce/payment-gateway/assets/js/frontend/sv-wc-payment-gateway-payment-form.coffee @@ -10,7 +10,7 @@ jQuery ( $ ) -> "use strict" - class window.SV_WC_Payment_Form_Handler_v5_13_0 + class window.SV_WC_Payment_Form_Handler_v5_13_1 # Public: Instantiate Payment Form Handler @@ -22,7 +22,7 @@ jQuery ( $ ) -> # type - gateway type, either `credit-card` or `echeck` # csc_required - true if the gateway requires the CSC field to be displayed # - # Returns SV_WC_Payment_Form_Handler_v5_13_0 instance + # Returns SV_WC_Payment_Form_Handler_v5_13_1 instance constructor: (args) -> @id = args.id @@ -385,4 +385,4 @@ jQuery ( $ ) -> # dispatch loaded event - $( document.body ).trigger( "sv_wc_payment_form_handler_v5_13_0_loaded" ) + $( document.body ).trigger( "sv_wc_payment_form_handler_v5_13_1_loaded" ) diff --git a/woocommerce/payment-gateway/class-sv-wc-payment-gateway-direct.php b/woocommerce/payment-gateway/class-sv-wc-payment-gateway-direct.php index dcd696b69..ba380e79f 100644 --- a/woocommerce/payment-gateway/class-sv-wc-payment-gateway-direct.php +++ b/woocommerce/payment-gateway/class-sv-wc-payment-gateway-direct.php @@ -22,13 +22,13 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 */ -namespace SkyVerge\WooCommerce\PluginFramework\v5_13_0; +namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1; -use SkyVerge\WooCommerce\PluginFramework\v5_13_0\Blocks\Blocks_Handler; +use SkyVerge\WooCommerce\PluginFramework\v5_13_1\Blocks\Blocks_Handler; defined( 'ABSPATH' ) or exit; -if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_0\\SV_WC_Payment_Gateway_Direct' ) ) : +if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\SV_WC_Payment_Gateway_Direct' ) ) : /** diff --git a/woocommerce/payment-gateway/class-sv-wc-payment-gateway-helper.php b/woocommerce/payment-gateway/class-sv-wc-payment-gateway-helper.php index 15ba81687..f2c06ce8e 100755 --- a/woocommerce/payment-gateway/class-sv-wc-payment-gateway-helper.php +++ b/woocommerce/payment-gateway/class-sv-wc-payment-gateway-helper.php @@ -22,11 +22,11 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 */ -namespace SkyVerge\WooCommerce\PluginFramework\v5_13_0; +namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1; defined( 'ABSPATH' ) or exit; -if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_0\\SV_WC_Payment_Gateway_Helper' ) ) : +if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\SV_WC_Payment_Gateway_Helper' ) ) : /** diff --git a/woocommerce/payment-gateway/class-sv-wc-payment-gateway-hosted.php b/woocommerce/payment-gateway/class-sv-wc-payment-gateway-hosted.php index 468b3c99b..73656bb45 100644 --- a/woocommerce/payment-gateway/class-sv-wc-payment-gateway-hosted.php +++ b/woocommerce/payment-gateway/class-sv-wc-payment-gateway-hosted.php @@ -22,11 +22,11 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 */ -namespace SkyVerge\WooCommerce\PluginFramework\v5_13_0; +namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1; defined( 'ABSPATH' ) or exit; -if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_0\\SV_WC_Payment_Gateway_Hosted' ) ) : +if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\SV_WC_Payment_Gateway_Hosted' ) ) : /** diff --git a/woocommerce/payment-gateway/class-sv-wc-payment-gateway-my-payment-methods.php b/woocommerce/payment-gateway/class-sv-wc-payment-gateway-my-payment-methods.php index 22fd4ef1e..d43ce2996 100644 --- a/woocommerce/payment-gateway/class-sv-wc-payment-gateway-my-payment-methods.php +++ b/woocommerce/payment-gateway/class-sv-wc-payment-gateway-my-payment-methods.php @@ -22,11 +22,11 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 */ -namespace SkyVerge\WooCommerce\PluginFramework\v5_13_0; +namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1; defined( 'ABSPATH' ) or exit; -if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_0\\SV_WC_Payment_Gateway_My_Payment_Methods' ) ) : +if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\SV_WC_Payment_Gateway_My_Payment_Methods' ) ) : /** @@ -174,9 +174,9 @@ public function maybe_enqueue_styles_scripts() { wp_register_script( 'jquery-tiptip', WC()->plugin_url() . '/assets/js/jquery-tiptip/jquery.tipTip.min.js', [ 'jquery' ], $wc_version ); - wp_enqueue_style( "$handle-v5_13_0", $this->get_plugin()->get_payment_gateway_framework_assets_url() . '/css/frontend/' . $handle . '.min.css', [ 'dashicons' ], $fw_version ); + wp_enqueue_style( "$handle-v5_13_1", $this->get_plugin()->get_payment_gateway_framework_assets_url() . '/css/frontend/' . $handle . '.min.css', [ 'dashicons' ], $fw_version ); - wp_enqueue_script( "$handle-v5_13_0", $this->get_plugin()->get_payment_gateway_framework_assets_url() . '/dist/frontend/' . $handle . '.js', [ 'jquery-tiptip', 'jquery' ], $fw_version ); + wp_enqueue_script( "$handle-v5_13_1", $this->get_plugin()->get_payment_gateway_framework_assets_url() . '/dist/frontend/' . $handle . '.js', [ 'jquery-tiptip', 'jquery' ], $fw_version ); } diff --git a/woocommerce/payment-gateway/class-sv-wc-payment-gateway-payment-form.php b/woocommerce/payment-gateway/class-sv-wc-payment-gateway-payment-form.php index 4ef8b2a15..1d6be21d5 100644 --- a/woocommerce/payment-gateway/class-sv-wc-payment-gateway-payment-form.php +++ b/woocommerce/payment-gateway/class-sv-wc-payment-gateway-payment-form.php @@ -22,15 +22,15 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 */ -namespace SkyVerge\WooCommerce\PluginFramework\v5_13_0; +namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1; -use SkyVerge\WooCommerce\PluginFramework\v5_13_0\Blocks\Blocks_Handler; -use SkyVerge\WooCommerce\PluginFramework\v5_13_0\Enums\PaymentFormContext; -use SkyVerge\WooCommerce\PluginFramework\v5_13_0\Payment_Gateway\Blocks\Gateway_Checkout_Block_Integration; +use SkyVerge\WooCommerce\PluginFramework\v5_13_1\Blocks\Blocks_Handler; +use SkyVerge\WooCommerce\PluginFramework\v5_13_1\Enums\PaymentFormContext; +use SkyVerge\WooCommerce\PluginFramework\v5_13_1\Payment_Gateway\Blocks\Gateway_Checkout_Block_Integration; defined( 'ABSPATH' ) or exit; -if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_0\\SV_WC_Payment_Gateway_Payment_Form' ) ) : +if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\SV_WC_Payment_Gateway_Payment_Form' ) ) : /** @@ -1180,7 +1180,7 @@ protected function get_js_handler_args() { if ( is_array( $card_types ) && ! empty( $card_types ) ) { - $args['enabled_card_types'] = array_map( [ 'SkyVerge\WooCommerce\PluginFramework\v5_13_0\SV_WC_Payment_Gateway_Helper', 'normalize_card_type' ], $card_types ); + $args['enabled_card_types'] = array_map( [ 'SkyVerge\WooCommerce\PluginFramework\v5_13_1\SV_WC_Payment_Gateway_Helper', 'normalize_card_type' ], $card_types ); } } diff --git a/woocommerce/payment-gateway/class-sv-wc-payment-gateway-plugin.php b/woocommerce/payment-gateway/class-sv-wc-payment-gateway-plugin.php index c41ab4943..fea9a3003 100644 --- a/woocommerce/payment-gateway/class-sv-wc-payment-gateway-plugin.php +++ b/woocommerce/payment-gateway/class-sv-wc-payment-gateway-plugin.php @@ -22,16 +22,16 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 */ -namespace SkyVerge\WooCommerce\PluginFramework\v5_13_0; +namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1; use Automattic\WooCommerce\Admin\Notes\WC_Admin_Note; use Automattic\WooCommerce\Admin\Notes\WC_Admin_Notes; -use SkyVerge\WooCommerce\PluginFramework\v5_13_0\Payment_Gateway\Blocks\Gateway_Blocks_Handler; -use SkyVerge\WooCommerce\PluginFramework\v5_13_0\Payment_Gateway\External_Checkout\Google_Pay\Google_Pay; +use SkyVerge\WooCommerce\PluginFramework\v5_13_1\Payment_Gateway\Blocks\Gateway_Blocks_Handler; +use SkyVerge\WooCommerce\PluginFramework\v5_13_1\Payment_Gateway\External_Checkout\Google_Pay\Google_Pay; defined( 'ABSPATH' ) or exit; -if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_0\\SV_WC_Payment_Gateway_Plugin' ) ) : +if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\SV_WC_Payment_Gateway_Plugin' ) ) : /** diff --git a/woocommerce/payment-gateway/class-sv-wc-payment-gateway-privacy.php b/woocommerce/payment-gateway/class-sv-wc-payment-gateway-privacy.php index 698cb0f11..631e503d3 100644 --- a/woocommerce/payment-gateway/class-sv-wc-payment-gateway-privacy.php +++ b/woocommerce/payment-gateway/class-sv-wc-payment-gateway-privacy.php @@ -22,11 +22,11 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 */ -namespace SkyVerge\WooCommerce\PluginFramework\v5_13_0; +namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1; defined( 'ABSPATH' ) or exit; -if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_0\\SV_WC_Payment_Gateway_Privacy' ) ) : +if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\SV_WC_Payment_Gateway_Privacy' ) ) : /** diff --git a/woocommerce/payment-gateway/class-sv-wc-payment-gateway.php b/woocommerce/payment-gateway/class-sv-wc-payment-gateway.php index 4e760e4c2..157a6c63d 100755 --- a/woocommerce/payment-gateway/class-sv-wc-payment-gateway.php +++ b/woocommerce/payment-gateway/class-sv-wc-payment-gateway.php @@ -22,16 +22,16 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 */ -namespace SkyVerge\WooCommerce\PluginFramework\v5_13_0; +namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1; use Automattic\WooCommerce\Blocks\Integrations\IntegrationInterface; -use SkyVerge\WooCommerce\PluginFramework\v5_13_0\Blocks\Blocks_Handler; -use SkyVerge\WooCommerce\PluginFramework\v5_13_0\Payment_Gateway\Blocks\Gateway_Checkout_Block_Integration; +use SkyVerge\WooCommerce\PluginFramework\v5_13_1\Blocks\Blocks_Handler; +use SkyVerge\WooCommerce\PluginFramework\v5_13_1\Payment_Gateway\Blocks\Gateway_Checkout_Block_Integration; use stdClass; defined( 'ABSPATH' ) or exit; -if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_0\\SV_WC_Payment_Gateway' ) ) : +if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\SV_WC_Payment_Gateway' ) ) : /** @@ -473,7 +473,7 @@ protected function enqueue_payment_form_assets() { } $handle = 'sv-wc-payment-gateway-payment-form'; - $versioned_handle = $handle . '-v5_13_0'; + $versioned_handle = $handle . '-v5_13_1'; // Frontend JS wp_enqueue_script( $versioned_handle, $this->get_plugin()->get_payment_gateway_framework_assets_url() . '/dist/frontend/' . $handle . '.js', array( 'jquery-payment' ), SV_WC_Plugin::VERSION, true ); diff --git a/woocommerce/payment-gateway/exceptions/class-sv-wc-payment-gateway-exception.php b/woocommerce/payment-gateway/exceptions/class-sv-wc-payment-gateway-exception.php index 76c60d1ce..4ac23a1c4 100644 --- a/woocommerce/payment-gateway/exceptions/class-sv-wc-payment-gateway-exception.php +++ b/woocommerce/payment-gateway/exceptions/class-sv-wc-payment-gateway-exception.php @@ -22,11 +22,11 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 */ -namespace SkyVerge\WooCommerce\PluginFramework\v5_13_0; +namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1; defined( 'ABSPATH' ) or exit; -if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_0\\SV_WC_Payment_Gateway_Exception' ) ) : +if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\SV_WC_Payment_Gateway_Exception' ) ) : /** diff --git a/woocommerce/payment-gateway/integrations/abstract-sv-wc-payment-gateway-integration.php b/woocommerce/payment-gateway/integrations/abstract-sv-wc-payment-gateway-integration.php index eb2d3c88b..760e1c993 100644 --- a/woocommerce/payment-gateway/integrations/abstract-sv-wc-payment-gateway-integration.php +++ b/woocommerce/payment-gateway/integrations/abstract-sv-wc-payment-gateway-integration.php @@ -22,11 +22,11 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 */ -namespace SkyVerge\WooCommerce\PluginFramework\v5_13_0; +namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1; defined( 'ABSPATH' ) or exit; -if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_0\\SV_WC_Payment_Gateway_Integration' ) ) : +if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\SV_WC_Payment_Gateway_Integration' ) ) : /** diff --git a/woocommerce/payment-gateway/integrations/class-sv-wc-payment-gateway-integration-pre-orders.php b/woocommerce/payment-gateway/integrations/class-sv-wc-payment-gateway-integration-pre-orders.php index 2b98202ba..18dd77997 100644 --- a/woocommerce/payment-gateway/integrations/class-sv-wc-payment-gateway-integration-pre-orders.php +++ b/woocommerce/payment-gateway/integrations/class-sv-wc-payment-gateway-integration-pre-orders.php @@ -22,11 +22,11 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 */ -namespace SkyVerge\WooCommerce\PluginFramework\v5_13_0; +namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1; defined( 'ABSPATH' ) or exit; -if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_0\\SV_WC_Payment_Gateway_Integration_Pre_Orders' ) ) : +if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\SV_WC_Payment_Gateway_Integration_Pre_Orders' ) ) : /** diff --git a/woocommerce/payment-gateway/integrations/class-sv-wc-payment-gateway-integration-subscriptions.php b/woocommerce/payment-gateway/integrations/class-sv-wc-payment-gateway-integration-subscriptions.php index b844fbfac..c4270678f 100644 --- a/woocommerce/payment-gateway/integrations/class-sv-wc-payment-gateway-integration-subscriptions.php +++ b/woocommerce/payment-gateway/integrations/class-sv-wc-payment-gateway-integration-subscriptions.php @@ -22,11 +22,11 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 */ -namespace SkyVerge\WooCommerce\PluginFramework\v5_13_0; +namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1; defined( 'ABSPATH' ) or exit; -if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_0\\SV_WC_Payment_Gateway_Integration_Subscriptions' ) ) : +if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\SV_WC_Payment_Gateway_Integration_Subscriptions' ) ) : /** diff --git a/woocommerce/payment-gateway/payment-tokens/class-sv-wc-payment-gateway-payment-token.php b/woocommerce/payment-gateway/payment-tokens/class-sv-wc-payment-gateway-payment-token.php index c9eccc1e6..7cd01bd18 100644 --- a/woocommerce/payment-gateway/payment-tokens/class-sv-wc-payment-gateway-payment-token.php +++ b/woocommerce/payment-gateway/payment-tokens/class-sv-wc-payment-gateway-payment-token.php @@ -22,11 +22,11 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 */ -namespace SkyVerge\WooCommerce\PluginFramework\v5_13_0; +namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1; defined( 'ABSPATH' ) or exit; -if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_0\\SV_WC_Payment_Gateway_Payment_Token' ) ) : +if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\SV_WC_Payment_Gateway_Payment_Token' ) ) : /** diff --git a/woocommerce/payment-gateway/payment-tokens/class-sv-wc-payment-gateway-payment-tokens-handler.php b/woocommerce/payment-gateway/payment-tokens/class-sv-wc-payment-gateway-payment-tokens-handler.php index 31edefaa5..d52ddbc0b 100644 --- a/woocommerce/payment-gateway/payment-tokens/class-sv-wc-payment-gateway-payment-tokens-handler.php +++ b/woocommerce/payment-gateway/payment-tokens/class-sv-wc-payment-gateway-payment-tokens-handler.php @@ -22,11 +22,11 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 */ -namespace SkyVerge\WooCommerce\PluginFramework\v5_13_0; +namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1; defined( 'ABSPATH' ) or exit; -if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_0\\SV_WC_Payment_Gateway_Payment_Tokens_Handler' ) ) : +if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\SV_WC_Payment_Gateway_Payment_Tokens_Handler' ) ) : /** diff --git a/woocommerce/payment-gateway/rest-api/class-sv-wc-payment-gateway-plugin-rest-api.php b/woocommerce/payment-gateway/rest-api/class-sv-wc-payment-gateway-plugin-rest-api.php index d80aa70e5..d71604aff 100644 --- a/woocommerce/payment-gateway/rest-api/class-sv-wc-payment-gateway-plugin-rest-api.php +++ b/woocommerce/payment-gateway/rest-api/class-sv-wc-payment-gateway-plugin-rest-api.php @@ -22,19 +22,19 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 */ -namespace SkyVerge\WooCommerce\PluginFramework\v5_13_0\Payment_Gateway; +namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1\Payment_Gateway; -use SkyVerge\WooCommerce\PluginFramework\v5_13_0\REST_API as Plugin_REST_API; +use SkyVerge\WooCommerce\PluginFramework\v5_13_1\REST_API as Plugin_REST_API; defined( 'ABSPATH' ) or exit; -if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_0\\Payment_Gateway\\REST_API' ) ) : +if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\Payment_Gateway\\REST_API' ) ) : /** * The payment gateway plugin REST API handler class. * - * @see \SkyVerge\WooCommerce\PluginFramework\v5_13_0\REST_API + * @see \SkyVerge\WooCommerce\PluginFramework\v5_13_1\REST_API * * @since 5.2.0 */ @@ -47,7 +47,7 @@ class REST_API extends Plugin_REST_API { * * Plugins can override this to add their own data. * - * @see \SkyVerge\WooCommerce\PluginFramework\v5_13_0\REST_API::get_system_status_data() + * @see \SkyVerge\WooCommerce\PluginFramework\v5_13_1\REST_API::get_system_status_data() * * @since 5.2.0 * diff --git a/woocommerce/rest-api/Controllers/Settings.php b/woocommerce/rest-api/Controllers/Settings.php index f0d4fc5e0..07e0b1c49 100644 --- a/woocommerce/rest-api/Controllers/Settings.php +++ b/woocommerce/rest-api/Controllers/Settings.php @@ -22,14 +22,14 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 */ -namespace SkyVerge\WooCommerce\PluginFramework\v5_13_0\REST_API\Controllers; +namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1\REST_API\Controllers; -use SkyVerge\WooCommerce\PluginFramework\v5_13_0\Settings_API\Abstract_Settings; -use SkyVerge\WooCommerce\PluginFramework\v5_13_0\Settings_API\Setting; +use SkyVerge\WooCommerce\PluginFramework\v5_13_1\Settings_API\Abstract_Settings; +use SkyVerge\WooCommerce\PluginFramework\v5_13_1\Settings_API\Setting; defined( 'ABSPATH' ) or exit; -if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_0\\REST_API\\Controllers\\Settings' ) ) : +if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\REST_API\\Controllers\\Settings' ) ) : /** diff --git a/woocommerce/rest-api/class-sv-wc-plugin-rest-api.php b/woocommerce/rest-api/class-sv-wc-plugin-rest-api.php index e4a204ae6..b3f6f0e69 100644 --- a/woocommerce/rest-api/class-sv-wc-plugin-rest-api.php +++ b/woocommerce/rest-api/class-sv-wc-plugin-rest-api.php @@ -22,11 +22,11 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 */ -namespace SkyVerge\WooCommerce\PluginFramework\v5_13_0; +namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1; defined( 'ABSPATH' ) or exit; -if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_0\\REST_API' ) ) : +if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\REST_API' ) ) : /** diff --git a/woocommerce/utilities/class-sv-wp-async-request.php b/woocommerce/utilities/class-sv-wp-async-request.php index 59301f721..afac0883f 100644 --- a/woocommerce/utilities/class-sv-wp-async-request.php +++ b/woocommerce/utilities/class-sv-wp-async-request.php @@ -23,11 +23,11 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 */ -namespace SkyVerge\WooCommerce\PluginFramework\v5_13_0; +namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1; defined( 'ABSPATH' ) or exit; -if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_0\\SV_WP_Async_Request' ) ) : +if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\SV_WP_Async_Request' ) ) : /** diff --git a/woocommerce/utilities/class-sv-wp-background-job-handler.php b/woocommerce/utilities/class-sv-wp-background-job-handler.php index 81b39673f..152816a23 100644 --- a/woocommerce/utilities/class-sv-wp-background-job-handler.php +++ b/woocommerce/utilities/class-sv-wp-background-job-handler.php @@ -23,11 +23,11 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 */ -namespace SkyVerge\WooCommerce\PluginFramework\v5_13_0; +namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1; defined( 'ABSPATH' ) or exit; -if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_0\\SV_WP_Background_Job_Handler' ) ) : +if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\SV_WP_Background_Job_Handler' ) ) : /** diff --git a/woocommerce/utilities/class-sv-wp-job-batch-handler.php b/woocommerce/utilities/class-sv-wp-job-batch-handler.php index f9d83814d..d1cc71659 100644 --- a/woocommerce/utilities/class-sv-wp-job-batch-handler.php +++ b/woocommerce/utilities/class-sv-wp-job-batch-handler.php @@ -22,11 +22,11 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 */ - namespace SkyVerge\WooCommerce\PluginFramework\v5_13_0; + namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1; defined( 'ABSPATH' ) or exit; - if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_0\\SV_WP_Job_Batch_Handler' ) ) : + if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\SV_WP_Job_Batch_Handler' ) ) : /** From 604225c3c8fa816219f1420733cb270648c2bddd Mon Sep 17 00:00:00 2001 From: Nabeel Molham <72820458+nmolham-godaddy@users.noreply.github.com> Date: Fri, 23 Aug 2024 20:37:49 +1000 Subject: [PATCH 03/62] Add IsSingletonTrait (#700) * Define IsSingletonTrait * Add IsSingletonTrait methods * Unit test IsSingletonTrait * Add changelog entry * Check if trait exists rather than class --------- Co-authored-by: Ashley Gibson <99189195+agibson-godaddy@users.noreply.github.com> --- tests/bootstrap.php | 1 + tests/unit/Traits/IsSingletonTraitTest.php | 78 ++++++++++++++++++++++ woocommerce/Traits/IsSingletonTrait.php | 67 +++++++++++++++++++ woocommerce/changelog.txt | 1 + 4 files changed, 147 insertions(+) create mode 100644 tests/unit/Traits/IsSingletonTraitTest.php create mode 100644 woocommerce/Traits/IsSingletonTrait.php diff --git a/tests/bootstrap.php b/tests/bootstrap.php index b846bcfaf..6cd225bdb 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -9,6 +9,7 @@ require_once PLUGIN_ROOT_DIR.'/woocommerce/class-sv-wc-plugin-exception.php'; require_once PLUGIN_ROOT_DIR.'/woocommerce/Enums/Traits/EnumTrait.php'; require_once PLUGIN_ROOT_DIR.'/woocommerce/Enums/PaymentFormContext.php'; +require_once PLUGIN_ROOT_DIR.'/woocommerce/Traits/IsSingletonTrait.php'; WP_Mock::setUsePatchwork(true); WP_Mock::bootstrap(); diff --git a/tests/unit/Traits/IsSingletonTraitTest.php b/tests/unit/Traits/IsSingletonTraitTest.php new file mode 100644 index 000000000..82f0781c2 --- /dev/null +++ b/tests/unit/Traits/IsSingletonTraitTest.php @@ -0,0 +1,78 @@ +singleton = new TestSingleton(); + + $this->setInaccessiblePropertyValue($this->singleton, 'instance', $this->singleton); + } + + /** + * Tests that it can determine whether an instance is loaded or not. + * + * @covers \SkyVerge\WooCommerce\PluginFramework\v5_13_1\Traits\IsSingletonTrait::isLoaded() + */ + public function testCanCheckIfIsLoaded() : void + { + self::assertTrue($this->singleton::isLoaded()); + + $this->singleton::reset(); + + self::assertFalse($this->singleton::isLoaded()); + } + + /** + * Tests that it can initialize and return an instance of self. + * + * @covers \SkyVerge\WooCommerce\PluginFramework\v5_13_1\Traits\IsSingletonTrait::getInstance() + */ + public function testCanGetInstance() : void + { + TestSingleton::reset(); + + $instance = TestSingleton::getInstance(); + + $this->assertInstanceOf(TestSingleton::class, $instance); + $this->assertSame($instance, TestSingleton::getInstance()); + } + + /** + * Tests that an instance can be reset. + * + * @covers \SkyVerge\WooCommerce\PluginFramework\v5_13_1\Traits\IsSingletonTrait::reset() + */ + public function testCanBeReset() : void + { + $this->singleton::reset(); + + $singleton = new ReflectionClass($this->singleton); + $instance = $singleton->getProperty('instance'); + $instance->setAccessible(true); + + self::assertNull($instance->getValue()); + } +} + +/** Dummy class for testing {@see IsSingletonTrait} */ +final class TestSingleton +{ + use IsSingletonTrait; +} diff --git a/woocommerce/Traits/IsSingletonTrait.php b/woocommerce/Traits/IsSingletonTrait.php new file mode 100644 index 000000000..4d4e93ed6 --- /dev/null +++ b/woocommerce/Traits/IsSingletonTrait.php @@ -0,0 +1,67 @@ + Date: Fri, 23 Aug 2024 11:49:17 +0100 Subject: [PATCH 04/62] Add can get new instance trait --- tests/bootstrap.php | 1 + .../Traits/CanGetNewInstanceTraitTest.php | 45 +++++++++++++++++ woocommerce/Traits/CanGetNewInstanceTrait.php | 50 +++++++++++++++++++ woocommerce/class-sv-wc-plugin.php | 4 ++ 4 files changed, 100 insertions(+) create mode 100644 tests/unit/Traits/CanGetNewInstanceTraitTest.php create mode 100644 woocommerce/Traits/CanGetNewInstanceTrait.php diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 6cd225bdb..2240ae4ee 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -9,6 +9,7 @@ require_once PLUGIN_ROOT_DIR.'/woocommerce/class-sv-wc-plugin-exception.php'; require_once PLUGIN_ROOT_DIR.'/woocommerce/Enums/Traits/EnumTrait.php'; require_once PLUGIN_ROOT_DIR.'/woocommerce/Enums/PaymentFormContext.php'; +require_once PLUGIN_ROOT_DIR.'/woocommerce/Traits/CanGetNewInstanceTrait.php'; require_once PLUGIN_ROOT_DIR.'/woocommerce/Traits/IsSingletonTrait.php'; WP_Mock::setUsePatchwork(true); diff --git a/tests/unit/Traits/CanGetNewInstanceTraitTest.php b/tests/unit/Traits/CanGetNewInstanceTraitTest.php new file mode 100644 index 000000000..d6f96d80a --- /dev/null +++ b/tests/unit/Traits/CanGetNewInstanceTraitTest.php @@ -0,0 +1,45 @@ +getTestClass(); + $newInstance = $class::getNewInstance('value1', 'value2'); + + $this->assertSame('value1', $newInstance->arg1); + $this->assertSame('value2', $newInstance->arg2); + $this->assertInstanceOf(get_class($class), $newInstance); + } + + /** + * Anonymous Class for Testing Trait. + * + * @see testItCanGetNewInstance + */ + private function getTestClass() + { + return new class { + use CanGetNewInstanceTrait; + + public $arg1; + public $arg2; + + public function __construct($arg1 = null, $arg2 = null) + { + $this->arg1 = $arg1; + $this->arg2 = $arg2; + } + }; + } +} diff --git a/woocommerce/Traits/CanGetNewInstanceTrait.php b/woocommerce/Traits/CanGetNewInstanceTrait.php new file mode 100644 index 000000000..847802f5e --- /dev/null +++ b/woocommerce/Traits/CanGetNewInstanceTrait.php @@ -0,0 +1,50 @@ +newInstanceArgs(func_get_args()); + } +} diff --git a/woocommerce/class-sv-wc-plugin.php b/woocommerce/class-sv-wc-plugin.php index 0de1e18c1..f3dbb4e33 100644 --- a/woocommerce/class-sv-wc-plugin.php +++ b/woocommerce/class-sv-wc-plugin.php @@ -452,6 +452,10 @@ private function includes() { // common exception class require_once( $framework_path . '/class-sv-wc-plugin-exception.php' ); + // traits + require_once( $framework_path . '/Traits/CanGetNewInstanceTrait.php' ); + require_once( $framework_path . '/Traits/IsSingletonTrait.php' ); + // addresses require_once( $framework_path . '/Addresses/Address.php' ); require_once( $framework_path . '/Addresses/Customer_Address.php' ); From 66df5ff00f9a6705f136578fe815d72dad067306 Mon Sep 17 00:00:00 2001 From: Ashley Gibson Date: Fri, 23 Aug 2024 11:58:22 +0100 Subject: [PATCH 05/62] Add CanConvertToArrayTrait and ArrayHelper --- woocommerce/Helpers/ArrayHelper.php | 126 ++++++++++++++++ woocommerce/Traits/CanConvertToArrayTrait.php | 136 ++++++++++++++++++ 2 files changed, 262 insertions(+) create mode 100644 woocommerce/Helpers/ArrayHelper.php create mode 100644 woocommerce/Traits/CanConvertToArrayTrait.php diff --git a/woocommerce/Helpers/ArrayHelper.php b/woocommerce/Helpers/ArrayHelper.php new file mode 100644 index 000000000..aa6019f47 --- /dev/null +++ b/woocommerce/Helpers/ArrayHelper.php @@ -0,0 +1,126 @@ + 1) { + $part = array_shift($parts); + + if (isset($array[$part]) && is_array($array[$part])) { + $array = &$array[$part]; + } else { + continue 2; + } + } + + unset($array[array_shift($parts)]); + } + } + + /** + * Wraps a given item in an array if it is not an array. + * + * @param mixed $item + * @return array + */ + public static function wrap($item = null) : array + { + if (is_array($item)) { + return $item; + } + + return $item ? [$item] : []; + } + + /** + * Determines if an array key exists. + * + * @param ArrayAccess|array $array + * @param string|int $key + * @return bool + */ + public static function exists($array, $key) : bool + { + if ($array instanceof ArrayAccess) { + return $array->offsetExists($key); + } + + return array_key_exists($key, self::wrap($array)); + } +} diff --git a/woocommerce/Traits/CanConvertToArrayTrait.php b/woocommerce/Traits/CanConvertToArrayTrait.php new file mode 100644 index 000000000..5773ba321 --- /dev/null +++ b/woocommerce/Traits/CanConvertToArrayTrait.php @@ -0,0 +1,136 @@ + + */ + public function toArray() : array + { + if ($this->bailIfInRecursiveCall) { + return []; + } + + $this->bailIfInRecursiveCall = true; + + $array = []; + + foreach ((new ReflectionClass(static::class))->getProperties() as $property) { + if ($this->toArrayShouldPropertyBeAccessible($property)) { + $property->setAccessible(true); + + $propertyValue = $property->getValue($this); + + $value = $propertyValue; + + if ($this->canConvertItemToArray($propertyValue)) { + /** @phpstan-ignore-next-line PhpStan might not understand that the check above means the object has a toArray() method */ + $value = $propertyValue->toArray(); + } elseif (ArrayHelper::accessible($value)) { + $trait = $this; + /* @phpstan-ignore-next-line */ + array_walk($value, static function (&$item) use ($trait) { + $item = $trait->canConvertItemToArray($item) ? $item->toArray() : $item; + }); + } + + $array[$property->getName()] = $value; + } + } + + $this->bailIfInRecursiveCall = false; + + return ArrayHelper::except($array, [ + 'bailIfInRecursiveCall', + 'toArrayIncludePrivate', + 'toArrayIncludeProtected', + 'toArrayIncludePublic', + ]); + } + + /** + * Determines if an item can be converted to an array. + * + * @param mixed $item + * @return bool + */ + protected function canConvertItemToArray($item) : bool + { + return is_object($item) && is_callable([$item, 'toArray']); + } + + /** + * Checks if the property is accessible for {@see toArray()} conversion. + * + * @param ReflectionProperty $property + * @return bool + */ + private function toArrayShouldPropertyBeAccessible(ReflectionProperty $property) : bool + { + // Force accessible for typed properties in PHP <8.1 to avoid an exception from isInitialized() + $property->setAccessible(true); + + if (! $property->isInitialized($this)) { + return false; + } + + if ($this->toArrayIncludePublic && $property->isPublic()) { + return true; + } + + if ($this->toArrayIncludeProtected && $property->isProtected()) { + return true; + } + + if ($this->toArrayIncludePrivate && $property->isPrivate()) { + return true; + } + + return false; + } +} From 3bbc15a162bdfe103fb59910836e0e78a23d2c36 Mon Sep 17 00:00:00 2001 From: Ashley Gibson Date: Fri, 23 Aug 2024 12:15:11 +0100 Subject: [PATCH 06/62] Add tests --- tests/bootstrap.php | 2 + tests/unit/Helpers/ArrayHelperTest.php | 13 ++ .../Traits/CanConvertToArrayTraitTest.php | 153 ++++++++++++++++++ woocommerce/class-sv-wc-plugin.php | 6 + 4 files changed, 174 insertions(+) create mode 100644 tests/unit/Helpers/ArrayHelperTest.php create mode 100644 tests/unit/Traits/CanConvertToArrayTraitTest.php diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 6cd225bdb..6ef60ba21 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -9,6 +9,8 @@ require_once PLUGIN_ROOT_DIR.'/woocommerce/class-sv-wc-plugin-exception.php'; require_once PLUGIN_ROOT_DIR.'/woocommerce/Enums/Traits/EnumTrait.php'; require_once PLUGIN_ROOT_DIR.'/woocommerce/Enums/PaymentFormContext.php'; +require_once PLUGIN_ROOT_DIR.'/woocommerce/Helpers/ArrayHelper.php'; +require_once PLUGIN_ROOT_DIR.'/woocommerce/Traits/CanConvertToArrayTrait.php'; require_once PLUGIN_ROOT_DIR.'/woocommerce/Traits/IsSingletonTrait.php'; WP_Mock::setUsePatchwork(true); diff --git a/tests/unit/Helpers/ArrayHelperTest.php b/tests/unit/Helpers/ArrayHelperTest.php new file mode 100644 index 000000000..08f49307e --- /dev/null +++ b/tests/unit/Helpers/ArrayHelperTest.php @@ -0,0 +1,13 @@ +subject = new TestCanConvertToArray(); + } + + /** + * @covers \SkyVerge\WooCommerce\PluginFramework\v5_13_1\Traits\CanConvertToArrayTrait::toArray() + * @covers \SkyVerge\WooCommerce\PluginFramework\v5_13_1\Traits\CanConvertToArrayTrait::toArrayShouldPropertyBeAccessible() + * + * @dataProvider providerCanConvertPropertiesToArray + * + * @param bool $includePrivateProperties + * @param bool $includeProtectedProperties + * @param bool $includePublicProperties + * @param array $expectedProperties + * @return void + * @throws Exception + */ + public function testCanConvertPropertiesToArray( + bool $includePrivateProperties, + bool $includeProtectedProperties, + bool $includePublicProperties, + array $expectedProperties + ) { + $this->setInaccessiblePropertyValue($this->subject, 'toArrayIncludePrivate', $includePrivateProperties); + $this->setInaccessiblePropertyValue($this->subject, 'toArrayIncludeProtected', $includeProtectedProperties); + $this->setInaccessiblePropertyValue($this->subject, 'toArrayIncludePublic', $includePublicProperties); + + $this->assertSame($expectedProperties, $this->subject->toArray()); + } + + /** @see testCanConvertPropertiesToArray */ + public function providerCanConvertPropertiesToArray(): \Generator + { + yield 'no properties included' => [ + 'includePrivateProperties' => false, + 'includeProtectedProperties' => false, + 'includePublicProperties' => false, + 'expectedProperties' => [], + ]; + + yield 'private properties included' => [ + 'includePrivateProperties' => true, + 'includeProtectedProperties' => false, + 'includePublicProperties' => false, + 'expectedProperties' => [ + 'privateProperty' => 'private', + ], + ]; + + yield 'private and protected properties included' => [ + 'includePrivateProperties' => true, + 'includeProtectedProperties' => true, + 'includePublicProperties' => false, + 'expectedProperties' => [ + 'privateProperty' => 'private', + 'protectedProperty' => 'protected', + ], + ]; + + yield 'private, protected, and public properties included' => [ + 'includePrivateProperties' => true, + 'includeProtectedProperties' => true, + 'includePublicProperties' => true, + 'expectedProperties' => [ + 'privateProperty' => 'private', + 'protectedProperty' => 'protected', + 'publicProperty' => 'public', + ], + ]; + + yield 'private and public properties included' => [ + 'includePrivateProperties' => true, + 'includeProtectedProperties' => false, + 'includePublicProperties' => true, + 'expectedProperties' => [ + 'privateProperty' => 'private', + 'publicProperty' => 'public', + ], + ]; + + yield 'protected and public properties included' => [ + 'includePrivateProperties' => false, + 'includeProtectedProperties' => true, + 'includePublicProperties' => true, + 'expectedProperties' => [ + 'protectedProperty' => 'protected', + 'publicProperty' => 'public', + ], + ]; + } + + /** + * @covers \SkyVerge\WooCommerce\PluginFramework\v5_13_1\Traits\CanConvertToArrayTrait::toArray() + */ + public function testCanConvertNestedProperties(): void + { + $this->markTestIncomplete('TODO'); + } + + /** + * Tests that can determine whether an item can be converted to array. + * + * @covers \SkyVerge\WooCommerce\PluginFramework\v5_13_1\Traits\CanConvertToArrayTrait::canConvertItemToArray() + * + * @throws Exception + */ + public function testCanDetermineWhetherCanConvertItemToArray() + { + $trait = $this->getMockForTrait(CanConvertToArrayTrait::class); + $method = $this->getInaccessibleMethod($trait, 'canConvertItemToArray'); + + $this->assertFalse($method->invokeArgs($trait, [null])); + $this->assertFalse($method->invokeArgs($trait, ['foo'])); + $this->assertFalse($method->invokeArgs($trait, [['foo' => 'bar']])); + $this->assertFalse($method->invokeArgs($trait, [123])); + $this->assertFalse($method->invokeArgs($trait, [new stdClass()])); + $this->assertTrue($method->invokeArgs($trait, [new class() { + public function toArray() + { + return []; + } + }])); + } +} + +/** Dummy class for testing {@see CanConvertToArrayTrait} */ +final class TestCanConvertToArray +{ + use CanConvertToArrayTrait; + + private string $privateProperty = 'private'; + protected string $protectedProperty = 'protected'; + public string $publicProperty = 'public'; + + /** @var bool this property should never be included in arrays because it's not initialized */ + public bool $unInitializedProperty; +} diff --git a/woocommerce/class-sv-wc-plugin.php b/woocommerce/class-sv-wc-plugin.php index 0de1e18c1..7fc618c4d 100644 --- a/woocommerce/class-sv-wc-plugin.php +++ b/woocommerce/class-sv-wc-plugin.php @@ -452,6 +452,12 @@ private function includes() { // common exception class require_once( $framework_path . '/class-sv-wc-plugin-exception.php' ); + // traits + require_once( $framework_path . '/Traits/CanConvertToArrayTrait.php' ); + + // helpers + require_once( $framework_path . '/Helpers/ArrayHelper.php' ); + // addresses require_once( $framework_path . '/Addresses/Address.php' ); require_once( $framework_path . '/Addresses/Customer_Address.php' ); From cb070f7602262ab13ab1ebb1f8606a7b05d84e96 Mon Sep 17 00:00:00 2001 From: Ashley Gibson Date: Fri, 23 Aug 2024 12:16:28 +0100 Subject: [PATCH 07/62] Update changelog --- woocommerce/changelog.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/woocommerce/changelog.txt b/woocommerce/changelog.txt index 6488962e6..3d1aab460 100644 --- a/woocommerce/changelog.txt +++ b/woocommerce/changelog.txt @@ -1,7 +1,8 @@ *** SkyVerge WooCommerce Plugin Framework Changelog *** 2024.nn.nn - version 5.13.1-dev.1 -* Feature - Add a trait to get a singular instance of a class IsSingletonTrait +* Feature - Add a trait to get a singular instance of a class: `IsSingletonTrait` +* Feature - Add a trait to get an instance (non-singular) of a class: `CanGetNewInstanceTrait` 2024.08.21 - version 5.13.0 * Feature - Add a trait for enum-like classes From 798179abfb5166f2b70fd5f9341454efaaf20dee Mon Sep 17 00:00:00 2001 From: Ashley Gibson Date: Fri, 23 Aug 2024 12:32:09 +0100 Subject: [PATCH 08/62] More tests --- tests/unit/Helpers/ArrayHelperTest.php | 226 +++++++++++++++++++++++++ 1 file changed, 226 insertions(+) diff --git a/tests/unit/Helpers/ArrayHelperTest.php b/tests/unit/Helpers/ArrayHelperTest.php index 08f49307e..b9b385c84 100644 --- a/tests/unit/Helpers/ArrayHelperTest.php +++ b/tests/unit/Helpers/ArrayHelperTest.php @@ -2,6 +2,9 @@ namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1\Tests\Unit\Helpers; +use ArrayAccess; +use Generator; +use SkyVerge\WooCommerce\PluginFramework\v5_13_1\Helpers\ArrayHelper; use SkyVerge\WooCommerce\PluginFramework\v5_13_1\Tests\TestCase; /** @@ -9,5 +12,228 @@ */ final class ArrayHelperTest extends TestCase { + /** + * @covers ::accessible() + * @dataProvider providerCanDetermineIsAccessible + * + * @param mixed $item + * @param bool $expected + * @return void + */ + public function testCanDetermineIsAccessible($item, bool $expected): void + { + $this->assertSame($expected, ArrayHelper::accessible($item)); + } + /** @see testCanDetermineIsAccessible */ + public function providerCanDetermineIsAccessible(): Generator + { + yield 'array is accessible' => [ + 'item' => ['foo' => 'bar'], + 'expected' => true, + ]; + + yield 'ArrayAccess is accessible' => [ + 'item' => $this->getArrayAccessObject(), + 'expected' => true, + ]; + + yield 'object without ArrayAccess is not accessible' => [ + 'item' => new \stdClass(), + 'expected' => false, + ]; + + yield 'integer is not accessible' => [ + 'item' => 10, + 'expected' => false, + ]; + + yield 'string is not accessible' => [ + 'item' => 'string', + 'expected' => false, + ]; + } + + /** + * @covers ::except() + * @dataProvider providerExcept + * + * @param array $inputArray + * @param array|string $keysToExclude + * @param array $expectedOutputArray + * @return void + */ + public function testExcept(array $inputArray, $keysToExclude, array $expectedOutputArray): void + { + $this->assertSame( + $expectedOutputArray, + ArrayHelper::except($inputArray, $keysToExclude) + ); + } + + /** @see testExcept */ + public function providerExcept(): Generator + { + yield 'array of keys' => [ + 'inputArray' => [ + 'apple' => 'red', + 'banana' => 'yellow', + 'cucumber' => 'green', + ], + 'keysToExclude' => ['apple', 'cucumber'], + 'expectedOutputArray' => [ + 'banana' => 'yellow', + ], + ]; + + yield 'key as a string' => [ + 'inputArray' => [ + 'apple' => 'red', + 'banana' => 'yellow', + 'cucumber' => 'green', + ], + 'keysToExclude' => 'banana', + 'expectedOutputArray' => [ + 'apple' => 'red', + 'cucumber' => 'green', + ], + ]; + + yield 'keys to exclude do not exist' => [ + 'inputArray' => [ + 'apple' => 'red', + 'banana' => 'yellow', + 'cucumber' => 'green', + ], + 'keysToExclude' => ['invalid'], + 'expectedOutputArray' => [ + 'apple' => 'red', + 'banana' => 'yellow', + 'cucumber' => 'green', + ], + ]; + } + + /** + * @covers ::remove() + */ + public function testCanRemove(): void + { + $this->markTestIncomplete('TODO'); + } + + /** + * @covers ::wrap() + * @dataProvider providerCanWrap + * + * @param mixed $item + * @param array $expectedOutput + * @return void + */ + public function testCanWrap($item, array $expectedOutput): void + { + $this->assertEquals($expectedOutput, ArrayHelper::wrap($item)); + } + + /** @see testCanWrap */ + public function providerCanWrap(): Generator + { + yield 'already an array' => [ + 'item' => ['foo' => 'bar'], + 'expectedOutput' => ['foo' => 'bar'], + ]; + + yield 'integer' => [ + 'item' => 50, + 'expectedOutput' => [50], + ]; + + yield 'null item' => [ + 'item' => null, + 'expectedOutput' => [], + ]; + + yield 'empty string' => [ + 'item' => '', + 'expectedOutput' => [], + ]; + } + + /** + * @covers ::exists() + * @dataProvider providerCanDetermineKeyExists + * + * @param array|ArrayAccess $input + * @param string|int $key + * @param bool $expected + * @return void + */ + public function testCanDetermineKeyExists($input, $key, bool $expected): void + { + $this->assertSame( + $expected, + ArrayHelper::exists($input, $key) + ); + } + + /** @see testCanDetermineKeyExists */ + public function providerCanDetermineKeyExists(): Generator + { + yield 'ArrayAccess' => [ + 'input' => $this->getArrayAccessObject(), + 'key' => 'key', + 'expected' => true, + ]; + + yield 'array with string key that exists' => [ + 'input' => ['foo' => 'bar'], + 'key' => 'foo', + 'expected' => true, + ]; + + yield 'array with string key that does not exist' => [ + 'input' => ['foo' => 'bar'], + 'key' => 'invalid', + 'expected' => false, + ]; + + yield 'array with integer key that exists' => [ + 'input' => ['chocolate', 'vanilla'], + 'key' => 1, + 'expected' => true, + ]; + + yield 'array with integer key that does not exist' => [ + 'input' => ['chocolate', 'vanilla'], + 'key' => 5, + 'expected' => false, + ]; + } + + protected function getArrayAccessObject(): ArrayAccess + { + return new class implements ArrayAccess + { + + public function offsetExists($offset) + { + return true; + } + + public function offsetGet($offset) + { + return 1; + } + + public function offsetSet($offset, $value) + { + // TODO: Implement offsetSet() method. + } + + public function offsetUnset($offset) + { + // TODO: Implement offsetUnset() method. + } + }; + } } From 0bf9d776e9f0f24af1f46cde40af7a50999ae479 Mon Sep 17 00:00:00 2001 From: Ashley Gibson Date: Fri, 23 Aug 2024 12:32:14 +0100 Subject: [PATCH 09/62] Update changelog --- woocommerce/changelog.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/woocommerce/changelog.txt b/woocommerce/changelog.txt index 6488962e6..9baf0beb5 100644 --- a/woocommerce/changelog.txt +++ b/woocommerce/changelog.txt @@ -2,6 +2,8 @@ 2024.nn.nn - version 5.13.1-dev.1 * Feature - Add a trait to get a singular instance of a class IsSingletonTrait +* Feature - Add a trait to convert an object into an array: `CanConvertToArrayTrait` +* Feature - Add a new `ArrayHelper` class for array-related utility methods 2024.08.21 - version 5.13.0 * Feature - Add a trait for enum-like classes From 01934632ad2d2bc16abc045ba87c4cf3c9f1005c Mon Sep 17 00:00:00 2001 From: Nabeel Molham Date: Mon, 26 Aug 2024 13:55:45 +1000 Subject: [PATCH 10/62] Use spread operator instead of class reflections for better performance --- woocommerce/Traits/CanGetNewInstanceTrait.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/woocommerce/Traits/CanGetNewInstanceTrait.php b/woocommerce/Traits/CanGetNewInstanceTrait.php index 847802f5e..3e15592b8 100644 --- a/woocommerce/Traits/CanGetNewInstanceTrait.php +++ b/woocommerce/Traits/CanGetNewInstanceTrait.php @@ -24,8 +24,6 @@ namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1\Traits; -use ReflectionClass; - defined('ABSPATH') or exit; if (trait_exists('\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\Traits\\CanGetNewInstanceTrait')) { @@ -43,8 +41,8 @@ trait CanGetNewInstanceTrait * * @return static */ - public static function getNewInstance() + public static function getNewInstance(...$args) { - return (new ReflectionClass(static::class))->newInstanceArgs(func_get_args()); + return new static(...$args); } } From fce9ec719d5f46e2b64cd85dbab83f2b62d71e58 Mon Sep 17 00:00:00 2001 From: Nabeel Molham Date: Mon, 26 Aug 2024 13:56:53 +1000 Subject: [PATCH 11/62] Use spread operator instead of func_get_args --- woocommerce/Traits/IsSingletonTrait.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/woocommerce/Traits/IsSingletonTrait.php b/woocommerce/Traits/IsSingletonTrait.php index 4d4e93ed6..447360998 100644 --- a/woocommerce/Traits/IsSingletonTrait.php +++ b/woocommerce/Traits/IsSingletonTrait.php @@ -50,9 +50,9 @@ public static function isLoaded() : bool * * @return static */ - public static function getInstance() + public static function getInstance(...$args) { - return static::$instance ??= new static(...func_get_args()); + return static::$instance ??= new static(...$args); } /** From 6f266df3d2c99caf8d2f3cbb5ecadd9fd5c5eb52 Mon Sep 17 00:00:00 2001 From: Nabeel Molham Date: Mon, 26 Aug 2024 13:56:59 +1000 Subject: [PATCH 12/62] Update unit tests --- .../Traits/CanGetNewInstanceTraitTest.php | 25 +++++++++++++++---- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/tests/unit/Traits/CanGetNewInstanceTraitTest.php b/tests/unit/Traits/CanGetNewInstanceTraitTest.php index d6f96d80a..1604e7877 100644 --- a/tests/unit/Traits/CanGetNewInstanceTraitTest.php +++ b/tests/unit/Traits/CanGetNewInstanceTraitTest.php @@ -8,11 +8,11 @@ class CanGetNewInstanceTraitTest extends TestCase { /** - * Tests that it can get new instance. + * Tests that it can get new instance with arguments. * * @covers \SkyVerge\WooCommerce\PluginFramework\v5_13_1\Traits\CanGetNewInstanceTrait::getNewInstance() */ - public function testItCanGetNewInstance() + public function testItCanGetNewInstanceWithArgs() : void { $class = $this->getTestClass(); $newInstance = $class::getNewInstance('value1', 'value2'); @@ -22,6 +22,21 @@ public function testItCanGetNewInstance() $this->assertInstanceOf(get_class($class), $newInstance); } + /** + * Tests that it can get new instance without arguments. + * + * @covers \SkyVerge\WooCommerce\PluginFramework\v5_13_1\Traits\CanGetNewInstanceTrait::getNewInstance() + */ + public function testItCanGetNewInstanceWithoutArgs() : void + { + $class = $this->getTestClass(); + $newInstance = $class::getNewInstance(); + + $this->assertNull($newInstance->arg1); + $this->assertNull($newInstance->arg2); + $this->assertInstanceOf(get_class($class), $newInstance); + } + /** * Anonymous Class for Testing Trait. * @@ -32,10 +47,10 @@ private function getTestClass() return new class { use CanGetNewInstanceTrait; - public $arg1; - public $arg2; + public ?string $arg1 = null; + public ?string $arg2 = null; - public function __construct($arg1 = null, $arg2 = null) + public function __construct(?string $arg1 = null, ?string $arg2 = null) { $this->arg1 = $arg1; $this->arg2 = $arg2; From 86eb78c171147993505cac77d4a7e09c1ae03741 Mon Sep 17 00:00:00 2001 From: Nabeel Molham Date: Mon, 26 Aug 2024 14:17:16 +1000 Subject: [PATCH 13/62] Tests nested objects infinite recursion prevention --- .../Traits/CanConvertToArrayTraitTest.php | 215 +++++++++++++++--- 1 file changed, 181 insertions(+), 34 deletions(-) diff --git a/tests/unit/Traits/CanConvertToArrayTraitTest.php b/tests/unit/Traits/CanConvertToArrayTraitTest.php index ac46b6006..43d45f539 100644 --- a/tests/unit/Traits/CanConvertToArrayTraitTest.php +++ b/tests/unit/Traits/CanConvertToArrayTraitTest.php @@ -3,6 +3,7 @@ namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1\Tests\Unit\Traits; use Exception; +use Generator; use SkyVerge\WooCommerce\PluginFramework\v5_13_1\Tests\TestCase; use SkyVerge\WooCommerce\PluginFramework\v5_13_1\Traits\CanConvertToArrayTrait; use stdClass; @@ -36,7 +37,7 @@ public function testCanConvertPropertiesToArray( bool $includeProtectedProperties, bool $includePublicProperties, array $expectedProperties - ) { + ) : void { $this->setInaccessiblePropertyValue($this->subject, 'toArrayIncludePrivate', $includePrivateProperties); $this->setInaccessiblePropertyValue($this->subject, 'toArrayIncludeProtected', $includeProtectedProperties); $this->setInaccessiblePropertyValue($this->subject, 'toArrayIncludePublic', $includePublicProperties); @@ -45,72 +46,168 @@ public function testCanConvertPropertiesToArray( } /** @see testCanConvertPropertiesToArray */ - public function providerCanConvertPropertiesToArray(): \Generator + public function providerCanConvertPropertiesToArray() : Generator { yield 'no properties included' => [ - 'includePrivateProperties' => false, + 'includePrivateProperties' => false, 'includeProtectedProperties' => false, - 'includePublicProperties' => false, - 'expectedProperties' => [], + 'includePublicProperties' => false, + 'expectedProperties' => [], ]; yield 'private properties included' => [ - 'includePrivateProperties' => true, + 'includePrivateProperties' => true, 'includeProtectedProperties' => false, - 'includePublicProperties' => false, - 'expectedProperties' => [ + 'includePublicProperties' => false, + 'expectedProperties' => [ 'privateProperty' => 'private', ], ]; yield 'private and protected properties included' => [ - 'includePrivateProperties' => true, + 'includePrivateProperties' => true, 'includeProtectedProperties' => true, - 'includePublicProperties' => false, - 'expectedProperties' => [ - 'privateProperty' => 'private', + 'includePublicProperties' => false, + 'expectedProperties' => [ + 'privateProperty' => 'private', 'protectedProperty' => 'protected', ], ]; yield 'private, protected, and public properties included' => [ - 'includePrivateProperties' => true, + 'includePrivateProperties' => true, 'includeProtectedProperties' => true, - 'includePublicProperties' => true, - 'expectedProperties' => [ - 'privateProperty' => 'private', + 'includePublicProperties' => true, + 'expectedProperties' => [ + 'privateProperty' => 'private', 'protectedProperty' => 'protected', - 'publicProperty' => 'public', + 'publicProperty' => 'public', ], ]; yield 'private and public properties included' => [ - 'includePrivateProperties' => true, + 'includePrivateProperties' => true, 'includeProtectedProperties' => false, - 'includePublicProperties' => true, - 'expectedProperties' => [ + 'includePublicProperties' => true, + 'expectedProperties' => [ 'privateProperty' => 'private', - 'publicProperty' => 'public', + 'publicProperty' => 'public', ], ]; yield 'protected and public properties included' => [ - 'includePrivateProperties' => false, + 'includePrivateProperties' => false, 'includeProtectedProperties' => true, - 'includePublicProperties' => true, - 'expectedProperties' => [ + 'includePublicProperties' => true, + 'expectedProperties' => [ 'protectedProperty' => 'protected', - 'publicProperty' => 'public', + 'publicProperty' => 'public', ], ]; } /** + * Tests nested objects that may or may not use the same trait. + * * @covers \SkyVerge\WooCommerce\PluginFramework\v5_13_1\Traits\CanConvertToArrayTrait::toArray() + * + * @dataProvider providerCanConvertNestedProperties + * + * @param TestSubjectWithNestedProperty $object + * @param mixed $nestedObject + * @param array $expected */ - public function testCanConvertNestedProperties(): void + public function testCanConvertNestedProperties( + TestSubjectWithNestedProperty $object, + $nestedObject, + array $expected + ) : void { + $object->nestedProperty = $nestedObject; + + $this->assertSame($expected, $object->toArray()); + } + + /** @see testCanConvertNestedProperties */ + public function providerCanConvertNestedProperties() : Generator { - $this->markTestIncomplete('TODO'); + yield 'Nested object is null' => [ + 'object' => new TestSubjectWithNestedProperty(), + 'nestedObject' => null, + 'expected' => ['nestedProperty' => null], + ]; + + yield 'Nested object is a primitive type' => [ + 'object' => new TestSubjectWithNestedProperty(), + 'nestedObject' => 'test', + 'expected' => ['nestedProperty' => 'test'], + ]; + + $randomObject = new class { + }; + + yield 'Nested object is an object that doesn\'t use the trait' => [ + 'object' => new TestSubjectWithNestedProperty(), + 'nestedObject' => $randomObject, + 'expected' => ['nestedProperty' => $randomObject], + ]; + + yield 'Nested object is an object that uses the trait' => [ + 'object' => new TestSubjectWithNestedProperty(), + 'nestedObject' => new TestSubjectWithNestedProperty(), + 'expected' => ['nestedProperty' => ['nestedProperty' => null]], + ]; + + yield 'Nested object is an array of primitive types' => [ + 'object' => new TestSubjectWithNestedProperty(), + 'nestedObject' => ['a', 'b'], + 'expected' => ['nestedProperty' => ['a', 'b']], + ]; + + yield 'Nested object is an associative array of primitive types' => [ + 'object' => new TestSubjectWithNestedProperty(), + 'nestedObject' => ['a' => 'b'], + 'expected' => ['nestedProperty' => ['a' => 'b']], + ]; + + yield 'Nested object is an associative array of objects that doesn\'t use the trait' => [ + 'object' => new TestSubjectWithNestedProperty(), + 'nestedObject' => ['a' => $randomObject], + 'expected' => ['nestedProperty' => ['a' => $randomObject]], + ]; + + yield 'Nested object is an array of objects that use the trait' => [ + 'object' => new TestSubjectWithNestedProperty(), + 'nestedObject' => [new TestSubjectWithNestedProperty()], + 'expected' => [ + 'nestedProperty' => [ + ['nestedProperty' => null], + ], + ], + ]; + + yield 'Nested object is an associative array of objects that use the trait' => [ + 'object' => new TestSubjectWithNestedProperty(), + 'nestedObject' => ['a' => new TestSubjectWithNestedProperty()], + 'expected' => [ + 'nestedProperty' => [ + 'a' => ['nestedProperty' => null], + ], + ], + ]; + + yield 'Nested object is a two-dimensional array' => [ + 'object' => new TestSubjectWithNestedProperty(), + 'nestedObject' => [ + ['a' => $randomObject], + ['a' => $randomObject], + ], + 'expected' => [ + 'nestedProperty' => [ + ['a' => $randomObject], + ['a' => $randomObject], + ], + ], + ]; } /** @@ -120,7 +217,7 @@ public function testCanConvertNestedProperties(): void * * @throws Exception */ - public function testCanDetermineWhetherCanConvertItemToArray() + public function testCanDetermineWhetherCanConvertItemToArray() : void { $trait = $this->getMockForTrait(CanConvertToArrayTrait::class); $method = $this->getInaccessibleMethod($trait, 'canConvertItemToArray'); @@ -130,12 +227,55 @@ public function testCanDetermineWhetherCanConvertItemToArray() $this->assertFalse($method->invokeArgs($trait, [['foo' => 'bar']])); $this->assertFalse($method->invokeArgs($trait, [123])); $this->assertFalse($method->invokeArgs($trait, [new stdClass()])); - $this->assertTrue($method->invokeArgs($trait, [new class() { - public function toArray() - { - return []; - } - }])); + $this->assertTrue($method->invokeArgs($trait, [ + new class() { + public function toArray() : array + { + return []; + } + }, + ])); + } + + /** + * Tests nested objects infinite recursion prevention. + * + * @covers \SkyVerge\WooCommerce\PluginFramework\v5_13_1\Traits\CanConvertToArrayTrait::toArray() + */ + public function testCanConvertNestedPropertiesWontDoInfiniteRecursion() : void + { + $objectA = new TestSubjectWithNestedProperty(); + $objectB = new TestSubjectWithNestedProperty(); + $objectC = new TestSubjectWithNestedProperty(); + + $objectA->nestedProperty = $objectB; + $objectB->nestedProperty = $objectC; + $objectC->nestedProperty = $objectA; + + // tests that a infinite recursion is prevented + $this->assertSame([ + // object A + 'nestedProperty' => [ + // object B + 'nestedProperty' => [ + // object C + 'nestedProperty' => [], + ], + ], + ], $objectA->toArray()); + + // tests that the recursion flag won't affect subsequent toArray() calls + // also makes sure the recursion flag acts per instance, not per class + $this->assertSame([ + // object B + 'nestedProperty' => [ + // object C + 'nestedProperty' => [ + // object A + 'nestedProperty' => [], + ], + ], + ], $objectB->toArray()); } } @@ -151,3 +291,10 @@ final class TestCanConvertToArray /** @var bool this property should never be included in arrays because it's not initialized */ public bool $unInitializedProperty; } + +final class TestSubjectWithNestedProperty +{ + use CanConvertToArrayTrait; + + public $nestedProperty; +} From 332b89a3c3431159e2db597cf2dd4393356262a1 Mon Sep 17 00:00:00 2001 From: Nabeel Molham Date: Mon, 26 Aug 2024 14:21:53 +1000 Subject: [PATCH 14/62] Unit test ArrayHelper::remove method --- tests/unit/Helpers/ArrayHelperTest.php | 53 +++++++++++++++++++++++--- woocommerce/Helpers/ArrayHelper.php | 2 +- 2 files changed, 48 insertions(+), 7 deletions(-) diff --git a/tests/unit/Helpers/ArrayHelperTest.php b/tests/unit/Helpers/ArrayHelperTest.php index b9b385c84..772b5f447 100644 --- a/tests/unit/Helpers/ArrayHelperTest.php +++ b/tests/unit/Helpers/ArrayHelperTest.php @@ -115,11 +115,52 @@ public function providerExcept(): Generator } /** + * Tests that can remove items from an array. + * * @covers ::remove() + * @dataProvider providerCanRemove + * + * @param array $input + * @param string|string[] $keysToRemove + * @param array $expected */ - public function testCanRemove(): void + public function testCanRemoveItemsFromArray(array $input, $keysToRemove, array $expected) : void { - $this->markTestIncomplete('TODO'); + ArrayHelper::remove($input, $keysToRemove); + $this->assertEquals($expected, $input); + } + + /** @see testCanRemoveItemsFromArray */ + public function providerCanRemove() : Generator + { + yield 'remove 1 key from one item array' => [ + 'input' => ['test' => 1], + 'keysToRemove' => 'test', + 'expected' => [], + ]; + + yield 'remove 1 key from two item array' => [ + 'input' => ['test' => 2, 'second' => ['nested' => 3]], + 'keysToRemove' => 'second', + 'expected' => ['test' => 2], + ]; + + yield 'remove 2 keys' => [ + 'input' => ['test' => 2, 'second' => ['nested' => 3], 'third' => 4], + 'keysToRemove' => ['second', 'third'], + 'expected' => ['test' => 2], + ]; + + yield 'remove 2 keys that are one level deep' => [ + 'input' => [ + 'resource' => [ + 'first' => 1, + 'second' => 2, + ], + ], + 'keysToRemove' => ['resource.first', 'resource.second'], + 'expected' => ['resource' => []], + ]; } /** @@ -215,22 +256,22 @@ protected function getArrayAccessObject(): ArrayAccess return new class implements ArrayAccess { - public function offsetExists($offset) + public function offsetExists($offset) : bool { return true; } - public function offsetGet($offset) + public function offsetGet($offset) : int { return 1; } - public function offsetSet($offset, $value) + public function offsetSet($offset, $value) : void { // TODO: Implement offsetSet() method. } - public function offsetUnset($offset) + public function offsetUnset($offset) : void { // TODO: Implement offsetUnset() method. } diff --git a/woocommerce/Helpers/ArrayHelper.php b/woocommerce/Helpers/ArrayHelper.php index aa6019f47..464d5188a 100644 --- a/woocommerce/Helpers/ArrayHelper.php +++ b/woocommerce/Helpers/ArrayHelper.php @@ -62,7 +62,7 @@ public static function except(array $array, $keys) : array * @param array $array * @param array|string $keys */ - public static function remove(array &$array, $keys) + public static function remove(array &$array, $keys) : void { $original = &$array; From 150c93fc08a36b2b504a9156fdd28febee899389 Mon Sep 17 00:00:00 2001 From: Nabeel Molham Date: Mon, 26 Aug 2024 16:42:31 +1000 Subject: [PATCH 15/62] Define PSR4 autoloading --- composer.json | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/composer.json b/composer.json index aa02aab74..6c2e2c341 100644 --- a/composer.json +++ b/composer.json @@ -16,6 +16,11 @@ "codeception/module-asserts": "^1.3", "10up/wp_mock": "^1.0" }, + "autoload": { + "psr-4": { + "SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\": "woocommerce/" + } + }, "autoload-dev": { "psr-4": { "SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\Tests\\": "tests/" From 54f199a727a4b6a9a53d282292d9c5082959ad24 Mon Sep 17 00:00:00 2001 From: Nabeel Molham Date: Mon, 26 Aug 2024 16:45:47 +1000 Subject: [PATCH 16/62] Autoloading Country_Helper --- woocommerce/Country_Helper.php | 6 ------ woocommerce/class-sv-wc-plugin.php | 1 - 2 files changed, 7 deletions(-) diff --git a/woocommerce/Country_Helper.php b/woocommerce/Country_Helper.php index 2509eb025..06bcb241c 100644 --- a/woocommerce/Country_Helper.php +++ b/woocommerce/Country_Helper.php @@ -26,9 +26,6 @@ defined( 'ABSPATH' ) or exit; -if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\Country_Helper' ) ) : - - /** * SkyVerge Country Helper Class * @@ -657,6 +654,3 @@ public static function get_flipped_calling_codes() { } - - -endif; diff --git a/woocommerce/class-sv-wc-plugin.php b/woocommerce/class-sv-wc-plugin.php index ed2cb00f3..ccad4c3d3 100644 --- a/woocommerce/class-sv-wc-plugin.php +++ b/woocommerce/class-sv-wc-plugin.php @@ -471,7 +471,6 @@ private function includes() { // common utility methods require_once( $framework_path . '/class-sv-wc-helper.php' ); - require_once( $framework_path . '/Country_Helper.php' ); require_once( $framework_path . '/admin/Notes_Helper.php' ); // backwards compatibility for older WC versions From 187db8574209f64076e1f5f04e49f72678a0db6d Mon Sep 17 00:00:00 2001 From: Nabeel Molham Date: Mon, 26 Aug 2024 16:47:19 +1000 Subject: [PATCH 17/62] Autoloading traits --- tests/bootstrap.php | 3 --- tests/unit/CountryHelperTest.php | 7 ------- woocommerce/class-sv-wc-plugin.php | 5 ----- 3 files changed, 15 deletions(-) diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 907435b8a..9d1617a99 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -9,9 +9,6 @@ require_once PLUGIN_ROOT_DIR.'/woocommerce/class-sv-wc-plugin-exception.php'; require_once PLUGIN_ROOT_DIR.'/woocommerce/Enums/Traits/EnumTrait.php'; require_once PLUGIN_ROOT_DIR.'/woocommerce/Enums/PaymentFormContext.php'; -require_once PLUGIN_ROOT_DIR.'/woocommerce/Traits/CanGetNewInstanceTrait.php'; -require_once PLUGIN_ROOT_DIR.'/woocommerce/Traits/CanConvertToArrayTrait.php'; -require_once PLUGIN_ROOT_DIR.'/woocommerce/Traits/IsSingletonTrait.php'; require_once PLUGIN_ROOT_DIR.'/woocommerce/Helpers/ArrayHelper.php'; WP_Mock::setUsePatchwork(true); diff --git a/tests/unit/CountryHelperTest.php b/tests/unit/CountryHelperTest.php index 7cca7f6d4..ae0802673 100644 --- a/tests/unit/CountryHelperTest.php +++ b/tests/unit/CountryHelperTest.php @@ -7,13 +7,6 @@ class CountryHelperTest extends TestCase { - public function setUp() : void - { - parent::setUp(); - - require_once PLUGIN_ROOT_DIR.'/woocommerce/Country_Helper.php'; - } - /** * @covers \SkyVerge\WooCommerce\PluginFramework\v5_13_1\Country_Helper::convert_alpha_country_code() * diff --git a/woocommerce/class-sv-wc-plugin.php b/woocommerce/class-sv-wc-plugin.php index ccad4c3d3..15d141ff5 100644 --- a/woocommerce/class-sv-wc-plugin.php +++ b/woocommerce/class-sv-wc-plugin.php @@ -452,11 +452,6 @@ private function includes() { // common exception class require_once( $framework_path . '/class-sv-wc-plugin-exception.php' ); - // traits - require_once( $framework_path . '/Traits/CanGetNewInstanceTrait.php' ); - require_once( $framework_path . '/Traits/IsSingletonTrait.php' ); - require_once( $framework_path . '/Traits/CanConvertToArrayTrait.php' ); - // helpers require_once( $framework_path . '/Helpers/ArrayHelper.php' ); From fb7cf27044021ab8f01fb08eeb87a2f33dd807fb Mon Sep 17 00:00:00 2001 From: Nabeel Molham Date: Mon, 26 Aug 2024 16:48:41 +1000 Subject: [PATCH 18/62] Autoloading enums --- tests/bootstrap.php | 2 -- woocommerce/class-sv-wc-plugin.php | 4 ---- 2 files changed, 6 deletions(-) diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 9d1617a99..2e226d13e 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -7,8 +7,6 @@ require_once PLUGIN_ROOT_DIR.'/vendor/autoload.php'; require_once PLUGIN_ROOT_DIR.'/woocommerce/class-sv-wc-plugin.php'; require_once PLUGIN_ROOT_DIR.'/woocommerce/class-sv-wc-plugin-exception.php'; -require_once PLUGIN_ROOT_DIR.'/woocommerce/Enums/Traits/EnumTrait.php'; -require_once PLUGIN_ROOT_DIR.'/woocommerce/Enums/PaymentFormContext.php'; require_once PLUGIN_ROOT_DIR.'/woocommerce/Helpers/ArrayHelper.php'; WP_Mock::setUsePatchwork(true); diff --git a/woocommerce/class-sv-wc-plugin.php b/woocommerce/class-sv-wc-plugin.php index 15d141ff5..29e2f6197 100644 --- a/woocommerce/class-sv-wc-plugin.php +++ b/woocommerce/class-sv-wc-plugin.php @@ -503,10 +503,6 @@ private function includes() { require_once( $framework_path . '/class-sv-wc-admin-notice-handler.php' ); require_once( $framework_path . '/Lifecycle.php' ); require_once( $framework_path . '/rest-api/class-sv-wc-plugin-rest-api.php' ); - - // Enums - require_once $framework_path . '/Enums/Traits/EnumTrait.php'; - require_once $framework_path . '/Enums/PaymentFormContext.php'; } From 7abe302c9771ef6dc3191c165abd9d6933fad3fd Mon Sep 17 00:00:00 2001 From: Nabeel Molham Date: Mon, 26 Aug 2024 16:58:45 +1000 Subject: [PATCH 19/62] Map Payment_Gateway namespace --- composer.json | 3 ++- woocommerce/class-sv-wc-plugin.php | 1 - 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 6c2e2c341..bf2ff4756 100644 --- a/composer.json +++ b/composer.json @@ -18,7 +18,8 @@ }, "autoload": { "psr-4": { - "SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\": "woocommerce/" + "SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\": "woocommerce/", + "SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\Payment_Gateway\\": "woocommerce/payment-gateway/" } }, "autoload-dev": { diff --git a/woocommerce/class-sv-wc-plugin.php b/woocommerce/class-sv-wc-plugin.php index 29e2f6197..775c3059c 100644 --- a/woocommerce/class-sv-wc-plugin.php +++ b/woocommerce/class-sv-wc-plugin.php @@ -496,7 +496,6 @@ private function includes() { require_once( $framework_path . '/rest-api/Controllers/Settings.php' ); // Handlers - require_once( $framework_path . '/Handlers/Script_Handler.php' ); require_once( $framework_path . '/class-sv-wc-plugin-dependencies.php' ); require_once( $framework_path . '/class-sv-wc-hook-deprecator.php' ); require_once( $framework_path . '/class-sv-wp-admin-message-handler.php' ); From 822e47a99a23e7bade992bc7f0545c00cfe74470 Mon Sep 17 00:00:00 2001 From: Nabeel Molham Date: Mon, 26 Aug 2024 17:03:04 +1000 Subject: [PATCH 20/62] Place PaymentFormContextChecker under the correct namespace --- .../PaymentFormContextCheckerTest.php | 16 +++++++--------- .../PaymentFormContextChecker.php | 3 ++- 2 files changed, 9 insertions(+), 10 deletions(-) rename tests/unit/{ => Payment_Gateway}/PaymentFormContextCheckerTest.php (92%) diff --git a/tests/unit/PaymentFormContextCheckerTest.php b/tests/unit/Payment_Gateway/PaymentFormContextCheckerTest.php similarity index 92% rename from tests/unit/PaymentFormContextCheckerTest.php rename to tests/unit/Payment_Gateway/PaymentFormContextCheckerTest.php index bc9e32053..c2564a1e2 100644 --- a/tests/unit/PaymentFormContextCheckerTest.php +++ b/tests/unit/Payment_Gateway/PaymentFormContextCheckerTest.php @@ -1,12 +1,12 @@ testObject = Mockery::mock(PaymentFormContextChecker::class) ->shouldAllowMockingProtectedMethods() ->makePartial(); @@ -40,7 +38,7 @@ public function tearDown() : void } /** - * @covers \SkyVerge\WooCommerce\PluginFramework\v5_13_1\PaymentFormContextChecker::getContextSessionKeyName() + * @covers \SkyVerge\WooCommerce\PluginFramework\v5_13_1\Payment_Gateway\PaymentFormContextChecker::getContextSessionKeyName() * @throws ReflectionException */ public function testCanGetContextSessionKeyName() : void @@ -54,7 +52,7 @@ public function testCanGetContextSessionKeyName() : void } /** - * @covers \SkyVerge\WooCommerce\PluginFramework\v5_13_1\PaymentFormContextChecker::maybeSetContext() + * @covers \SkyVerge\WooCommerce\PluginFramework\v5_13_1\Payment_Gateway\PaymentFormContextChecker::maybeSetContext() */ public function testCanSetContext() : void { @@ -83,7 +81,7 @@ public function testCanSetContext() : void } /** - * @covers \SkyVerge\WooCommerce\PluginFramework\v5_13_1\PaymentFormContextChecker::getCurrentPaymentFormContext() + * @covers \SkyVerge\WooCommerce\PluginFramework\v5_13_1\Payment_Gateway\PaymentFormContextChecker::getCurrentPaymentFormContext() * * @dataProvider providerCanGetCurrentPaymentFormContext * @@ -144,7 +142,7 @@ public function providerCanGetCurrentPaymentFormContext() : Generator } /** - * @covers \SkyVerge\WooCommerce\PluginFramework\v5_13_1\PaymentFormContextChecker::getStoredPaymentFormContext() + * @covers \SkyVerge\WooCommerce\PluginFramework\v5_13_1\Payment_Gateway\PaymentFormContextChecker::getStoredPaymentFormContext() * @throws ReflectionException */ public function testCanGetStoredPaymentFormContext() : void @@ -172,7 +170,7 @@ public function testCanGetStoredPaymentFormContext() : void } /** - * @covers \SkyVerge\WooCommerce\PluginFramework\v5_13_1\PaymentFormContextChecker::currentContextRequiresTermsAndConditionsAcceptance() + * @covers \SkyVerge\WooCommerce\PluginFramework\v5_13_1\Payment_Gateway\PaymentFormContextChecker::currentContextRequiresTermsAndConditionsAcceptance() * * @dataProvider providerCanDetermineCurrentContextRequiresTermsAndConditionsAcceptance * diff --git a/woocommerce/payment-gateway/PaymentFormContextChecker.php b/woocommerce/payment-gateway/PaymentFormContextChecker.php index 98b96bab6..c8a137d5d 100644 --- a/woocommerce/payment-gateway/PaymentFormContextChecker.php +++ b/woocommerce/payment-gateway/PaymentFormContextChecker.php @@ -1,8 +1,9 @@ Date: Mon, 26 Aug 2024 17:08:54 +1000 Subject: [PATCH 21/62] Autoload Handlers namespace --- tests/unit/AutoloadingTest.php | 28 +++++++++++++++++++ .../class-sv-wc-payment-gateway-plugin.php | 5 ---- 2 files changed, 28 insertions(+), 5 deletions(-) create mode 100644 tests/unit/AutoloadingTest.php diff --git a/tests/unit/AutoloadingTest.php b/tests/unit/AutoloadingTest.php new file mode 100644 index 000000000..04f2a7e11 --- /dev/null +++ b/tests/unit/AutoloadingTest.php @@ -0,0 +1,28 @@ +assertInstanceOf($className, Mockery::mock($className)->makePartial()); + } + } +} diff --git a/woocommerce/payment-gateway/class-sv-wc-payment-gateway-plugin.php b/woocommerce/payment-gateway/class-sv-wc-payment-gateway-plugin.php index fea9a3003..ac0a487ba 100644 --- a/woocommerce/payment-gateway/class-sv-wc-payment-gateway-plugin.php +++ b/woocommerce/payment-gateway/class-sv-wc-payment-gateway-plugin.php @@ -315,11 +315,6 @@ private function includes() { require_once( $payment_gateway_framework_path . '/class-sv-wc-payment-gateway-payment-form.php' ); require_once( $payment_gateway_framework_path . '/class-sv-wc-payment-gateway-my-payment-methods.php' ); - // handlers - require_once( $payment_gateway_framework_path . '/Handlers/Abstract_Payment_Handler.php' ); - require_once( $payment_gateway_framework_path . '/Handlers/Abstract_Hosted_Payment_Handler.php' ); - require_once( $payment_gateway_framework_path . '/Handlers/Capture.php' ); - // External Checkout require_once( "{$payment_gateway_framework_path}/External_Checkout/External_Checkout.php" ); require_once( "{$payment_gateway_framework_path}/External_Checkout/Admin.php" ); From 7350d97ca63ef65aeb7dff620e5a3686b4cbb203 Mon Sep 17 00:00:00 2001 From: Nabeel Molham Date: Mon, 26 Aug 2024 17:10:29 +1000 Subject: [PATCH 22/62] Autoload Payment_Gateway\External_Checkout namespace --- tests/unit/AutoloadingTest.php | 8 ++++++++ .../class-sv-wc-payment-gateway-plugin.php | 6 ------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/tests/unit/AutoloadingTest.php b/tests/unit/AutoloadingTest.php index 04f2a7e11..b971f3d3b 100644 --- a/tests/unit/AutoloadingTest.php +++ b/tests/unit/AutoloadingTest.php @@ -3,6 +3,10 @@ namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1\Tests\Unit; use Mockery; +use SkyVerge\WooCommerce\PluginFramework\v5_13_1\Payment_Gateway\External_Checkout\Admin; +use SkyVerge\WooCommerce\PluginFramework\v5_13_1\Payment_Gateway\External_Checkout\External_Checkout; +use SkyVerge\WooCommerce\PluginFramework\v5_13_1\Payment_Gateway\External_Checkout\Frontend; +use SkyVerge\WooCommerce\PluginFramework\v5_13_1\Payment_Gateway\External_Checkout\Orders; use SkyVerge\WooCommerce\PluginFramework\v5_13_1\Payment_Gateway\Handlers\Abstract_Hosted_Payment_Handler; use SkyVerge\WooCommerce\PluginFramework\v5_13_1\Payment_Gateway\Handlers\Abstract_Payment_Handler; use SkyVerge\WooCommerce\PluginFramework\v5_13_1\Payment_Gateway\Handlers\Capture; @@ -19,6 +23,10 @@ public function testCanAutoload() : void Capture::class, Abstract_Payment_Handler::class, Abstract_Hosted_Payment_Handler::class, + External_Checkout::class, + Admin::class, + Frontend::class, + Orders::class, ]; foreach ($list as $className) { diff --git a/woocommerce/payment-gateway/class-sv-wc-payment-gateway-plugin.php b/woocommerce/payment-gateway/class-sv-wc-payment-gateway-plugin.php index ac0a487ba..d349446c6 100644 --- a/woocommerce/payment-gateway/class-sv-wc-payment-gateway-plugin.php +++ b/woocommerce/payment-gateway/class-sv-wc-payment-gateway-plugin.php @@ -315,12 +315,6 @@ private function includes() { require_once( $payment_gateway_framework_path . '/class-sv-wc-payment-gateway-payment-form.php' ); require_once( $payment_gateway_framework_path . '/class-sv-wc-payment-gateway-my-payment-methods.php' ); - // External Checkout - require_once( "{$payment_gateway_framework_path}/External_Checkout/External_Checkout.php" ); - require_once( "{$payment_gateway_framework_path}/External_Checkout/Admin.php" ); - require_once( "{$payment_gateway_framework_path}/External_Checkout/Frontend.php" ); - require_once( "{$payment_gateway_framework_path}/External_Checkout/Orders.php" ); - // Apple Pay require_once( "{$payment_gateway_framework_path}/External_Checkout/apple-pay/class-sv-wc-payment-gateway-apple-pay.php" ); require_once( "{$payment_gateway_framework_path}/External_Checkout/apple-pay/class-sv-wc-payment-gateway-apple-pay-admin.php" ); From 5e6f97859cf529d5c99b84a629562d3eba7c0148 Mon Sep 17 00:00:00 2001 From: Nabeel Molham Date: Mon, 26 Aug 2024 17:14:25 +1000 Subject: [PATCH 23/62] Autoload Payment_Gateway\External_Checkout\Google_Pay namespace --- tests/unit/AutoloadingTest.php | 15 +++++++++------ .../class-sv-wc-payment-gateway-plugin.php | 6 ------ 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/tests/unit/AutoloadingTest.php b/tests/unit/AutoloadingTest.php index b971f3d3b..789d03e6a 100644 --- a/tests/unit/AutoloadingTest.php +++ b/tests/unit/AutoloadingTest.php @@ -6,10 +6,9 @@ use SkyVerge\WooCommerce\PluginFramework\v5_13_1\Payment_Gateway\External_Checkout\Admin; use SkyVerge\WooCommerce\PluginFramework\v5_13_1\Payment_Gateway\External_Checkout\External_Checkout; use SkyVerge\WooCommerce\PluginFramework\v5_13_1\Payment_Gateway\External_Checkout\Frontend; +use SkyVerge\WooCommerce\PluginFramework\v5_13_1\Payment_Gateway\External_Checkout\Google_Pay as Google_Pay_Checkout; use SkyVerge\WooCommerce\PluginFramework\v5_13_1\Payment_Gateway\External_Checkout\Orders; -use SkyVerge\WooCommerce\PluginFramework\v5_13_1\Payment_Gateway\Handlers\Abstract_Hosted_Payment_Handler; -use SkyVerge\WooCommerce\PluginFramework\v5_13_1\Payment_Gateway\Handlers\Abstract_Payment_Handler; -use SkyVerge\WooCommerce\PluginFramework\v5_13_1\Payment_Gateway\Handlers\Capture; +use SkyVerge\WooCommerce\PluginFramework\v5_13_1\Payment_Gateway\Handlers as Handlers; use SkyVerge\WooCommerce\PluginFramework\v5_13_1\Tests\TestCase; /** @@ -20,13 +19,17 @@ class AutoloadingTest extends TestCase public function testCanAutoload() : void { $list = [ - Capture::class, - Abstract_Payment_Handler::class, - Abstract_Hosted_Payment_Handler::class, + Handlers\Capture::class, + Handlers\Abstract_Payment_Handler::class, + Handlers\Abstract_Hosted_Payment_Handler::class, External_Checkout::class, Admin::class, Frontend::class, Orders::class, + Google_Pay_Checkout\Google_Pay::class, + Google_Pay_Checkout\Admin::class, + Google_Pay_Checkout\AJAX::class, + Google_Pay_Checkout\Frontend::class, ]; foreach ($list as $className) { diff --git a/woocommerce/payment-gateway/class-sv-wc-payment-gateway-plugin.php b/woocommerce/payment-gateway/class-sv-wc-payment-gateway-plugin.php index d349446c6..6fcbcc79c 100644 --- a/woocommerce/payment-gateway/class-sv-wc-payment-gateway-plugin.php +++ b/woocommerce/payment-gateway/class-sv-wc-payment-gateway-plugin.php @@ -322,12 +322,6 @@ private function includes() { require_once( "{$payment_gateway_framework_path}/External_Checkout/apple-pay/class-sv-wc-payment-gateway-apple-pay-ajax.php" ); require_once( "{$payment_gateway_framework_path}/External_Checkout/apple-pay/api/class-sv-wc-payment-gateway-apple-pay-payment-response.php" ); - // Google Pay - require_once( "{$payment_gateway_framework_path}/External_Checkout/Google_Pay/Google_Pay.php" ); - require_once( "{$payment_gateway_framework_path}/External_Checkout/Google_Pay/Admin.php" ); - require_once( "{$payment_gateway_framework_path}/External_Checkout/Google_Pay/AJAX.php" ); - require_once( "{$payment_gateway_framework_path}/External_Checkout/Google_Pay/Frontend.php" ); - // payment tokens require_once( $payment_gateway_framework_path . '/payment-tokens/class-sv-wc-payment-gateway-payment-token.php' ); require_once( $payment_gateway_framework_path . '/payment-tokens/class-sv-wc-payment-gateway-payment-tokens-handler.php' ); From 854ccc873949b0b27b3e4632a0ad77be2b02f0e9 Mon Sep 17 00:00:00 2001 From: Nabeel Molham Date: Mon, 26 Aug 2024 17:20:31 +1000 Subject: [PATCH 24/62] Autoload Payment_Gateway\Blocks namespace --- tests/unit/AutoloadingTest.php | 5 +++++ .../payment-gateway/Blocks/Gateway_Blocks_Handler.php | 5 ----- .../payment-gateway/class-sv-wc-payment-gateway-plugin.php | 3 --- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/tests/unit/AutoloadingTest.php b/tests/unit/AutoloadingTest.php index 789d03e6a..d3db4815b 100644 --- a/tests/unit/AutoloadingTest.php +++ b/tests/unit/AutoloadingTest.php @@ -3,6 +3,7 @@ namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1\Tests\Unit; use Mockery; +use SkyVerge\WooCommerce\PluginFramework\v5_13_1\Payment_Gateway\Blocks as Payment_Gateway_Blocks; use SkyVerge\WooCommerce\PluginFramework\v5_13_1\Payment_Gateway\External_Checkout\Admin; use SkyVerge\WooCommerce\PluginFramework\v5_13_1\Payment_Gateway\External_Checkout\External_Checkout; use SkyVerge\WooCommerce\PluginFramework\v5_13_1\Payment_Gateway\External_Checkout\Frontend; @@ -30,8 +31,12 @@ public function testCanAutoload() : void Google_Pay_Checkout\Admin::class, Google_Pay_Checkout\AJAX::class, Google_Pay_Checkout\Frontend::class, + Payment_Gateway_Blocks\Gateway_Blocks_Handler::class, + Payment_Gateway_Blocks\Gateway_Checkout_Block_Integration::class, ]; + Mockery::mock('\Automattic\WooCommerce\Blocks\Payments\Integrations\AbstractPaymentMethodType'); + foreach ($list as $className) { $this->assertInstanceOf($className, Mockery::mock($className)->makePartial()); } diff --git a/woocommerce/payment-gateway/Blocks/Gateway_Blocks_Handler.php b/woocommerce/payment-gateway/Blocks/Gateway_Blocks_Handler.php index 7b73d05fa..74fbd113f 100644 --- a/woocommerce/payment-gateway/Blocks/Gateway_Blocks_Handler.php +++ b/woocommerce/payment-gateway/Blocks/Gateway_Blocks_Handler.php @@ -7,9 +7,6 @@ use SkyVerge\WooCommerce\PluginFramework\v5_13_1\Blocks\Blocks_Handler; use SkyVerge\WooCommerce\PluginFramework\v5_13_1\SV_WC_Payment_Gateway_Plugin; - -use function Patchwork\Redefinitions\LanguageConstructs\_require_once; - if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\Payment_Gateway\Blocks\\Gateway_Blocks_Handler' ) ) : /** @@ -59,8 +56,6 @@ public function handle_blocks_integration() : void { /** @var SV_WC_Payment_Gateway_Plugin $plugin */ $plugin = $this->plugin; - require_once( $plugin->get_payment_gateway_framework_path() . '/Blocks/Gateway_Checkout_Block_Integration.php' ); - foreach ( $plugin->get_gateways() as $gateway ) { if ( $checkout_integration = $gateway->get_checkout_block_integration_instance() ) { diff --git a/woocommerce/payment-gateway/class-sv-wc-payment-gateway-plugin.php b/woocommerce/payment-gateway/class-sv-wc-payment-gateway-plugin.php index 6fcbcc79c..2165d666e 100644 --- a/woocommerce/payment-gateway/class-sv-wc-payment-gateway-plugin.php +++ b/woocommerce/payment-gateway/class-sv-wc-payment-gateway-plugin.php @@ -181,9 +181,6 @@ protected function init_rest_api_handler() { */ protected function init_blocks_handler() : void { - require_once( $this->get_framework_path() . '/Blocks/Blocks_Handler.php' ); - require_once( $this->get_payment_gateway_framework_path() . '/Blocks/Gateway_Blocks_Handler.php' ); - // individual gateway plugins should initialize their block integrations handler by overriding this method $this->blocks_handler = new Gateway_Blocks_Handler( $this ); } From ba85ecf6ceb12408d42fd5f4ff74d71e6715eaea Mon Sep 17 00:00:00 2001 From: Nabeel Molham Date: Mon, 26 Aug 2024 17:24:16 +1000 Subject: [PATCH 25/62] Autoload Settings_API namespace --- tests/unit/AutoloadingTest.php | 4 ++++ tests/unit/Settings_API/SettingTest.php | 10 ---------- woocommerce/class-sv-wc-plugin.php | 5 ----- 3 files changed, 4 insertions(+), 15 deletions(-) diff --git a/tests/unit/AutoloadingTest.php b/tests/unit/AutoloadingTest.php index d3db4815b..4babbeaf5 100644 --- a/tests/unit/AutoloadingTest.php +++ b/tests/unit/AutoloadingTest.php @@ -10,6 +10,7 @@ use SkyVerge\WooCommerce\PluginFramework\v5_13_1\Payment_Gateway\External_Checkout\Google_Pay as Google_Pay_Checkout; use SkyVerge\WooCommerce\PluginFramework\v5_13_1\Payment_Gateway\External_Checkout\Orders; use SkyVerge\WooCommerce\PluginFramework\v5_13_1\Payment_Gateway\Handlers as Handlers; +use SkyVerge\WooCommerce\PluginFramework\v5_13_1\Settings_API as Settings_API; use SkyVerge\WooCommerce\PluginFramework\v5_13_1\Tests\TestCase; /** @@ -33,6 +34,9 @@ public function testCanAutoload() : void Google_Pay_Checkout\Frontend::class, Payment_Gateway_Blocks\Gateway_Blocks_Handler::class, Payment_Gateway_Blocks\Gateway_Checkout_Block_Integration::class, + Settings_API\Abstract_Settings::class, + Settings_API\Setting::class, + Settings_API\Control::class, ]; Mockery::mock('\Automattic\WooCommerce\Blocks\Payments\Integrations\AbstractPaymentMethodType'); diff --git a/tests/unit/Settings_API/SettingTest.php b/tests/unit/Settings_API/SettingTest.php index c81ccaf92..bf8c0333c 100644 --- a/tests/unit/Settings_API/SettingTest.php +++ b/tests/unit/Settings_API/SettingTest.php @@ -8,14 +8,6 @@ class SettingTest extends TestCase { - public function setUp() : void - { - parent::setUp(); - - require_once PLUGIN_ROOT_DIR.'/woocommerce/Settings_API/Abstract_Settings.php'; - require_once PLUGIN_ROOT_DIR.'/woocommerce/Settings_API/Setting.php'; - } - /** * @covers \SkyVerge\WooCommerce\PluginFramework\v5_13_1\Settings_API\Setting::set_id() * @@ -303,8 +295,6 @@ public function provider_set_value() : array */ public function provider_set_control() : array { - require_once PLUGIN_ROOT_DIR.'/woocommerce/Settings_API/Control.php'; - $control = new Control(); return [ diff --git a/woocommerce/class-sv-wc-plugin.php b/woocommerce/class-sv-wc-plugin.php index 775c3059c..69d9fbaf8 100644 --- a/woocommerce/class-sv-wc-plugin.php +++ b/woocommerce/class-sv-wc-plugin.php @@ -459,11 +459,6 @@ private function includes() { require_once( $framework_path . '/Addresses/Address.php' ); require_once( $framework_path . '/Addresses/Customer_Address.php' ); - // Settings API - require_once( $framework_path . '/Settings_API/Abstract_Settings.php' ); - require_once( $framework_path . '/Settings_API/Setting.php' ); - require_once( $framework_path . '/Settings_API/Control.php' ); - // common utility methods require_once( $framework_path . '/class-sv-wc-helper.php' ); require_once( $framework_path . '/admin/Notes_Helper.php' ); From 5c48eb19755610481c068aa6cb54476b4e3998d9 Mon Sep 17 00:00:00 2001 From: Nabeel Molham Date: Mon, 26 Aug 2024 17:25:09 +1000 Subject: [PATCH 26/62] Autoload Helpers namespace --- tests/bootstrap.php | 1 - tests/unit/Settings_API/ControlTest.php | 8 -------- woocommerce/class-sv-wc-plugin.php | 3 --- 3 files changed, 12 deletions(-) diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 2e226d13e..5500f22cf 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -7,7 +7,6 @@ require_once PLUGIN_ROOT_DIR.'/vendor/autoload.php'; require_once PLUGIN_ROOT_DIR.'/woocommerce/class-sv-wc-plugin.php'; require_once PLUGIN_ROOT_DIR.'/woocommerce/class-sv-wc-plugin-exception.php'; -require_once PLUGIN_ROOT_DIR.'/woocommerce/Helpers/ArrayHelper.php'; WP_Mock::setUsePatchwork(true); WP_Mock::bootstrap(); diff --git a/tests/unit/Settings_API/ControlTest.php b/tests/unit/Settings_API/ControlTest.php index 03b714765..98f10529d 100644 --- a/tests/unit/Settings_API/ControlTest.php +++ b/tests/unit/Settings_API/ControlTest.php @@ -9,14 +9,6 @@ class ControlTest extends TestCase { - - public function setUp() : void - { - parent::setUp(); - - require_once PLUGIN_ROOT_DIR.'/woocommerce/Settings_API/Control.php'; - } - /** * @covers \SkyVerge\WooCommerce\PluginFramework\v5_13_1\Settings_API\Control::get_setting_id() * @throws SV_WC_Plugin_Exception diff --git a/woocommerce/class-sv-wc-plugin.php b/woocommerce/class-sv-wc-plugin.php index 69d9fbaf8..9a3b72606 100644 --- a/woocommerce/class-sv-wc-plugin.php +++ b/woocommerce/class-sv-wc-plugin.php @@ -452,9 +452,6 @@ private function includes() { // common exception class require_once( $framework_path . '/class-sv-wc-plugin-exception.php' ); - // helpers - require_once( $framework_path . '/Helpers/ArrayHelper.php' ); - // addresses require_once( $framework_path . '/Addresses/Address.php' ); require_once( $framework_path . '/Addresses/Customer_Address.php' ); From 6779677fc9e55d152def719be1f5f24451436de0 Mon Sep 17 00:00:00 2001 From: Nabeel Molham Date: Mon, 26 Aug 2024 17:33:48 +1000 Subject: [PATCH 27/62] Autoload API namespace --- composer.json | 3 ++- tests/unit/API/CacheableRequestTraitTest.php | 1 - tests/unit/AutoloadingTest.php | 4 ++++ woocommerce/class-sv-wc-plugin.php | 4 ---- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/composer.json b/composer.json index bf2ff4756..ec2b98f6e 100644 --- a/composer.json +++ b/composer.json @@ -19,7 +19,8 @@ "autoload": { "psr-4": { "SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\": "woocommerce/", - "SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\Payment_Gateway\\": "woocommerce/payment-gateway/" + "SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\Payment_Gateway\\": "woocommerce/payment-gateway/", + "SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\API\\": "woocommerce/api/" } }, "autoload-dev": { diff --git a/tests/unit/API/CacheableRequestTraitTest.php b/tests/unit/API/CacheableRequestTraitTest.php index 239886745..24b3f1600 100644 --- a/tests/unit/API/CacheableRequestTraitTest.php +++ b/tests/unit/API/CacheableRequestTraitTest.php @@ -13,7 +13,6 @@ public function setUp() : void require_once PLUGIN_ROOT_DIR.'/woocommerce/api/interface-sv-wc-api-request.php'; require_once PLUGIN_ROOT_DIR.'/woocommerce/api/abstract-sv-wc-api-json-request.php'; - require_once PLUGIN_ROOT_DIR.'/woocommerce/api/traits/Cacheable_Request_Trait.php'; } /** diff --git a/tests/unit/AutoloadingTest.php b/tests/unit/AutoloadingTest.php index 4babbeaf5..a63336ad4 100644 --- a/tests/unit/AutoloadingTest.php +++ b/tests/unit/AutoloadingTest.php @@ -3,6 +3,7 @@ namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1\Tests\Unit; use Mockery; +use SkyVerge\WooCommerce\PluginFramework\v5_13_1\API\Abstract_Cacheable_API_Base; use SkyVerge\WooCommerce\PluginFramework\v5_13_1\Payment_Gateway\Blocks as Payment_Gateway_Blocks; use SkyVerge\WooCommerce\PluginFramework\v5_13_1\Payment_Gateway\External_Checkout\Admin; use SkyVerge\WooCommerce\PluginFramework\v5_13_1\Payment_Gateway\External_Checkout\External_Checkout; @@ -20,6 +21,8 @@ class AutoloadingTest extends TestCase { public function testCanAutoload() : void { + require_once PLUGIN_ROOT_DIR.'/woocommerce/api/class-sv-wc-api-base.php'; + $list = [ Handlers\Capture::class, Handlers\Abstract_Payment_Handler::class, @@ -37,6 +40,7 @@ public function testCanAutoload() : void Settings_API\Abstract_Settings::class, Settings_API\Setting::class, Settings_API\Control::class, + Abstract_Cacheable_API_Base::class, ]; Mockery::mock('\Automattic\WooCommerce\Blocks\Payments\Integrations\AbstractPaymentMethodType'); diff --git a/woocommerce/class-sv-wc-plugin.php b/woocommerce/class-sv-wc-plugin.php index 9a3b72606..a4fd07c58 100644 --- a/woocommerce/class-sv-wc-plugin.php +++ b/woocommerce/class-sv-wc-plugin.php @@ -480,10 +480,6 @@ private function includes() { require_once( $framework_path . '/api/abstract-sv-wc-api-json-request.php' ); require_once( $framework_path . '/api/abstract-sv-wc-api-json-response.php' ); - // Cacheable API - require_once( $framework_path . '/api/traits/Cacheable_Request_Trait.php' ); - require_once( $framework_path . '/api/Abstract_Cacheable_API_Base.php' ); - // REST API Controllers require_once( $framework_path . '/rest-api/Controllers/Settings.php' ); From 0fa7993bbb3c702a63ee86a9ebc72047b7a5b35d Mon Sep 17 00:00:00 2001 From: Nabeel Molham Date: Mon, 26 Aug 2024 17:35:44 +1000 Subject: [PATCH 28/62] Autoload Admin namespace --- composer.json | 1 + tests/unit/AutoloadingTest.php | 2 ++ woocommerce/class-sv-wc-plugin.php | 1 - 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index ec2b98f6e..011e03b5e 100644 --- a/composer.json +++ b/composer.json @@ -19,6 +19,7 @@ "autoload": { "psr-4": { "SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\": "woocommerce/", + "SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\Admin\\": "woocommerce/admin/", "SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\Payment_Gateway\\": "woocommerce/payment-gateway/", "SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\API\\": "woocommerce/api/" } diff --git a/tests/unit/AutoloadingTest.php b/tests/unit/AutoloadingTest.php index a63336ad4..b9a58736d 100644 --- a/tests/unit/AutoloadingTest.php +++ b/tests/unit/AutoloadingTest.php @@ -3,6 +3,7 @@ namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1\Tests\Unit; use Mockery; +use SkyVerge\WooCommerce\PluginFramework\v5_13_1\Admin\Notes_Helper; use SkyVerge\WooCommerce\PluginFramework\v5_13_1\API\Abstract_Cacheable_API_Base; use SkyVerge\WooCommerce\PluginFramework\v5_13_1\Payment_Gateway\Blocks as Payment_Gateway_Blocks; use SkyVerge\WooCommerce\PluginFramework\v5_13_1\Payment_Gateway\External_Checkout\Admin; @@ -41,6 +42,7 @@ public function testCanAutoload() : void Settings_API\Setting::class, Settings_API\Control::class, Abstract_Cacheable_API_Base::class, + Notes_Helper::class, ]; Mockery::mock('\Automattic\WooCommerce\Blocks\Payments\Integrations\AbstractPaymentMethodType'); diff --git a/woocommerce/class-sv-wc-plugin.php b/woocommerce/class-sv-wc-plugin.php index a4fd07c58..0d52dc8b2 100644 --- a/woocommerce/class-sv-wc-plugin.php +++ b/woocommerce/class-sv-wc-plugin.php @@ -458,7 +458,6 @@ private function includes() { // common utility methods require_once( $framework_path . '/class-sv-wc-helper.php' ); - require_once( $framework_path . '/admin/Notes_Helper.php' ); // backwards compatibility for older WC versions require_once( $framework_path . '/class-sv-wc-plugin-compatibility.php' ); From 95fd07bbbaba1e3ec0dcd8b18a0a61e3236abc7d Mon Sep 17 00:00:00 2001 From: Nabeel Molham Date: Mon, 26 Aug 2024 17:37:14 +1000 Subject: [PATCH 29/62] Autoload Addresses namespace --- tests/unit/AutoloadingTest.php | 3 +++ woocommerce/class-sv-wc-plugin.php | 4 ---- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/tests/unit/AutoloadingTest.php b/tests/unit/AutoloadingTest.php index b9a58736d..9980b20b6 100644 --- a/tests/unit/AutoloadingTest.php +++ b/tests/unit/AutoloadingTest.php @@ -3,6 +3,7 @@ namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1\Tests\Unit; use Mockery; +use SkyVerge\WooCommerce\PluginFramework\v5_13_1\Addresses as Addresses; use SkyVerge\WooCommerce\PluginFramework\v5_13_1\Admin\Notes_Helper; use SkyVerge\WooCommerce\PluginFramework\v5_13_1\API\Abstract_Cacheable_API_Base; use SkyVerge\WooCommerce\PluginFramework\v5_13_1\Payment_Gateway\Blocks as Payment_Gateway_Blocks; @@ -43,6 +44,8 @@ public function testCanAutoload() : void Settings_API\Control::class, Abstract_Cacheable_API_Base::class, Notes_Helper::class, + Addresses\Address::class, + Addresses\Customer_Address::class, ]; Mockery::mock('\Automattic\WooCommerce\Blocks\Payments\Integrations\AbstractPaymentMethodType'); diff --git a/woocommerce/class-sv-wc-plugin.php b/woocommerce/class-sv-wc-plugin.php index 0d52dc8b2..47540f931 100644 --- a/woocommerce/class-sv-wc-plugin.php +++ b/woocommerce/class-sv-wc-plugin.php @@ -452,10 +452,6 @@ private function includes() { // common exception class require_once( $framework_path . '/class-sv-wc-plugin-exception.php' ); - // addresses - require_once( $framework_path . '/Addresses/Address.php' ); - require_once( $framework_path . '/Addresses/Customer_Address.php' ); - // common utility methods require_once( $framework_path . '/class-sv-wc-helper.php' ); From fb5efbb36b59fdd0278d507c8d9849450e037357 Mon Sep 17 00:00:00 2001 From: Nabeel Molham Date: Mon, 26 Aug 2024 17:44:03 +1000 Subject: [PATCH 30/62] Temp api/traits dir rename --- .../api/{traits => OtherTraits}/Cacheable_Request_Trait.php | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename woocommerce/api/{traits => OtherTraits}/Cacheable_Request_Trait.php (100%) diff --git a/woocommerce/api/traits/Cacheable_Request_Trait.php b/woocommerce/api/OtherTraits/Cacheable_Request_Trait.php similarity index 100% rename from woocommerce/api/traits/Cacheable_Request_Trait.php rename to woocommerce/api/OtherTraits/Cacheable_Request_Trait.php From d7ee9d89b8a8448ae5e3e9d2b7a98cd244ef4cac Mon Sep 17 00:00:00 2001 From: Nabeel Molham Date: Mon, 26 Aug 2024 17:44:34 +1000 Subject: [PATCH 31/62] Revert temp renaming --- .../api/{OtherTraits => Traits}/Cacheable_Request_Trait.php | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename woocommerce/api/{OtherTraits => Traits}/Cacheable_Request_Trait.php (100%) diff --git a/woocommerce/api/OtherTraits/Cacheable_Request_Trait.php b/woocommerce/api/Traits/Cacheable_Request_Trait.php similarity index 100% rename from woocommerce/api/OtherTraits/Cacheable_Request_Trait.php rename to woocommerce/api/Traits/Cacheable_Request_Trait.php From 3ffed13aa542fdbb06543730e8eb0d650cc04121 Mon Sep 17 00:00:00 2001 From: Nabeel Molham Date: Mon, 26 Aug 2024 17:47:26 +1000 Subject: [PATCH 32/62] Move Country_Helper under Helpers namespace --- tests/unit/{ => Helpers}/CountryHelperTest.php | 6 +++--- woocommerce/{ => Handlers}/Country_Helper.php | 10 ++++++---- 2 files changed, 9 insertions(+), 7 deletions(-) rename tests/unit/{ => Helpers}/CountryHelperTest.php (79%) rename woocommerce/{ => Handlers}/Country_Helper.php (98%) diff --git a/tests/unit/CountryHelperTest.php b/tests/unit/Helpers/CountryHelperTest.php similarity index 79% rename from tests/unit/CountryHelperTest.php rename to tests/unit/Helpers/CountryHelperTest.php index ae0802673..cc024b6a0 100644 --- a/tests/unit/CountryHelperTest.php +++ b/tests/unit/Helpers/CountryHelperTest.php @@ -1,14 +1,14 @@ ISO 3166-alpha3 */ - static public $alpha3 = [ + static public array $alpha3 = [ 'AF' => 'AFG', 'AL' => 'ALB', 'DZ' => 'DZA', 'AD' => 'AND', 'AO' => 'AGO', 'AG' => 'ATG', 'AR' => 'ARG', 'AM' => 'ARM', 'AU' => 'AUS', 'AT' => 'AUT', 'AZ' => 'AZE', 'BS' => 'BHS', 'BH' => 'BHR', 'BD' => 'BGD', 'BB' => 'BRB', @@ -92,7 +94,7 @@ class Country_Helper { ]; /** @var array ISO 3166-alpha2 => ISO 3166-numeric */ - static public $numeric = [ + static public array $numeric = [ 'AF' => '004', 'AX' => '248', 'AL' => '008', 'DZ' => '012', 'AS' => '016', 'AD' => '020', 'AO' => '024', 'AI' => '660', 'AQ' => '010', 'AG' => '028', 'AR' => '032', 'AM' => '051', 'AW' => '533', 'AU' => '036', 'AT' => '040', @@ -146,7 +148,7 @@ class Country_Helper { ]; /** @var array ISO 3166-alpha2 => phone calling code(s) */ - static public $calling_codes = [ + static public array $calling_codes = [ 'BD' => '+880', 'BE' => '+32', 'BF' => '+226', From 3fb89faa5093f0e5b9354506ca4c7cd07d2e1fc6 Mon Sep 17 00:00:00 2001 From: Nabeel Molham Date: Wed, 28 Aug 2024 12:13:15 +1000 Subject: [PATCH 33/62] Setup class aliases --- tests/unit/AutoloadingTest.php | 30 ++++++++++++++++++++++++++++++ woocommerce/class-sv-wc-plugin.php | 24 ++++++++++++++++++++++++ 2 files changed, 54 insertions(+) diff --git a/tests/unit/AutoloadingTest.php b/tests/unit/AutoloadingTest.php index 9980b20b6..19d7b119a 100644 --- a/tests/unit/AutoloadingTest.php +++ b/tests/unit/AutoloadingTest.php @@ -3,9 +3,11 @@ namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1\Tests\Unit; use Mockery; +use ReflectionException; use SkyVerge\WooCommerce\PluginFramework\v5_13_1\Addresses as Addresses; use SkyVerge\WooCommerce\PluginFramework\v5_13_1\Admin\Notes_Helper; use SkyVerge\WooCommerce\PluginFramework\v5_13_1\API\Abstract_Cacheable_API_Base; +use SkyVerge\WooCommerce\PluginFramework\v5_13_1\Handlers\Country_Helper; use SkyVerge\WooCommerce\PluginFramework\v5_13_1\Payment_Gateway\Blocks as Payment_Gateway_Blocks; use SkyVerge\WooCommerce\PluginFramework\v5_13_1\Payment_Gateway\External_Checkout\Admin; use SkyVerge\WooCommerce\PluginFramework\v5_13_1\Payment_Gateway\External_Checkout\External_Checkout; @@ -13,7 +15,9 @@ use SkyVerge\WooCommerce\PluginFramework\v5_13_1\Payment_Gateway\External_Checkout\Google_Pay as Google_Pay_Checkout; use SkyVerge\WooCommerce\PluginFramework\v5_13_1\Payment_Gateway\External_Checkout\Orders; use SkyVerge\WooCommerce\PluginFramework\v5_13_1\Payment_Gateway\Handlers as Handlers; +use SkyVerge\WooCommerce\PluginFramework\v5_13_1\Payment_Gateway\PaymentFormContextChecker; use SkyVerge\WooCommerce\PluginFramework\v5_13_1\Settings_API as Settings_API; +use SkyVerge\WooCommerce\PluginFramework\v5_13_1\SV_WC_Plugin; use SkyVerge\WooCommerce\PluginFramework\v5_13_1\Tests\TestCase; /** @@ -54,4 +58,30 @@ public function testCanAutoload() : void $this->assertInstanceOf($className, Mockery::mock($className)->makePartial()); } } + + /** + * @covers \SkyVerge\WooCommerce\PluginFramework\v5_13_1\SV_WC_Plugin::setupClassAliases() + * + * @throws ReflectionException + */ + public function testClassAliases() : void + { + $aliases = [ + Country_Helper::class => '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\Country_Helper', + PaymentFormContextChecker::class => '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\PaymentFormContextChecker', + ]; + + foreach ($aliases as $alias) { + $this->assertFalse(class_exists($alias)); + } + + $this->invokeInaccessibleMethod( + Mockery::mock(SV_WC_Plugin::class)->makePartial(), + 'setupClassAliases' + ); + + foreach ($aliases as $class => $alias) { + $this->assertInstanceOf($class, Mockery::mock($alias)); + } + } } diff --git a/woocommerce/class-sv-wc-plugin.php b/woocommerce/class-sv-wc-plugin.php index 47540f931..fb555aa67 100644 --- a/woocommerce/class-sv-wc-plugin.php +++ b/woocommerce/class-sv-wc-plugin.php @@ -25,6 +25,8 @@ namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1; use Automattic\WooCommerce\Utilities\FeaturesUtil; +use SkyVerge\WooCommerce\PluginFramework\v5_13_1\Handlers\Country_Helper; +use SkyVerge\WooCommerce\PluginFramework\v5_13_1\Payment_Gateway\PaymentFormContextChecker; use stdClass; defined( 'ABSPATH' ) or exit; @@ -449,6 +451,8 @@ private function includes() { $framework_path = $this->get_framework_path(); + $this->setupClassAliases(); + // common exception class require_once( $framework_path . '/class-sv-wc-plugin-exception.php' ); @@ -487,6 +491,26 @@ private function includes() { require_once( $framework_path . '/rest-api/class-sv-wc-plugin-rest-api.php' ); } + /** + * Setup aliases for classes that got renamed, moved, or namespace changed. + * + * @since 5_13_1 + * + * @return void + */ + protected function setupClassAliases() : void + { + class_alias( + Country_Helper::class, + '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\Country_Helper' + ); + + class_alias( + PaymentFormContextChecker::class, + '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\PaymentFormContextChecker' + ); + } + /** * Gets a list of framework deprecated/removed hooks. From 9817b0a8da029ed4ef4af11f7db41842b6414a9e Mon Sep 17 00:00:00 2001 From: Nabeel Molham Date: Wed, 28 Aug 2024 16:01:19 +1000 Subject: [PATCH 34/62] Setup class mapping via composer --- composer.json | 23 +++++++++++++++++++---- tests/bootstrap.php | 4 ---- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/composer.json b/composer.json index 011e03b5e..3fe0be262 100644 --- a/composer.json +++ b/composer.json @@ -17,11 +17,26 @@ "10up/wp_mock": "^1.0" }, "autoload": { + "classmap": [ + "woocommerce/admin", + "woocommerce/api", + "woocommerce/compatibility", + "woocommerce/payment-gateway", + "woocommerce/rest-api", + "woocommerce/utilities", + "woocommerce/class-sv-wc-admin-notice-handler.php", + "woocommerce/class-sv-wc-framework-bootstrap.php", + "woocommerce/class-sv-wc-helper.php", + "woocommerce/class-sv-wc-hook-deprecator.php", + "woocommerce/class-sv-wc-plugin.php", + "woocommerce/class-sv-wc-plugin-compatibility.php", + "woocommerce/class-sv-wc-plugin-dependencies.php", + "woocommerce/class-sv-wc-plugin-exception.php", + "woocommerce/class-sv-wp-admin-message-handler.php", + "woocommerce/Lifecycle.php" + ], "psr-4": { - "SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\": "woocommerce/", - "SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\Admin\\": "woocommerce/admin/", - "SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\Payment_Gateway\\": "woocommerce/payment-gateway/", - "SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\API\\": "woocommerce/api/" + "SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\": "woocommerce/" } }, "autoload-dev": { diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 5500f22cf..644e958a6 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -5,10 +5,6 @@ define('PLUGIN_ROOT_DIR', dirname(__DIR__)); require_once PLUGIN_ROOT_DIR.'/vendor/autoload.php'; -require_once PLUGIN_ROOT_DIR.'/woocommerce/class-sv-wc-plugin.php'; -require_once PLUGIN_ROOT_DIR.'/woocommerce/class-sv-wc-plugin-exception.php'; WP_Mock::setUsePatchwork(true); WP_Mock::bootstrap(); - -require_once PLUGIN_ROOT_DIR.'/woocommerce/class-sv-wc-helper.php'; From 7ddac72ba5a70313dc1a4ac9a7b5cbc273fc07b1 Mon Sep 17 00:00:00 2001 From: Nabeel Molham Date: Wed, 28 Aug 2024 16:20:47 +1000 Subject: [PATCH 35/62] Remove all unnecessary class files inclusion --- woocommerce/Blocks/Blocks_Handler.php | 5 -- woocommerce/class-sv-wc-plugin.php | 56 +++-------------- .../class-sv-wc-payment-gateway-apple-pay.php | 5 -- .../class-sv-wc-payment-gateway-plugin.php | 62 ------------------- 4 files changed, 9 insertions(+), 119 deletions(-) diff --git a/woocommerce/Blocks/Blocks_Handler.php b/woocommerce/Blocks/Blocks_Handler.php index b90e13424..76e5016f0 100644 --- a/woocommerce/Blocks/Blocks_Handler.php +++ b/woocommerce/Blocks/Blocks_Handler.php @@ -50,11 +50,6 @@ public function __construct( SV_WC_Plugin $plugin ) { $this->plugin = $plugin; - $framework_path = $this->plugin->get_framework_path(); - - require_once( $framework_path . '/Blocks/Traits/Block_Integration_Trait.php' ); - require_once( $framework_path . '/Blocks/Block_Integration.php' ); - // blocks-related notices and call-to-actions add_action( 'admin_notices', [ $this, 'add_admin_notices' ] ); diff --git a/woocommerce/class-sv-wc-plugin.php b/woocommerce/class-sv-wc-plugin.php index fb555aa67..f1ac269bc 100644 --- a/woocommerce/class-sv-wc-plugin.php +++ b/woocommerce/class-sv-wc-plugin.php @@ -177,9 +177,6 @@ public function __construct( string $id, string $version, array $args = [] ) { // build the blocks handler instance $this->init_blocks_handler(); - // build the setup handler instance - $this->init_setup_wizard_handler(); - // add the action & filter hooks $this->add_hooks(); } @@ -282,8 +279,6 @@ protected function init_rest_api_handler() { */ protected function init_blocks_handler() : void { - require_once( $this->get_framework_path() . '/Blocks/Blocks_Handler.php' ); - // individual plugins should initialize their block integrations handler by overriding this method $this->blocks_handler = new Blocks\Blocks_Handler( $this ); } @@ -295,10 +290,12 @@ protected function init_blocks_handler() : void { * Plugins can override and extend this method to add their own setup wizard. * * @since 5.3.0 + * + * @deprecated */ protected function init_setup_wizard_handler() { - require_once( $this->get_framework_path() . '/admin/abstract-sv-wc-plugin-admin-setup-wizard.php' ); + // np-op } @@ -446,49 +443,12 @@ public function init_admin() { * Include any critical files which must be available as early as possible, * * @since 2.0.0 + * + * @deprecated class files are loaded via composer */ private function includes() { - $framework_path = $this->get_framework_path(); - $this->setupClassAliases(); - - // common exception class - require_once( $framework_path . '/class-sv-wc-plugin-exception.php' ); - - // common utility methods - require_once( $framework_path . '/class-sv-wc-helper.php' ); - - // backwards compatibility for older WC versions - require_once( $framework_path . '/class-sv-wc-plugin-compatibility.php' ); - require_once( $framework_path . '/compatibility/abstract-sv-wc-data-compatibility.php' ); - require_once( $framework_path . '/compatibility/class-sv-wc-order-compatibility.php' ); - require_once( $framework_path . '/compatibility/class-sv-wc-subscription-compatibility.php' ); - - // generic API base - require_once( $framework_path . '/api/class-sv-wc-api-exception.php' ); - require_once( $framework_path . '/api/class-sv-wc-api-base.php' ); - require_once( $framework_path . '/api/interface-sv-wc-api-request.php' ); - require_once( $framework_path . '/api/interface-sv-wc-api-response.php' ); - - // XML API base - require_once( $framework_path . '/api/abstract-sv-wc-api-xml-request.php' ); - require_once( $framework_path . '/api/abstract-sv-wc-api-xml-response.php' ); - - // JSON API base - require_once( $framework_path . '/api/abstract-sv-wc-api-json-request.php' ); - require_once( $framework_path . '/api/abstract-sv-wc-api-json-response.php' ); - - // REST API Controllers - require_once( $framework_path . '/rest-api/Controllers/Settings.php' ); - - // Handlers - require_once( $framework_path . '/class-sv-wc-plugin-dependencies.php' ); - require_once( $framework_path . '/class-sv-wc-hook-deprecator.php' ); - require_once( $framework_path . '/class-sv-wp-admin-message-handler.php' ); - require_once( $framework_path . '/class-sv-wc-admin-notice-handler.php' ); - require_once( $framework_path . '/Lifecycle.php' ); - require_once( $framework_path . '/rest-api/class-sv-wc-plugin-rest-api.php' ); } /** @@ -833,14 +793,16 @@ public function log( $message, $log_id = null ) { * Require and instantiate a class * * @since 4.2.0 + * + * @deprecated + * * @param string $local_path path to class file in plugin, e.g. '/includes/class-wc-foo.php' * @param string $class_name class to instantiate + * * @return object instantiated class instance */ public function load_class( $local_path, $class_name ) { - require_once( $this->get_plugin_path() . $local_path ); - return new $class_name; } diff --git a/woocommerce/payment-gateway/External_Checkout/apple-pay/class-sv-wc-payment-gateway-apple-pay.php b/woocommerce/payment-gateway/External_Checkout/apple-pay/class-sv-wc-payment-gateway-apple-pay.php index 14669170f..ac821a5f9 100755 --- a/woocommerce/payment-gateway/External_Checkout/apple-pay/class-sv-wc-payment-gateway-apple-pay.php +++ b/woocommerce/payment-gateway/External_Checkout/apple-pay/class-sv-wc-payment-gateway-apple-pay.php @@ -754,11 +754,6 @@ public function add_order_data( $order ) { public function get_api() { if ( ! $this->api instanceof SV_WC_Payment_Gateway_Apple_Pay_API ) { - - require_once( $this->get_plugin()->get_payment_gateway_framework_path() . '/External_Checkout/apple-pay/api/class-sv-wc-payment-gateway-apple-pay-api.php'); - require_once( $this->get_plugin()->get_payment_gateway_framework_path() . '/External_Checkout/apple-pay/api/class-sv-wc-payment-gateway-apple-pay-api-request.php'); - require_once( $this->get_plugin()->get_payment_gateway_framework_path() . '/External_Checkout/apple-pay/api/class-sv-wc-payment-gateway-apple-pay-api-response.php'); - $this->api = new SV_WC_Payment_Gateway_Apple_Pay_API( $this->get_processing_gateway() ); } diff --git a/woocommerce/payment-gateway/class-sv-wc-payment-gateway-plugin.php b/woocommerce/payment-gateway/class-sv-wc-payment-gateway-plugin.php index 2165d666e..69d54d4a0 100644 --- a/woocommerce/payment-gateway/class-sv-wc-payment-gateway-plugin.php +++ b/woocommerce/payment-gateway/class-sv-wc-payment-gateway-plugin.php @@ -166,8 +166,6 @@ public function __construct( $id, $version, $args ) { */ protected function init_rest_api_handler() { - require_once( $this->get_payment_gateway_framework_path() . '/rest-api/class-sv-wc-payment-gateway-plugin-rest-api.php' ); - $this->rest_api_handler = new Payment_Gateway\REST_API( $this ); } @@ -287,68 +285,8 @@ public function adjust_available_gateways( $available_gateways ) { */ private function includes() { - $payment_gateway_framework_path = $this->get_payment_gateway_framework_path(); - - // interfaces - require_once( $payment_gateway_framework_path . '/api/interface-sv-wc-payment-gateway-api.php' ); - require_once( $payment_gateway_framework_path . '/api/interface-sv-wc-payment-gateway-api-request.php' ); - require_once( $payment_gateway_framework_path . '/api/interface-sv-wc-payment-gateway-api-response.php' ); - require_once( $payment_gateway_framework_path . '/api/interface-sv-wc-payment-gateway-api-authorization-response.php' ); - require_once( $payment_gateway_framework_path . '/api/interface-sv-wc-payment-gateway-api-create-payment-token-response.php' ); - require_once( $payment_gateway_framework_path . '/api/interface-sv-wc-payment-gateway-api-get-tokenized-payment-methods-response.php' ); - require_once( $payment_gateway_framework_path . '/api/interface-sv-wc-payment-gateway-api-payment-notification-response.php' ); - require_once( $payment_gateway_framework_path . '/api/interface-sv-wc-payment-gateway-api-payment-notification-credit-card-response.php' ); - require_once( $payment_gateway_framework_path . '/api/interface-sv-wc-payment-gateway-api-payment-notification-echeck-response.php' ); - require_once( $payment_gateway_framework_path . '/api/interface-sv-wc-payment-gateway-api-payment-notification-tokenization-response.php' ); - require_once( $payment_gateway_framework_path . '/api/interface-sv-wc-payment-gateway-api-customer-response.php' ); - - // exceptions - require_once( $payment_gateway_framework_path . '/exceptions/class-sv-wc-payment-gateway-exception.php' ); - - // gateway - require_once( $payment_gateway_framework_path . '/class-sv-wc-payment-gateway.php' ); - require_once( $payment_gateway_framework_path . '/class-sv-wc-payment-gateway-direct.php' ); - require_once( $payment_gateway_framework_path . '/class-sv-wc-payment-gateway-hosted.php' ); - require_once( $payment_gateway_framework_path . '/class-sv-wc-payment-gateway-payment-form.php' ); - require_once( $payment_gateway_framework_path . '/class-sv-wc-payment-gateway-my-payment-methods.php' ); - - // Apple Pay - require_once( "{$payment_gateway_framework_path}/External_Checkout/apple-pay/class-sv-wc-payment-gateway-apple-pay.php" ); - require_once( "{$payment_gateway_framework_path}/External_Checkout/apple-pay/class-sv-wc-payment-gateway-apple-pay-admin.php" ); - require_once( "{$payment_gateway_framework_path}/External_Checkout/apple-pay/class-sv-wc-payment-gateway-apple-pay-frontend.php" ); - require_once( "{$payment_gateway_framework_path}/External_Checkout/apple-pay/class-sv-wc-payment-gateway-apple-pay-ajax.php" ); - require_once( "{$payment_gateway_framework_path}/External_Checkout/apple-pay/api/class-sv-wc-payment-gateway-apple-pay-payment-response.php" ); - - // payment tokens - require_once( $payment_gateway_framework_path . '/payment-tokens/class-sv-wc-payment-gateway-payment-token.php' ); - require_once( $payment_gateway_framework_path . '/payment-tokens/class-sv-wc-payment-gateway-payment-tokens-handler.php' ); - - // helpers - require_once( $payment_gateway_framework_path . '/api/class-sv-wc-payment-gateway-api-response-message-helper.php' ); - require_once( $payment_gateway_framework_path . '/class-sv-wc-payment-gateway-helper.php' ); - require_once $payment_gateway_framework_path . '/PaymentFormContextChecker.php'; - - // admin - require_once( $payment_gateway_framework_path . '/admin/class-sv-wc-payment-gateway-admin-order.php' ); - require_once( $payment_gateway_framework_path . '/admin/class-sv-wc-payment-gateway-admin-user-handler.php' ); - require_once( $payment_gateway_framework_path . '/admin/class-sv-wc-payment-gateway-admin-payment-token-editor.php' ); - - // integrations - require_once( $payment_gateway_framework_path . '/integrations/abstract-sv-wc-payment-gateway-integration.php' ); - - // subscriptions - if ( $this->is_subscriptions_active() ) { - require_once( $payment_gateway_framework_path . '/integrations/class-sv-wc-payment-gateway-integration-subscriptions.php' ); - } - - // pre-orders - if ( $this->is_pre_orders_active() ) { - require_once( $payment_gateway_framework_path . '/integrations/class-sv-wc-payment-gateway-integration-pre-orders.php' ); - } - // privacy if ( SV_WC_Plugin_Compatibility::is_wc_version_gte( '3.4' ) ) { - require_once( "{$payment_gateway_framework_path}/class-sv-wc-payment-gateway-privacy.php" ); $this->privacy_handler = new SV_WC_Payment_Gateway_Privacy( $this ); } } From b35d742576648eb3f0a3f977bc74e0fe4d14cff3 Mon Sep 17 00:00:00 2001 From: Nabeel Molham Date: Wed, 28 Aug 2024 16:21:17 +1000 Subject: [PATCH 36/62] Test for samples of non-PSR4 classes --- tests/unit/AutoloadingTest.php | 35 +++++++++++++++++++++++++++------- 1 file changed, 28 insertions(+), 7 deletions(-) diff --git a/tests/unit/AutoloadingTest.php b/tests/unit/AutoloadingTest.php index 19d7b119a..590c5ea93 100644 --- a/tests/unit/AutoloadingTest.php +++ b/tests/unit/AutoloadingTest.php @@ -4,7 +4,7 @@ use Mockery; use ReflectionException; -use SkyVerge\WooCommerce\PluginFramework\v5_13_1\Addresses as Addresses; +use SkyVerge\WooCommerce\PluginFramework\v5_13_1\Addresses; use SkyVerge\WooCommerce\PluginFramework\v5_13_1\Admin\Notes_Helper; use SkyVerge\WooCommerce\PluginFramework\v5_13_1\API\Abstract_Cacheable_API_Base; use SkyVerge\WooCommerce\PluginFramework\v5_13_1\Handlers\Country_Helper; @@ -14,10 +14,20 @@ use SkyVerge\WooCommerce\PluginFramework\v5_13_1\Payment_Gateway\External_Checkout\Frontend; use SkyVerge\WooCommerce\PluginFramework\v5_13_1\Payment_Gateway\External_Checkout\Google_Pay as Google_Pay_Checkout; use SkyVerge\WooCommerce\PluginFramework\v5_13_1\Payment_Gateway\External_Checkout\Orders; -use SkyVerge\WooCommerce\PluginFramework\v5_13_1\Payment_Gateway\Handlers as Handlers; +use SkyVerge\WooCommerce\PluginFramework\v5_13_1\Payment_Gateway\Handlers; use SkyVerge\WooCommerce\PluginFramework\v5_13_1\Payment_Gateway\PaymentFormContextChecker; -use SkyVerge\WooCommerce\PluginFramework\v5_13_1\Settings_API as Settings_API; +use SkyVerge\WooCommerce\PluginFramework\v5_13_1\REST_API; +use SkyVerge\WooCommerce\PluginFramework\v5_13_1\Settings_API; +use SkyVerge\WooCommerce\PluginFramework\v5_13_1\SV_WC_Admin_Notice_Handler; +use SkyVerge\WooCommerce\PluginFramework\v5_13_1\SV_WC_Payment_Gateway_Admin_Payment_Token_Editor; +use SkyVerge\WooCommerce\PluginFramework\v5_13_1\SV_WC_Payment_Gateway_API_Authorization_Response; +use SkyVerge\WooCommerce\PluginFramework\v5_13_1\SV_WC_Payment_Gateway_Apple_Pay_AJAX; +use SkyVerge\WooCommerce\PluginFramework\v5_13_1\SV_WC_Payment_Gateway_Exception; +use SkyVerge\WooCommerce\PluginFramework\v5_13_1\SV_WC_Payment_Gateway_Integration_Subscriptions; +use SkyVerge\WooCommerce\PluginFramework\v5_13_1\SV_WC_Payment_Gateway_Payment_Tokens_Handler; use SkyVerge\WooCommerce\PluginFramework\v5_13_1\SV_WC_Plugin; +use SkyVerge\WooCommerce\PluginFramework\v5_13_1\SV_WP_Admin_Message_Handler; +use SkyVerge\WooCommerce\PluginFramework\v5_13_1\SV_WP_Job_Batch_Handler; use SkyVerge\WooCommerce\PluginFramework\v5_13_1\Tests\TestCase; /** @@ -27,8 +37,6 @@ class AutoloadingTest extends TestCase { public function testCanAutoload() : void { - require_once PLUGIN_ROOT_DIR.'/woocommerce/api/class-sv-wc-api-base.php'; - $list = [ Handlers\Capture::class, Handlers\Abstract_Payment_Handler::class, @@ -50,8 +58,21 @@ public function testCanAutoload() : void Notes_Helper::class, Addresses\Address::class, Addresses\Customer_Address::class, + SV_WC_Payment_Gateway_API_Authorization_Response::class, + SV_WC_Payment_Gateway_Admin_Payment_Token_Editor::class, + SV_WC_Payment_Gateway_Exception::class, + SV_WC_Payment_Gateway_Apple_Pay_AJAX::class, + SV_WC_Payment_Gateway_Integration_Subscriptions::class, + SV_WC_Payment_Gateway_Payment_Tokens_Handler::class, + \SkyVerge\WooCommerce\PluginFramework\v5_13_1\Payment_Gateway\REST_API::class, + REST_API::class, + REST_API\Controllers\Settings::class, + SV_WP_Job_Batch_Handler::class, + SV_WC_Admin_Notice_Handler::class, + SV_WP_Admin_Message_Handler::class, ]; + Mockery::mock('\WP_REST_Controller'); Mockery::mock('\Automattic\WooCommerce\Blocks\Payments\Integrations\AbstractPaymentMethodType'); foreach ($list as $className) { @@ -67,8 +88,8 @@ public function testCanAutoload() : void public function testClassAliases() : void { $aliases = [ - Country_Helper::class => '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\Country_Helper', - PaymentFormContextChecker::class => '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\PaymentFormContextChecker', + Country_Helper::class => \SkyVerge\WooCommerce\PluginFramework\v5_13_1\Country_Helper::class, + PaymentFormContextChecker::class => \SkyVerge\WooCommerce\PluginFramework\v5_13_1\PaymentFormContextChecker::class, ]; foreach ($aliases as $alias) { From 7ee0cd61da72687a9d20e099a324fce3c21a06b5 Mon Sep 17 00:00:00 2001 From: Nabeel Molham Date: Wed, 28 Aug 2024 16:29:46 +1000 Subject: [PATCH 37/62] restore load_class method --- woocommerce/class-sv-wc-plugin.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/woocommerce/class-sv-wc-plugin.php b/woocommerce/class-sv-wc-plugin.php index f1ac269bc..b9b76a7d1 100644 --- a/woocommerce/class-sv-wc-plugin.php +++ b/woocommerce/class-sv-wc-plugin.php @@ -793,16 +793,14 @@ public function log( $message, $log_id = null ) { * Require and instantiate a class * * @since 4.2.0 - * - * @deprecated - * * @param string $local_path path to class file in plugin, e.g. '/includes/class-wc-foo.php' * @param string $class_name class to instantiate - * * @return object instantiated class instance */ public function load_class( $local_path, $class_name ) { + require_once( $this->get_plugin_path() . $local_path ); + return new $class_name; } From 5728a3d7801539631cb0cb060213fa83d5fe83c9 Mon Sep 17 00:00:00 2001 From: Ashley Gibson Date: Wed, 28 Aug 2024 10:30:07 +0100 Subject: [PATCH 38/62] Version number formatting. --- woocommerce/class-sv-wc-plugin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/woocommerce/class-sv-wc-plugin.php b/woocommerce/class-sv-wc-plugin.php index b9b76a7d1..21a42da20 100644 --- a/woocommerce/class-sv-wc-plugin.php +++ b/woocommerce/class-sv-wc-plugin.php @@ -454,7 +454,7 @@ private function includes() { /** * Setup aliases for classes that got renamed, moved, or namespace changed. * - * @since 5_13_1 + * @since 5.13.1 * * @return void */ From 67e69bc4e6ead2c22e8d424fb7291f9c6fc56715 Mon Sep 17 00:00:00 2001 From: Nabeel Molham Date: Thu, 29 Aug 2024 12:38:30 +1000 Subject: [PATCH 39/62] Autoload testing with class_exists and/or interface_exists --- tests/unit/AutoloadingTest.php | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/tests/unit/AutoloadingTest.php b/tests/unit/AutoloadingTest.php index 590c5ea93..692243934 100644 --- a/tests/unit/AutoloadingTest.php +++ b/tests/unit/AutoloadingTest.php @@ -2,6 +2,7 @@ namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1\Tests\Unit; +use Generator; use Mockery; use ReflectionException; use SkyVerge\WooCommerce\PluginFramework\v5_13_1\Addresses; @@ -21,8 +22,11 @@ use SkyVerge\WooCommerce\PluginFramework\v5_13_1\SV_WC_Admin_Notice_Handler; use SkyVerge\WooCommerce\PluginFramework\v5_13_1\SV_WC_Payment_Gateway_Admin_Payment_Token_Editor; use SkyVerge\WooCommerce\PluginFramework\v5_13_1\SV_WC_Payment_Gateway_API_Authorization_Response; +use SkyVerge\WooCommerce\PluginFramework\v5_13_1\SV_WC_Payment_Gateway_API_Get_Tokenized_Payment_Methods_Response; +use SkyVerge\WooCommerce\PluginFramework\v5_13_1\SV_WC_Payment_Gateway_API_Response; use SkyVerge\WooCommerce\PluginFramework\v5_13_1\SV_WC_Payment_Gateway_Apple_Pay_AJAX; use SkyVerge\WooCommerce\PluginFramework\v5_13_1\SV_WC_Payment_Gateway_Exception; +use SkyVerge\WooCommerce\PluginFramework\v5_13_1\SV_WC_Payment_Gateway_Integration; use SkyVerge\WooCommerce\PluginFramework\v5_13_1\SV_WC_Payment_Gateway_Integration_Subscriptions; use SkyVerge\WooCommerce\PluginFramework\v5_13_1\SV_WC_Payment_Gateway_Payment_Tokens_Handler; use SkyVerge\WooCommerce\PluginFramework\v5_13_1\SV_WC_Plugin; @@ -35,7 +39,19 @@ */ class AutoloadingTest extends TestCase { - public function testCanAutoload() : void + /** + * @dataProvider providerCanAutoload + */ + public function testCanAutoload(string $className) : void + { + Mockery::mock('\WP_REST_Controller'); + Mockery::mock('\Automattic\WooCommerce\Blocks\Payments\Integrations\AbstractPaymentMethodType'); + + $this->assertTrue(class_exists($className) || interface_exists($className)); + } + + /** @see testCanAutoload */ + public function providerCanAutoload() : Generator { $list = [ Handlers\Capture::class, @@ -59,11 +75,14 @@ public function testCanAutoload() : void Addresses\Address::class, Addresses\Customer_Address::class, SV_WC_Payment_Gateway_API_Authorization_Response::class, + SV_WC_Payment_Gateway_API_Get_Tokenized_Payment_Methods_Response::class, + SV_WC_Payment_Gateway_API_Response::class, SV_WC_Payment_Gateway_Admin_Payment_Token_Editor::class, SV_WC_Payment_Gateway_Exception::class, SV_WC_Payment_Gateway_Apple_Pay_AJAX::class, SV_WC_Payment_Gateway_Integration_Subscriptions::class, SV_WC_Payment_Gateway_Payment_Tokens_Handler::class, + SV_WC_Payment_Gateway_Integration::class, \SkyVerge\WooCommerce\PluginFramework\v5_13_1\Payment_Gateway\REST_API::class, REST_API::class, REST_API\Controllers\Settings::class, @@ -72,11 +91,8 @@ public function testCanAutoload() : void SV_WP_Admin_Message_Handler::class, ]; - Mockery::mock('\WP_REST_Controller'); - Mockery::mock('\Automattic\WooCommerce\Blocks\Payments\Integrations\AbstractPaymentMethodType'); - foreach ($list as $className) { - $this->assertInstanceOf($className, Mockery::mock($className)->makePartial()); + yield $className => [$className]; } } From 146dc3bf6c09991ffa077dc198b62eff79b420fc Mon Sep 17 00:00:00 2001 From: Nabeel Molham Date: Thu, 29 Aug 2024 12:45:40 +1000 Subject: [PATCH 40/62] Bump version to 5.14.0 --- composer.json | 2 +- tests/TestCase.php | 2 +- .../gateway-test-plugin.php | 2 +- .../gateway-test-plugin/includes/API.php | 2 +- .../gateway-test-plugin/includes/Gateway.php | 2 +- .../gateway-test-plugin/includes/Plugin.php | 2 +- .../plugins/test-plugin/includes/API.php | 2 +- .../plugins/test-plugin/includes/Gateway.php | 2 +- .../plugins/test-plugin/includes/Plugin.php | 2 +- .../plugins/test-plugin/test-plugin.php | 2 +- .../integration/API/CacheableAPIBaseTest.php | 10 +++---- tests/integration/DependenciesTest.php | 6 ++-- tests/integration/HelperTest.php | 4 +-- tests/integration/PluginTest.php | 6 ++-- .../REST_API/Controllers/SettingsTest.php | 10 +++---- tests/integration/REST_API/RESTAPITest.php | 8 +++--- .../SV_WC_Payment_Gateway_Helper_Test.php | 4 +-- .../Settings_API/AbstractSettingsTest.php | 12 ++++---- .../integration/Settings_API/SettingTest.php | 4 +-- .../payment-gateway/GatewayPluginTest.php | 2 +- .../payment-gateway/MyPaymentMethodsTest.php | 8 +++--- .../payment-gateway/PaymentFormTest.php | 6 ++-- ..._WC_Payment_Gateway_Payment_Token_Test.php | 4 +-- ...nt_Gateway_Payment_Tokens_Handler_Test.php | 4 +-- .../apple-pay/ApplePayFrontendTest.php | 10 +++---- tests/unit/API/CacheableRequestTraitTest.php | 20 ++++++------- tests/unit/CountryHelperTest.php | 8 +++--- tests/unit/Helpers/ArrayHelperTest.php | 8 +++--- tests/unit/PaymentFormContextCheckerTest.php | 20 ++++++------- tests/unit/Settings_API/ControlTest.php | 28 +++++++++---------- tests/unit/Settings_API/SettingTest.php | 26 ++++++++--------- .../Traits/CanConvertToArrayTraitTest.php | 16 +++++------ .../Traits/CanGetNewInstanceTraitTest.php | 10 +++---- tests/unit/Traits/IsSingletonTraitTest.php | 12 ++++---- ...ommerce-framework-plugin-loader-sample.php | 2 +- woocommerce/Addresses/Address.php | 4 +-- woocommerce/Addresses/Customer_Address.php | 4 +-- woocommerce/Blocks/Block_Integration.php | 10 +++---- woocommerce/Blocks/Blocks_Handler.php | 10 +++---- .../Blocks/Traits/Block_Integration_Trait.php | 16 +++++------ woocommerce/Country_Helper.php | 4 +-- woocommerce/Enums/PaymentFormContext.php | 4 +-- woocommerce/Enums/Traits/EnumTrait.php | 2 +- woocommerce/Handlers/Script_Handler.php | 10 +++---- woocommerce/Helpers/ArrayHelper.php | 2 +- woocommerce/Lifecycle.php | 12 ++++---- .../Settings_API/Abstract_Settings.php | 6 ++-- woocommerce/Settings_API/Control.php | 6 ++-- woocommerce/Settings_API/Setting.php | 6 ++-- woocommerce/Traits/CanConvertToArrayTrait.php | 4 +-- woocommerce/Traits/CanGetNewInstanceTrait.php | 4 +-- woocommerce/Traits/IsSingletonTrait.php | 4 +-- woocommerce/admin/Notes_Helper.php | 4 +-- ...stract-sv-wc-plugin-admin-setup-wizard.php | 6 ++-- .../api/Abstract_Cacheable_API_Base.php | 8 +++--- .../api/abstract-sv-wc-api-json-request.php | 4 +-- .../api/abstract-sv-wc-api-json-response.php | 4 +-- .../api/abstract-sv-wc-api-xml-request.php | 4 +-- .../api/abstract-sv-wc-api-xml-response.php | 4 +-- woocommerce/api/class-sv-wc-api-base.php | 4 +-- woocommerce/api/class-sv-wc-api-exception.php | 4 +-- .../api/interface-sv-wc-api-request.php | 4 +-- .../api/interface-sv-wc-api-response.php | 4 +-- .../api/traits/Cacheable_Request_Trait.php | 4 +-- woocommerce/changelog.txt | 2 +- .../class-sv-wc-admin-notice-handler.php | 4 +-- woocommerce/class-sv-wc-helper.php | 4 +-- woocommerce/class-sv-wc-hook-deprecator.php | 4 +-- .../class-sv-wc-plugin-compatibility.php | 4 +-- .../class-sv-wc-plugin-dependencies.php | 4 +-- woocommerce/class-sv-wc-plugin-exception.php | 4 +-- woocommerce/class-sv-wc-plugin.php | 6 ++-- .../class-sv-wp-admin-message-handler.php | 4 +-- .../abstract-sv-wc-data-compatibility.php | 4 +-- .../class-sv-wc-order-compatibility.php | 4 +-- ...class-sv-wc-subscription-compatibility.php | 4 +-- .../Blocks/Gateway_Blocks_Handler.php | 8 +++--- .../Gateway_Checkout_Block_Integration.php | 16 +++++------ .../External_Checkout/Admin.php | 4 +-- .../External_Checkout/External_Checkout.php | 6 ++-- .../External_Checkout/Frontend.php | 16 +++++------ .../External_Checkout/Google_Pay/AJAX.php | 8 +++--- .../External_Checkout/Google_Pay/Admin.php | 8 +++--- .../External_Checkout/Google_Pay/Frontend.php | 12 ++++---- .../Google_Pay/Google_Pay.php | 16 +++++------ .../External_Checkout/Orders.php | 4 +-- ...-payment-gateway-apple-pay-api-request.php | 4 +-- ...payment-gateway-apple-pay-api-response.php | 4 +-- ...ss-sv-wc-payment-gateway-apple-pay-api.php | 6 ++-- ...ent-gateway-apple-pay-payment-response.php | 4 +-- ...-sv-wc-payment-gateway-apple-pay-admin.php | 6 ++-- ...s-sv-wc-payment-gateway-apple-pay-ajax.php | 4 +-- ...-wc-payment-gateway-apple-pay-frontend.php | 10 +++---- .../class-sv-wc-payment-gateway-apple-pay.php | 8 +++--- .../Abstract_Hosted_Payment_Handler.php | 6 ++-- .../Handlers/Abstract_Payment_Handler.php | 6 ++-- .../payment-gateway/Handlers/Capture.php | 6 ++-- .../PaymentFormContextChecker.php | 4 +-- ...ment-gateway-plugin-admin-setup-wizard.php | 6 ++-- ...lass-sv-wc-payment-gateway-admin-order.php | 4 +-- ...ent-gateway-admin-payment-token-editor.php | 4 +-- ...-wc-payment-gateway-admin-user-handler.php | 4 +-- ...nt-gateway-api-response-message-helper.php | 4 +-- ...ent-gateway-api-authorization-response.php | 4 +-- ...eway-api-create-payment-token-response.php | 4 +-- ...-payment-gateway-api-customer-response.php | 4 +-- ...get-tokenized-payment-methods-response.php | 4 +-- ...ment-notification-credit-card-response.php | 4 +-- ...i-payment-notification-echeck-response.php | 4 +-- ...eway-api-payment-notification-response.php | 4 +-- ...ent-notification-tokenization-response.php | 4 +-- ...face-sv-wc-payment-gateway-api-request.php | 4 +-- ...ace-sv-wc-payment-gateway-api-response.php | 4 +-- .../interface-sv-wc-payment-gateway-api.php | 4 +-- .../sv-wc-payment-gateway-apple-pay.js | 2 +- .../sv-wc-payment-gateway-apple-pay.js.map | 2 +- .../sv-wc-payment-gateway-google-pay.js | 2 +- .../sv-wc-payment-gateway-google-pay.js.map | 2 +- ...v-wc-payment-gateway-my-payment-methods.js | 2 +- ...-payment-gateway-my-payment-methods.js.map | 2 +- .../sv-wc-payment-gateway-payment-form.js | 2 +- .../sv-wc-payment-gateway-payment-form.js.map | 2 +- .../sv-wc-payment-gateway-apple-pay.coffee | 4 +-- .../sv-wc-payment-gateway-google-pay.js | 6 ++-- ...-payment-gateway-my-payment-methods.coffee | 4 +-- .../sv-wc-payment-gateway-payment-form.coffee | 6 ++-- .../class-sv-wc-payment-gateway-direct.php | 6 ++-- .../class-sv-wc-payment-gateway-helper.php | 4 +-- .../class-sv-wc-payment-gateway-hosted.php | 4 +-- ...-wc-payment-gateway-my-payment-methods.php | 8 +++--- ...ass-sv-wc-payment-gateway-payment-form.php | 12 ++++---- .../class-sv-wc-payment-gateway-plugin.php | 8 +++--- .../class-sv-wc-payment-gateway-privacy.php | 4 +-- .../class-sv-wc-payment-gateway.php | 10 +++---- .../class-sv-wc-payment-gateway-exception.php | 4 +-- ...ract-sv-wc-payment-gateway-integration.php | 4 +-- ...payment-gateway-integration-pre-orders.php | 4 +-- ...ment-gateway-integration-subscriptions.php | 4 +-- ...ss-sv-wc-payment-gateway-payment-token.php | 4 +-- ...payment-gateway-payment-tokens-handler.php | 4 +-- ...-sv-wc-payment-gateway-plugin-rest-api.php | 10 +++---- woocommerce/rest-api/Controllers/Settings.php | 8 +++--- .../rest-api/class-sv-wc-plugin-rest-api.php | 4 +-- .../utilities/class-sv-wp-async-request.php | 4 +-- .../class-sv-wp-background-job-handler.php | 4 +-- .../class-sv-wp-job-batch-handler.php | 4 +-- 146 files changed, 430 insertions(+), 430 deletions(-) diff --git a/composer.json b/composer.json index aa02aab74..a6dc83e21 100644 --- a/composer.json +++ b/composer.json @@ -18,7 +18,7 @@ }, "autoload-dev": { "psr-4": { - "SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\Tests\\": "tests/" + "SkyVerge\\WooCommerce\\PluginFramework\\v5_14_0\\Tests\\": "tests/" } }, "config": { diff --git a/tests/TestCase.php b/tests/TestCase.php index cd192f805..5d32915b4 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -1,6 +1,6 @@ assertInstanceOf( '\SkyVerge\WooCommerce\PluginFramework\v5_13_1\SV_WC_Plugin_Dependencies', $this->get_plugin()->get_dependency_handler() ); + $this->assertInstanceOf( '\SkyVerge\WooCommerce\PluginFramework\v5_14_0\SV_WC_Plugin_Dependencies', $this->get_plugin()->get_dependency_handler() ); } @@ -161,7 +161,7 @@ public function test_get_dependency_handler() { */ public function test_get_lifecycle_handler() { - $this->assertInstanceOf( '\SkyVerge\WooCommerce\PluginFramework\v5_13_1\Plugin\Lifecycle', $this->get_plugin()->get_lifecycle_handler() ); + $this->assertInstanceOf( '\SkyVerge\WooCommerce\PluginFramework\v5_14_0\Plugin\Lifecycle', $this->get_plugin()->get_lifecycle_handler() ); } diff --git a/tests/integration/REST_API/Controllers/SettingsTest.php b/tests/integration/REST_API/Controllers/SettingsTest.php index a87f3b922..16d5d1c6a 100644 --- a/tests/integration/REST_API/Controllers/SettingsTest.php +++ b/tests/integration/REST_API/Controllers/SettingsTest.php @@ -1,14 +1,14 @@ render_js(); $this->assertStringContainsString( 'function load_gateway_test_plugin_payment_methods_handler', $wc_queued_js ); - $this->assertStringContainsString( 'window.jQuery( document.body ).on( \'sv_wc_payment_methods_handler_v5_13_1_loaded\', load_gateway_test_plugin_payment_methods_handler );', $wc_queued_js ); + $this->assertStringContainsString( 'window.jQuery( document.body ).on( \'sv_wc_payment_methods_handler_v5_14_0_loaded\', load_gateway_test_plugin_payment_methods_handler );', $wc_queued_js ); } diff --git a/tests/integration/payment-gateway/PaymentFormTest.php b/tests/integration/payment-gateway/PaymentFormTest.php index 223fa6943..12662f7c6 100644 --- a/tests/integration/payment-gateway/PaymentFormTest.php +++ b/tests/integration/payment-gateway/PaymentFormTest.php @@ -1,11 +1,11 @@ get_plugin()->get_gateway()->get_payment_form_instance()->render_js(); $this->assertStringContainsString( 'function load_test_gateway_payment_form_handler', $wc_queued_js ); - $this->assertStringContainsString( 'window.jQuery( document.body ).on( \'sv_wc_payment_form_handler_v5_13_1_loaded\', load_test_gateway_payment_form_handler );', $wc_queued_js ); + $this->assertStringContainsString( 'window.jQuery( document.body ).on( \'sv_wc_payment_form_handler_v5_14_0_loaded\', load_test_gateway_payment_form_handler );', $wc_queued_js ); } diff --git a/tests/integration/payment-gateway/SV_WC_Payment_Gateway_Payment_Token_Test.php b/tests/integration/payment-gateway/SV_WC_Payment_Gateway_Payment_Token_Test.php index aa7b25ee9..46c72e142 100644 --- a/tests/integration/payment-gateway/SV_WC_Payment_Gateway_Payment_Token_Test.php +++ b/tests/integration/payment-gateway/SV_WC_Payment_Gateway_Payment_Token_Test.php @@ -1,11 +1,11 @@ invokeArgs( $frontend_instance, [[]] ); $this->assertStringContainsString( 'function load_test_gateway_apple_pay_handler', $wc_queued_js ); - $this->assertStringContainsString( 'window.jQuery( document.body ).on( \'sv_wc_apple_pay_handler_v5_13_1_loaded\', load_test_gateway_apple_pay_handler );', $wc_queued_js ); + $this->assertStringContainsString( 'window.jQuery( document.body ).on( \'sv_wc_apple_pay_handler_v5_14_0_loaded\', load_test_gateway_apple_pay_handler );', $wc_queued_js ); } diff --git a/tests/unit/API/CacheableRequestTraitTest.php b/tests/unit/API/CacheableRequestTraitTest.php index 239886745..6bdbc7a82 100644 --- a/tests/unit/API/CacheableRequestTraitTest.php +++ b/tests/unit/API/CacheableRequestTraitTest.php @@ -1,9 +1,9 @@ js_handler_base_class_name ); + return sprintf( '%s_v5_14_0', $this->js_handler_base_class_name ); } diff --git a/woocommerce/Helpers/ArrayHelper.php b/woocommerce/Helpers/ArrayHelper.php index 464d5188a..2c66658ef 100644 --- a/woocommerce/Helpers/ArrayHelper.php +++ b/woocommerce/Helpers/ArrayHelper.php @@ -22,7 +22,7 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 */ -namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1\Helpers; +namespace SkyVerge\WooCommerce\PluginFramework\v5_14_0\Helpers; use ArrayAccess; diff --git a/woocommerce/Lifecycle.php b/woocommerce/Lifecycle.php index 99c97713a..f7e9939de 100644 --- a/woocommerce/Lifecycle.php +++ b/woocommerce/Lifecycle.php @@ -22,16 +22,16 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 */ -namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1\Plugin; +namespace SkyVerge\WooCommerce\PluginFramework\v5_14_0\Plugin; -use SkyVerge\WooCommerce\PluginFramework\v5_13_1\Admin\Notes_Helper; -use SkyVerge\WooCommerce\PluginFramework\v5_13_1\SV_WC_Payment_Gateway_Plugin; -use SkyVerge\WooCommerce\PluginFramework\v5_13_1\SV_WC_Plugin; -use SkyVerge\WooCommerce\PluginFramework\v5_13_1\SV_WC_Plugin_Compatibility; +use SkyVerge\WooCommerce\PluginFramework\v5_14_0\Admin\Notes_Helper; +use SkyVerge\WooCommerce\PluginFramework\v5_14_0\SV_WC_Payment_Gateway_Plugin; +use SkyVerge\WooCommerce\PluginFramework\v5_14_0\SV_WC_Plugin; +use SkyVerge\WooCommerce\PluginFramework\v5_14_0\SV_WC_Plugin_Compatibility; defined( 'ABSPATH' ) or exit; -if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\Plugin\\Lifecycle' ) ) : +if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_14_0\\Plugin\\Lifecycle' ) ) : /** diff --git a/woocommerce/Settings_API/Abstract_Settings.php b/woocommerce/Settings_API/Abstract_Settings.php index 228c84d75..35f0666ba 100644 --- a/woocommerce/Settings_API/Abstract_Settings.php +++ b/woocommerce/Settings_API/Abstract_Settings.php @@ -22,13 +22,13 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 */ -namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1\Settings_API; +namespace SkyVerge\WooCommerce\PluginFramework\v5_14_0\Settings_API; -use SkyVerge\WooCommerce\PluginFramework\v5_13_1 as Framework; +use SkyVerge\WooCommerce\PluginFramework\v5_14_0 as Framework; defined( 'ABSPATH' ) or exit; -if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\Settings_API\\Abstract_Settings' ) ) : +if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_14_0\\Settings_API\\Abstract_Settings' ) ) : /** diff --git a/woocommerce/Settings_API/Control.php b/woocommerce/Settings_API/Control.php index 57c91dc84..6df903b30 100644 --- a/woocommerce/Settings_API/Control.php +++ b/woocommerce/Settings_API/Control.php @@ -22,13 +22,13 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 */ -namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1\Settings_API; +namespace SkyVerge\WooCommerce\PluginFramework\v5_14_0\Settings_API; -use SkyVerge\WooCommerce\PluginFramework\v5_13_1 as Framework; +use SkyVerge\WooCommerce\PluginFramework\v5_14_0 as Framework; defined( 'ABSPATH' ) or exit; -if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\Settings_API\\Control' ) ) : +if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_14_0\\Settings_API\\Control' ) ) : /** diff --git a/woocommerce/Settings_API/Setting.php b/woocommerce/Settings_API/Setting.php index 10d323d7b..48cc66429 100644 --- a/woocommerce/Settings_API/Setting.php +++ b/woocommerce/Settings_API/Setting.php @@ -22,13 +22,13 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 */ -namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1\Settings_API; +namespace SkyVerge\WooCommerce\PluginFramework\v5_14_0\Settings_API; -use SkyVerge\WooCommerce\PluginFramework\v5_13_1 as Framework; +use SkyVerge\WooCommerce\PluginFramework\v5_14_0 as Framework; defined( 'ABSPATH' ) or exit; -if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\Settings_API\\Setting' ) ) : +if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_14_0\\Settings_API\\Setting' ) ) : /** diff --git a/woocommerce/Traits/CanConvertToArrayTrait.php b/woocommerce/Traits/CanConvertToArrayTrait.php index 5773ba321..287064540 100644 --- a/woocommerce/Traits/CanConvertToArrayTrait.php +++ b/woocommerce/Traits/CanConvertToArrayTrait.php @@ -22,11 +22,11 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 */ -namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1\Traits; +namespace SkyVerge\WooCommerce\PluginFramework\v5_14_0\Traits; use ReflectionClass; use ReflectionProperty; -use SkyVerge\WooCommerce\PluginFramework\v5_13_1\Helpers\ArrayHelper; +use SkyVerge\WooCommerce\PluginFramework\v5_14_0\Helpers\ArrayHelper; /** * A trait that allows a given class/object to convert its state to an array. diff --git a/woocommerce/Traits/CanGetNewInstanceTrait.php b/woocommerce/Traits/CanGetNewInstanceTrait.php index 3e15592b8..2fcf21be9 100644 --- a/woocommerce/Traits/CanGetNewInstanceTrait.php +++ b/woocommerce/Traits/CanGetNewInstanceTrait.php @@ -22,11 +22,11 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 */ -namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1\Traits; +namespace SkyVerge\WooCommerce\PluginFramework\v5_14_0\Traits; defined('ABSPATH') or exit; -if (trait_exists('\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\Traits\\CanGetNewInstanceTrait')) { +if (trait_exists('\\SkyVerge\\WooCommerce\\PluginFramework\\v5_14_0\\Traits\\CanGetNewInstanceTrait')) { return; } diff --git a/woocommerce/Traits/IsSingletonTrait.php b/woocommerce/Traits/IsSingletonTrait.php index 447360998..7c775da35 100644 --- a/woocommerce/Traits/IsSingletonTrait.php +++ b/woocommerce/Traits/IsSingletonTrait.php @@ -22,11 +22,11 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 */ -namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1\Traits; +namespace SkyVerge\WooCommerce\PluginFramework\v5_14_0\Traits; defined('ABSPATH') or exit; -if (trait_exists('\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\Traits\\IsSingletonTrait')) { +if (trait_exists('\\SkyVerge\\WooCommerce\\PluginFramework\\v5_14_0\\Traits\\IsSingletonTrait')) { return; } diff --git a/woocommerce/admin/Notes_Helper.php b/woocommerce/admin/Notes_Helper.php index d9fdaf6fb..dc0f68985 100644 --- a/woocommerce/admin/Notes_Helper.php +++ b/woocommerce/admin/Notes_Helper.php @@ -21,13 +21,13 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 */ -namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1\Admin; +namespace SkyVerge\WooCommerce\PluginFramework\v5_14_0\Admin; use Automattic\WooCommerce\Admin\Notes as WooCommerce_Admin_Notes; defined( 'ABSPATH' ) or exit; -if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\Admin\\Notes_Helper' ) ) : +if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_14_0\\Admin\\Notes_Helper' ) ) : /** diff --git a/woocommerce/admin/abstract-sv-wc-plugin-admin-setup-wizard.php b/woocommerce/admin/abstract-sv-wc-plugin-admin-setup-wizard.php index 709f264ff..2764ba8a2 100644 --- a/woocommerce/admin/abstract-sv-wc-plugin-admin-setup-wizard.php +++ b/woocommerce/admin/abstract-sv-wc-plugin-admin-setup-wizard.php @@ -21,13 +21,13 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 */ -namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1\Admin; +namespace SkyVerge\WooCommerce\PluginFramework\v5_14_0\Admin; defined( 'ABSPATH' ) or exit; -use SkyVerge\WooCommerce\PluginFramework\v5_13_1 as Framework; +use SkyVerge\WooCommerce\PluginFramework\v5_14_0 as Framework; -if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\Admin\\Setup_Wizard' ) ) : +if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_14_0\\Admin\\Setup_Wizard' ) ) : /** diff --git a/woocommerce/api/Abstract_Cacheable_API_Base.php b/woocommerce/api/Abstract_Cacheable_API_Base.php index 7ced9d506..dad7ddb76 100644 --- a/woocommerce/api/Abstract_Cacheable_API_Base.php +++ b/woocommerce/api/Abstract_Cacheable_API_Base.php @@ -22,14 +22,14 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 */ -namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1\API; +namespace SkyVerge\WooCommerce\PluginFramework\v5_14_0\API; -use SkyVerge\WooCommerce\PluginFramework\v5_13_1\SV_WC_API_Base; -use SkyVerge\WooCommerce\PluginFramework\v5_13_1\API\Traits\Cacheable_Request_Trait; +use SkyVerge\WooCommerce\PluginFramework\v5_14_0\SV_WC_API_Base; +use SkyVerge\WooCommerce\PluginFramework\v5_14_0\API\Traits\Cacheable_Request_Trait; defined( 'ABSPATH' ) or exit; -if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\API\\Abstract_Cacheable_API_Base' ) ) : +if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_14_0\\API\\Abstract_Cacheable_API_Base' ) ) : /** diff --git a/woocommerce/api/abstract-sv-wc-api-json-request.php b/woocommerce/api/abstract-sv-wc-api-json-request.php index 3151e9916..52a16f692 100644 --- a/woocommerce/api/abstract-sv-wc-api-json-request.php +++ b/woocommerce/api/abstract-sv-wc-api-json-request.php @@ -22,11 +22,11 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 */ -namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1; +namespace SkyVerge\WooCommerce\PluginFramework\v5_14_0; defined( 'ABSPATH' ) or exit; -if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\SV_WC_API_JSON_Request' ) ) : +if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_14_0\\SV_WC_API_JSON_Request' ) ) : /** diff --git a/woocommerce/api/abstract-sv-wc-api-json-response.php b/woocommerce/api/abstract-sv-wc-api-json-response.php index 58ef9a41a..8b371eb6a 100644 --- a/woocommerce/api/abstract-sv-wc-api-json-response.php +++ b/woocommerce/api/abstract-sv-wc-api-json-response.php @@ -22,11 +22,11 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 */ -namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1; +namespace SkyVerge\WooCommerce\PluginFramework\v5_14_0; defined( 'ABSPATH' ) or exit; -if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\SV_WC_API_JSON_Response' ) ) : +if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_14_0\\SV_WC_API_JSON_Response' ) ) : /** diff --git a/woocommerce/api/abstract-sv-wc-api-xml-request.php b/woocommerce/api/abstract-sv-wc-api-xml-request.php index 973c0cec3..28819ea10 100644 --- a/woocommerce/api/abstract-sv-wc-api-xml-request.php +++ b/woocommerce/api/abstract-sv-wc-api-xml-request.php @@ -22,11 +22,11 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 */ -namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1; +namespace SkyVerge\WooCommerce\PluginFramework\v5_14_0; defined( 'ABSPATH' ) or exit; -if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\SV_WC_API_XML_Request' ) ) : +if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_14_0\\SV_WC_API_XML_Request' ) ) : /** diff --git a/woocommerce/api/abstract-sv-wc-api-xml-response.php b/woocommerce/api/abstract-sv-wc-api-xml-response.php index dde0df1f3..29843fe9e 100644 --- a/woocommerce/api/abstract-sv-wc-api-xml-response.php +++ b/woocommerce/api/abstract-sv-wc-api-xml-response.php @@ -22,11 +22,11 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 */ -namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1; +namespace SkyVerge\WooCommerce\PluginFramework\v5_14_0; defined( 'ABSPATH' ) or exit; -if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\SV_WC_API_XML_Response' ) ) : +if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_14_0\\SV_WC_API_XML_Response' ) ) : /** diff --git a/woocommerce/api/class-sv-wc-api-base.php b/woocommerce/api/class-sv-wc-api-base.php index 9acc26e2b..f077f7381 100644 --- a/woocommerce/api/class-sv-wc-api-base.php +++ b/woocommerce/api/class-sv-wc-api-base.php @@ -22,11 +22,11 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 */ -namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1; +namespace SkyVerge\WooCommerce\PluginFramework\v5_14_0; defined( 'ABSPATH' ) or exit; -if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\SV_WC_API_Base' ) ) : +if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_14_0\\SV_WC_API_Base' ) ) : /** diff --git a/woocommerce/api/class-sv-wc-api-exception.php b/woocommerce/api/class-sv-wc-api-exception.php index 0bb3bf9ab..cfd39023b 100644 --- a/woocommerce/api/class-sv-wc-api-exception.php +++ b/woocommerce/api/class-sv-wc-api-exception.php @@ -22,11 +22,11 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 */ -namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1; +namespace SkyVerge\WooCommerce\PluginFramework\v5_14_0; defined( 'ABSPATH' ) or exit; -if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\SV_WC_API_Exception' ) ) : +if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_14_0\\SV_WC_API_Exception' ) ) : /** diff --git a/woocommerce/api/interface-sv-wc-api-request.php b/woocommerce/api/interface-sv-wc-api-request.php index 77862105a..ee6e5ba72 100644 --- a/woocommerce/api/interface-sv-wc-api-request.php +++ b/woocommerce/api/interface-sv-wc-api-request.php @@ -22,11 +22,11 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 */ -namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1; +namespace SkyVerge\WooCommerce\PluginFramework\v5_14_0; defined( 'ABSPATH' ) or exit; -if ( ! interface_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\SV_WC_API_Request' ) ) : +if ( ! interface_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_14_0\\SV_WC_API_Request' ) ) : /** diff --git a/woocommerce/api/interface-sv-wc-api-response.php b/woocommerce/api/interface-sv-wc-api-response.php index 0b403fc8c..d33859017 100644 --- a/woocommerce/api/interface-sv-wc-api-response.php +++ b/woocommerce/api/interface-sv-wc-api-response.php @@ -22,11 +22,11 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 */ -namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1; +namespace SkyVerge\WooCommerce\PluginFramework\v5_14_0; defined( 'ABSPATH' ) or exit; -if ( ! interface_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\SV_WC_API_Response' ) ) : +if ( ! interface_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_14_0\\SV_WC_API_Response' ) ) : /** diff --git a/woocommerce/api/traits/Cacheable_Request_Trait.php b/woocommerce/api/traits/Cacheable_Request_Trait.php index e60126a37..856f9f5f0 100644 --- a/woocommerce/api/traits/Cacheable_Request_Trait.php +++ b/woocommerce/api/traits/Cacheable_Request_Trait.php @@ -22,11 +22,11 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 */ -namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1\API\Traits; +namespace SkyVerge\WooCommerce\PluginFramework\v5_14_0\API\Traits; defined( 'ABSPATH' ) or exit; -if ( ! trait_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\API\\Traits\\Cacheable_Request_Trait' ) ) : +if ( ! trait_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_14_0\\API\\Traits\\Cacheable_Request_Trait' ) ) : /** diff --git a/woocommerce/changelog.txt b/woocommerce/changelog.txt index 209660fe2..7f76abbbb 100644 --- a/woocommerce/changelog.txt +++ b/woocommerce/changelog.txt @@ -1,6 +1,6 @@ *** SkyVerge WooCommerce Plugin Framework Changelog *** -2024.nn.nn - version 5.13.1-dev.1 +2024.nn.nn - version 5.14.0-dev.1 * Feature - Add a trait to get a singular instance of a class: `IsSingletonTrait` * Feature - Add a trait to get an instance (non-singular) of a class: `CanGetNewInstanceTrait` * Feature - Add a trait to convert an object into an array: `CanConvertToArrayTrait` diff --git a/woocommerce/class-sv-wc-admin-notice-handler.php b/woocommerce/class-sv-wc-admin-notice-handler.php index 42633163c..036f0bf3f 100644 --- a/woocommerce/class-sv-wc-admin-notice-handler.php +++ b/woocommerce/class-sv-wc-admin-notice-handler.php @@ -22,11 +22,11 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 */ -namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1; +namespace SkyVerge\WooCommerce\PluginFramework\v5_14_0; defined( 'ABSPATH' ) or exit; -if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\SV_WC_Admin_Notice_Handler' ) ) : +if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_14_0\\SV_WC_Admin_Notice_Handler' ) ) : /** diff --git a/woocommerce/class-sv-wc-helper.php b/woocommerce/class-sv-wc-helper.php index 8d0a3a1ba..1754cfdf6 100644 --- a/woocommerce/class-sv-wc-helper.php +++ b/woocommerce/class-sv-wc-helper.php @@ -22,11 +22,11 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 */ -namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1; +namespace SkyVerge\WooCommerce\PluginFramework\v5_14_0; defined( 'ABSPATH' ) or exit; -if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\SV_WC_Helper' ) ) : +if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_14_0\\SV_WC_Helper' ) ) : /** diff --git a/woocommerce/class-sv-wc-hook-deprecator.php b/woocommerce/class-sv-wc-hook-deprecator.php index 4a4430242..e045bc417 100644 --- a/woocommerce/class-sv-wc-hook-deprecator.php +++ b/woocommerce/class-sv-wc-hook-deprecator.php @@ -22,11 +22,11 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 */ -namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1; +namespace SkyVerge\WooCommerce\PluginFramework\v5_14_0; defined( 'ABSPATH' ) or exit; -if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\SV_WC_Hook_Deprecator' ) ) : +if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_14_0\\SV_WC_Hook_Deprecator' ) ) : /** diff --git a/woocommerce/class-sv-wc-plugin-compatibility.php b/woocommerce/class-sv-wc-plugin-compatibility.php index 9391aadbe..59fa1a4f1 100644 --- a/woocommerce/class-sv-wc-plugin-compatibility.php +++ b/woocommerce/class-sv-wc-plugin-compatibility.php @@ -22,13 +22,13 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 */ -namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1; +namespace SkyVerge\WooCommerce\PluginFramework\v5_14_0; use Automattic\WooCommerce\Utilities\OrderUtil; defined( 'ABSPATH' ) or exit; -if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\SV_WC_Plugin_Compatibility' ) ) : +if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_14_0\\SV_WC_Plugin_Compatibility' ) ) : /** diff --git a/woocommerce/class-sv-wc-plugin-dependencies.php b/woocommerce/class-sv-wc-plugin-dependencies.php index fd4a0c2a0..94b028f3c 100644 --- a/woocommerce/class-sv-wc-plugin-dependencies.php +++ b/woocommerce/class-sv-wc-plugin-dependencies.php @@ -22,11 +22,11 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 */ -namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1; +namespace SkyVerge\WooCommerce\PluginFramework\v5_14_0; defined( 'ABSPATH' ) or exit; -if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\SV_WC_Plugin_Dependencies' ) ) : +if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_14_0\\SV_WC_Plugin_Dependencies' ) ) : /** diff --git a/woocommerce/class-sv-wc-plugin-exception.php b/woocommerce/class-sv-wc-plugin-exception.php index 1056115d4..52c3d31bb 100644 --- a/woocommerce/class-sv-wc-plugin-exception.php +++ b/woocommerce/class-sv-wc-plugin-exception.php @@ -22,11 +22,11 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 */ -namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1; +namespace SkyVerge\WooCommerce\PluginFramework\v5_14_0; defined( 'ABSPATH' ) or exit; -if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\SV_WC_Plugin_Exception' ) ) : +if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_14_0\\SV_WC_Plugin_Exception' ) ) : /** diff --git a/woocommerce/class-sv-wc-plugin.php b/woocommerce/class-sv-wc-plugin.php index ed2cb00f3..84601dbc6 100644 --- a/woocommerce/class-sv-wc-plugin.php +++ b/woocommerce/class-sv-wc-plugin.php @@ -22,14 +22,14 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 */ -namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1; +namespace SkyVerge\WooCommerce\PluginFramework\v5_14_0; use Automattic\WooCommerce\Utilities\FeaturesUtil; use stdClass; defined( 'ABSPATH' ) or exit; -if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\SV_WC_Plugin' ) ) : +if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_14_0\\SV_WC_Plugin' ) ) : /** @@ -47,7 +47,7 @@ abstract class SV_WC_Plugin { /** Plugin Framework Version */ - const VERSION = '5.13.1-dev.1'; + const VERSION = '5.14.0-dev.1'; /** @var object single instance of plugin */ protected static $instance; diff --git a/woocommerce/class-sv-wp-admin-message-handler.php b/woocommerce/class-sv-wp-admin-message-handler.php index 030184e3f..11c8719d6 100644 --- a/woocommerce/class-sv-wp-admin-message-handler.php +++ b/woocommerce/class-sv-wp-admin-message-handler.php @@ -22,11 +22,11 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 */ -namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1; +namespace SkyVerge\WooCommerce\PluginFramework\v5_14_0; defined( 'ABSPATH' ) or exit; -if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\SV_WP_Admin_Message_Handler' ) ) : +if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_14_0\\SV_WP_Admin_Message_Handler' ) ) : /** diff --git a/woocommerce/compatibility/abstract-sv-wc-data-compatibility.php b/woocommerce/compatibility/abstract-sv-wc-data-compatibility.php index c5848db94..46049ff84 100644 --- a/woocommerce/compatibility/abstract-sv-wc-data-compatibility.php +++ b/woocommerce/compatibility/abstract-sv-wc-data-compatibility.php @@ -22,11 +22,11 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 */ -namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1; +namespace SkyVerge\WooCommerce\PluginFramework\v5_14_0; defined( 'ABSPATH' ) or exit; -if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\SV_WC_Data_Compatibility' ) ) : +if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_14_0\\SV_WC_Data_Compatibility' ) ) : /** diff --git a/woocommerce/compatibility/class-sv-wc-order-compatibility.php b/woocommerce/compatibility/class-sv-wc-order-compatibility.php index 046dd1efd..c970fc952 100644 --- a/woocommerce/compatibility/class-sv-wc-order-compatibility.php +++ b/woocommerce/compatibility/class-sv-wc-order-compatibility.php @@ -22,7 +22,7 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 */ -namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1; +namespace SkyVerge\WooCommerce\PluginFramework\v5_14_0; use Automattic\WooCommerce\Admin\Overrides\Order; use Automattic\WooCommerce\Internal\Admin\Orders\PageController; @@ -32,7 +32,7 @@ defined( 'ABSPATH' ) or exit; -if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\SV_WC_Order_Compatibility' ) ) : +if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_14_0\\SV_WC_Order_Compatibility' ) ) : /** diff --git a/woocommerce/compatibility/class-sv-wc-subscription-compatibility.php b/woocommerce/compatibility/class-sv-wc-subscription-compatibility.php index da32e6bf7..dfae0196d 100644 --- a/woocommerce/compatibility/class-sv-wc-subscription-compatibility.php +++ b/woocommerce/compatibility/class-sv-wc-subscription-compatibility.php @@ -22,11 +22,11 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 */ -namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1; +namespace SkyVerge\WooCommerce\PluginFramework\v5_14_0; defined( 'ABSPATH' ) or exit; -if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\SV_WC_Subscription_Compatibility' ) ) : +if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_14_0\\SV_WC_Subscription_Compatibility' ) ) : /** * WooCommerce subscription compatibility class. diff --git a/woocommerce/payment-gateway/Blocks/Gateway_Blocks_Handler.php b/woocommerce/payment-gateway/Blocks/Gateway_Blocks_Handler.php index 7b73d05fa..9b6980271 100644 --- a/woocommerce/payment-gateway/Blocks/Gateway_Blocks_Handler.php +++ b/woocommerce/payment-gateway/Blocks/Gateway_Blocks_Handler.php @@ -1,16 +1,16 @@ get_handler()->get_plugin()->get_payment_gateway_framework_assets_url() . '/css/frontend/sv-wc-payment-gateway-external-checkout.css', array(), $this->get_handler()->get_plugin()->get_version() ); // TODO: min + wp_enqueue_style( 'sv-wc-external-checkout-v5_14_0', $this->get_handler()->get_plugin()->get_payment_gateway_framework_assets_url() . '/css/frontend/sv-wc-payment-gateway-external-checkout.css', array(), $this->get_handler()->get_plugin()->get_version() ); // TODO: min } diff --git a/woocommerce/payment-gateway/External_Checkout/Google_Pay/AJAX.php b/woocommerce/payment-gateway/External_Checkout/Google_Pay/AJAX.php index 9175190ee..9f3353fa9 100644 --- a/woocommerce/payment-gateway/External_Checkout/Google_Pay/AJAX.php +++ b/woocommerce/payment-gateway/External_Checkout/Google_Pay/AJAX.php @@ -22,14 +22,14 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 */ -namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1\Payment_Gateway\External_Checkout\Google_Pay; +namespace SkyVerge\WooCommerce\PluginFramework\v5_14_0\Payment_Gateway\External_Checkout\Google_Pay; -use SkyVerge\WooCommerce\PluginFramework\v5_13_1\SV_WC_Helper; -use SkyVerge\WooCommerce\PluginFramework\v5_13_1\SV_WC_Payment_Gateway_Exception; +use SkyVerge\WooCommerce\PluginFramework\v5_14_0\SV_WC_Helper; +use SkyVerge\WooCommerce\PluginFramework\v5_14_0\SV_WC_Payment_Gateway_Exception; defined( 'ABSPATH' ) or exit; -if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\Payment_Gateway\\External_Checkout\\Google_Pay\\AJAX' ) ) : +if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_14_0\\Payment_Gateway\\External_Checkout\\Google_Pay\\AJAX' ) ) : /** diff --git a/woocommerce/payment-gateway/External_Checkout/Google_Pay/Admin.php b/woocommerce/payment-gateway/External_Checkout/Google_Pay/Admin.php index 483274c4d..25d81e1c1 100755 --- a/woocommerce/payment-gateway/External_Checkout/Google_Pay/Admin.php +++ b/woocommerce/payment-gateway/External_Checkout/Google_Pay/Admin.php @@ -22,13 +22,13 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 */ -namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1\Payment_Gateway\External_Checkout\Google_Pay; +namespace SkyVerge\WooCommerce\PluginFramework\v5_14_0\Payment_Gateway\External_Checkout\Google_Pay; -use SkyVerge\WooCommerce\PluginFramework\v5_13_1\SV_WC_Helper; +use SkyVerge\WooCommerce\PluginFramework\v5_14_0\SV_WC_Helper; defined( 'ABSPATH' ) or exit; -if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\Payment_Gateway\\External_Checkout\\Google_Pay\\Admin' ) ) : +if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_14_0\\Payment_Gateway\\External_Checkout\\Google_Pay\\Admin' ) ) : /** @@ -37,7 +37,7 @@ * @since 5.10.0 */ #[\AllowDynamicProperties] -class Admin extends \SkyVerge\WooCommerce\PluginFramework\v5_13_1\Payment_Gateway\External_Checkout\Admin { +class Admin extends \SkyVerge\WooCommerce\PluginFramework\v5_14_0\Payment_Gateway\External_Checkout\Admin { /** @var Google_Pay the Google Pay handler instance */ diff --git a/woocommerce/payment-gateway/External_Checkout/Google_Pay/Frontend.php b/woocommerce/payment-gateway/External_Checkout/Google_Pay/Frontend.php index 654b2fb13..9400fc0fb 100644 --- a/woocommerce/payment-gateway/External_Checkout/Google_Pay/Frontend.php +++ b/woocommerce/payment-gateway/External_Checkout/Google_Pay/Frontend.php @@ -22,14 +22,14 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 */ -namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1\Payment_Gateway\External_Checkout\Google_Pay; +namespace SkyVerge\WooCommerce\PluginFramework\v5_14_0\Payment_Gateway\External_Checkout\Google_Pay; -use SkyVerge\WooCommerce\PluginFramework\v5_13_1\SV_WC_Payment_Gateway_Exception; -use SkyVerge\WooCommerce\PluginFramework\v5_13_1\SV_WC_Payment_Gateway_Plugin; +use SkyVerge\WooCommerce\PluginFramework\v5_14_0\SV_WC_Payment_Gateway_Exception; +use SkyVerge\WooCommerce\PluginFramework\v5_14_0\SV_WC_Payment_Gateway_Plugin; defined( 'ABSPATH' ) or exit; -if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\Payment_Gateway\\External_Checkout\\Google_Pay\\Frontend' ) ) : +if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_14_0\\Payment_Gateway\\External_Checkout\\Google_Pay\\Frontend' ) ) : /** @@ -38,7 +38,7 @@ * @since 5.10.0 */ #[\AllowDynamicProperties] -class Frontend extends \SkyVerge\WooCommerce\PluginFramework\v5_13_1\Payment_Gateway\External_Checkout\Frontend { +class Frontend extends \SkyVerge\WooCommerce\PluginFramework\v5_14_0\Payment_Gateway\External_Checkout\Frontend { /** @var string JS handler base class name, without the FW version */ @@ -102,7 +102,7 @@ public function enqueue_scripts() { $version = $gateway->get_plugin()->get_assets_version( $gateway->get_id() ); wp_enqueue_script( 'google-pay-js-library', 'https://pay.google.com/gp/p/js/pay.js', [], $version, true ); - wp_enqueue_script( 'sv-wc-google-pay-v5_13_1', $this->get_plugin()->get_payment_gateway_framework_assets_url() . '/dist/frontend/sv-wc-payment-gateway-google-pay.js', [ 'google-pay-js-library', 'jquery' ], $version, true ); + wp_enqueue_script( 'sv-wc-google-pay-v5_14_0', $this->get_plugin()->get_payment_gateway_framework_assets_url() . '/dist/frontend/sv-wc-payment-gateway-google-pay.js', [ 'google-pay-js-library', 'jquery' ], $version, true ); } diff --git a/woocommerce/payment-gateway/External_Checkout/Google_Pay/Google_Pay.php b/woocommerce/payment-gateway/External_Checkout/Google_Pay/Google_Pay.php index 4530f424e..388dc7e8b 100755 --- a/woocommerce/payment-gateway/External_Checkout/Google_Pay/Google_Pay.php +++ b/woocommerce/payment-gateway/External_Checkout/Google_Pay/Google_Pay.php @@ -22,17 +22,17 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 */ -namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1\Payment_Gateway\External_Checkout\Google_Pay; +namespace SkyVerge\WooCommerce\PluginFramework\v5_14_0\Payment_Gateway\External_Checkout\Google_Pay; -use SkyVerge\WooCommerce\PluginFramework\v5_13_1\Payment_Gateway\External_Checkout\External_Checkout; -use SkyVerge\WooCommerce\PluginFramework\v5_13_1\Payment_Gateway\External_Checkout\Orders; -use SkyVerge\WooCommerce\PluginFramework\v5_13_1\SV_WC_Payment_Gateway_Exception; -use SkyVerge\WooCommerce\PluginFramework\v5_13_1\SV_WC_Payment_Gateway_Helper; -use SkyVerge\WooCommerce\PluginFramework\v5_13_1\SV_WC_Payment_Gateway_Plugin; +use SkyVerge\WooCommerce\PluginFramework\v5_14_0\Payment_Gateway\External_Checkout\External_Checkout; +use SkyVerge\WooCommerce\PluginFramework\v5_14_0\Payment_Gateway\External_Checkout\Orders; +use SkyVerge\WooCommerce\PluginFramework\v5_14_0\SV_WC_Payment_Gateway_Exception; +use SkyVerge\WooCommerce\PluginFramework\v5_14_0\SV_WC_Payment_Gateway_Helper; +use SkyVerge\WooCommerce\PluginFramework\v5_14_0\SV_WC_Payment_Gateway_Plugin; defined( 'ABSPATH' ) or exit; -if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\Payment_Gateway\\External_Checkout\\Google_Pay\\Google_Pay' ) ) : +if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_14_0\\Payment_Gateway\\External_Checkout\\Google_Pay\\Google_Pay' ) ) : /** @@ -677,7 +677,7 @@ public function get_supported_networks() { $accepted_card_types = ( $this->get_processing_gateway() ) ? $this->get_processing_gateway()->get_card_types() : []; - $accepted_card_types = array_map( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\SV_WC_Payment_Gateway_Helper::normalize_card_type', $accepted_card_types ); + $accepted_card_types = array_map( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_14_0\\SV_WC_Payment_Gateway_Helper::normalize_card_type', $accepted_card_types ); $valid_networks = [ SV_WC_Payment_Gateway_Helper::CARD_TYPE_AMEX => 'AMEX', diff --git a/woocommerce/payment-gateway/External_Checkout/Orders.php b/woocommerce/payment-gateway/External_Checkout/Orders.php index 11b1899ee..ef0f8adef 100644 --- a/woocommerce/payment-gateway/External_Checkout/Orders.php +++ b/woocommerce/payment-gateway/External_Checkout/Orders.php @@ -22,9 +22,9 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 */ -namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1\Payment_Gateway\External_Checkout; +namespace SkyVerge\WooCommerce\PluginFramework\v5_14_0\Payment_Gateway\External_Checkout; -use SkyVerge\WooCommerce\PluginFramework\v5_13_1 as Framework; +use SkyVerge\WooCommerce\PluginFramework\v5_14_0 as Framework; defined( 'ABSPATH' ) or exit; diff --git a/woocommerce/payment-gateway/External_Checkout/apple-pay/api/class-sv-wc-payment-gateway-apple-pay-api-request.php b/woocommerce/payment-gateway/External_Checkout/apple-pay/api/class-sv-wc-payment-gateway-apple-pay-api-request.php index 9f2052738..3eb4eff5c 100644 --- a/woocommerce/payment-gateway/External_Checkout/apple-pay/api/class-sv-wc-payment-gateway-apple-pay-api-request.php +++ b/woocommerce/payment-gateway/External_Checkout/apple-pay/api/class-sv-wc-payment-gateway-apple-pay-api-request.php @@ -22,11 +22,11 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 */ -namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1; +namespace SkyVerge\WooCommerce\PluginFramework\v5_14_0; defined( 'ABSPATH' ) or exit; -if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\SV_WC_Payment_Gateway_Apple_Pay_API_Request' ) ) : +if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_14_0\\SV_WC_Payment_Gateway_Apple_Pay_API_Request' ) ) : /** diff --git a/woocommerce/payment-gateway/External_Checkout/apple-pay/api/class-sv-wc-payment-gateway-apple-pay-api-response.php b/woocommerce/payment-gateway/External_Checkout/apple-pay/api/class-sv-wc-payment-gateway-apple-pay-api-response.php index 247519b14..28aad6b86 100644 --- a/woocommerce/payment-gateway/External_Checkout/apple-pay/api/class-sv-wc-payment-gateway-apple-pay-api-response.php +++ b/woocommerce/payment-gateway/External_Checkout/apple-pay/api/class-sv-wc-payment-gateway-apple-pay-api-response.php @@ -22,11 +22,11 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 */ -namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1; +namespace SkyVerge\WooCommerce\PluginFramework\v5_14_0; defined( 'ABSPATH' ) or exit; -if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\SV_WC_Payment_Gateway_Apple_Pay_API_Response' ) ) : +if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_14_0\\SV_WC_Payment_Gateway_Apple_Pay_API_Response' ) ) : /** diff --git a/woocommerce/payment-gateway/External_Checkout/apple-pay/api/class-sv-wc-payment-gateway-apple-pay-api.php b/woocommerce/payment-gateway/External_Checkout/apple-pay/api/class-sv-wc-payment-gateway-apple-pay-api.php index e4f0a9f73..3d8c0e5ff 100644 --- a/woocommerce/payment-gateway/External_Checkout/apple-pay/api/class-sv-wc-payment-gateway-apple-pay-api.php +++ b/woocommerce/payment-gateway/External_Checkout/apple-pay/api/class-sv-wc-payment-gateway-apple-pay-api.php @@ -22,11 +22,11 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 */ -namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1; +namespace SkyVerge\WooCommerce\PluginFramework\v5_14_0; defined( 'ABSPATH' ) or exit; -if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\SV_WC_Payment_Gateway_Apple_Pay_API' ) ) : +if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_14_0\\SV_WC_Payment_Gateway_Apple_Pay_API' ) ) : /** @@ -58,7 +58,7 @@ public function __construct( SV_WC_Payment_Gateway $gateway ) { $this->set_request_content_type_header( 'application/json' ); $this->set_request_accept_header( 'application/json' ); - $this->set_response_handler( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\SV_WC_Payment_Gateway_Apple_Pay_API_Response' ); + $this->set_response_handler( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_14_0\\SV_WC_Payment_Gateway_Apple_Pay_API_Response' ); } diff --git a/woocommerce/payment-gateway/External_Checkout/apple-pay/api/class-sv-wc-payment-gateway-apple-pay-payment-response.php b/woocommerce/payment-gateway/External_Checkout/apple-pay/api/class-sv-wc-payment-gateway-apple-pay-payment-response.php index 3d4199cd8..926e865b4 100644 --- a/woocommerce/payment-gateway/External_Checkout/apple-pay/api/class-sv-wc-payment-gateway-apple-pay-payment-response.php +++ b/woocommerce/payment-gateway/External_Checkout/apple-pay/api/class-sv-wc-payment-gateway-apple-pay-payment-response.php @@ -22,11 +22,11 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 */ -namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1; +namespace SkyVerge\WooCommerce\PluginFramework\v5_14_0; defined( 'ABSPATH' ) or exit; -if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\SV_WC_Payment_Gateway_Apple_Pay_Payment_Response' ) ) : +if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_14_0\\SV_WC_Payment_Gateway_Apple_Pay_Payment_Response' ) ) : /** diff --git a/woocommerce/payment-gateway/External_Checkout/apple-pay/class-sv-wc-payment-gateway-apple-pay-admin.php b/woocommerce/payment-gateway/External_Checkout/apple-pay/class-sv-wc-payment-gateway-apple-pay-admin.php index a4f7b4301..4230f93b2 100755 --- a/woocommerce/payment-gateway/External_Checkout/apple-pay/class-sv-wc-payment-gateway-apple-pay-admin.php +++ b/woocommerce/payment-gateway/External_Checkout/apple-pay/class-sv-wc-payment-gateway-apple-pay-admin.php @@ -22,13 +22,13 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 */ -namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1; +namespace SkyVerge\WooCommerce\PluginFramework\v5_14_0; -use SkyVerge\WooCommerce\PluginFramework\v5_13_1\Payment_Gateway\External_Checkout\Admin; +use SkyVerge\WooCommerce\PluginFramework\v5_14_0\Payment_Gateway\External_Checkout\Admin; defined( 'ABSPATH' ) or exit; -if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\SV_WC_Payment_Gateway_Apple_Pay_Admin' ) ) : +if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_14_0\\SV_WC_Payment_Gateway_Apple_Pay_Admin' ) ) : /** diff --git a/woocommerce/payment-gateway/External_Checkout/apple-pay/class-sv-wc-payment-gateway-apple-pay-ajax.php b/woocommerce/payment-gateway/External_Checkout/apple-pay/class-sv-wc-payment-gateway-apple-pay-ajax.php index fae8e57e6..9629a02ac 100644 --- a/woocommerce/payment-gateway/External_Checkout/apple-pay/class-sv-wc-payment-gateway-apple-pay-ajax.php +++ b/woocommerce/payment-gateway/External_Checkout/apple-pay/class-sv-wc-payment-gateway-apple-pay-ajax.php @@ -22,11 +22,11 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 */ -namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1; +namespace SkyVerge\WooCommerce\PluginFramework\v5_14_0; defined( 'ABSPATH' ) or exit; -if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\SV_WC_Payment_Gateway_Apple_Pay_AJAX' ) ) : +if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_14_0\\SV_WC_Payment_Gateway_Apple_Pay_AJAX' ) ) : /** diff --git a/woocommerce/payment-gateway/External_Checkout/apple-pay/class-sv-wc-payment-gateway-apple-pay-frontend.php b/woocommerce/payment-gateway/External_Checkout/apple-pay/class-sv-wc-payment-gateway-apple-pay-frontend.php index 6a3a92d6b..cd3b3873a 100644 --- a/woocommerce/payment-gateway/External_Checkout/apple-pay/class-sv-wc-payment-gateway-apple-pay-frontend.php +++ b/woocommerce/payment-gateway/External_Checkout/apple-pay/class-sv-wc-payment-gateway-apple-pay-frontend.php @@ -22,11 +22,11 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 */ -namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1; +namespace SkyVerge\WooCommerce\PluginFramework\v5_14_0; defined( 'ABSPATH' ) or exit; -if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\SV_WC_Payment_Gateway_Apple_Pay_Frontend' ) ) : +if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_14_0\\SV_WC_Payment_Gateway_Apple_Pay_Frontend' ) ) : /** @@ -35,7 +35,7 @@ * @since 4.7.0 */ #[\AllowDynamicProperties] -class SV_WC_Payment_Gateway_Apple_Pay_Frontend extends \SkyVerge\WooCommerce\PluginFramework\v5_13_1\Payment_Gateway\External_Checkout\Frontend { +class SV_WC_Payment_Gateway_Apple_Pay_Frontend extends \SkyVerge\WooCommerce\PluginFramework\v5_14_0\Payment_Gateway\External_Checkout\Frontend { /** @var string JS handler base class name, without the FW version */ @@ -116,9 +116,9 @@ public function enqueue_scripts() { $gateway = $this->get_gateway(); $version = $gateway->get_plugin()->get_assets_version( $gateway->get_id() ); - wp_enqueue_style( 'sv-wc-apple-pay-v5_13_1', $this->get_plugin()->get_payment_gateway_framework_assets_url() . '/css/frontend/sv-wc-payment-gateway-apple-pay.css', [], $version ); // TODO: min + wp_enqueue_style( 'sv-wc-apple-pay-v5_14_0', $this->get_plugin()->get_payment_gateway_framework_assets_url() . '/css/frontend/sv-wc-payment-gateway-apple-pay.css', [], $version ); // TODO: min - wp_enqueue_script( 'sv-wc-apple-pay-v5_13_1', $this->get_plugin()->get_payment_gateway_framework_assets_url() . '/dist/frontend/sv-wc-payment-gateway-apple-pay.js', [ 'jquery' ], $version, true ); + wp_enqueue_script( 'sv-wc-apple-pay-v5_14_0', $this->get_plugin()->get_payment_gateway_framework_assets_url() . '/dist/frontend/sv-wc-payment-gateway-apple-pay.js', [ 'jquery' ], $version, true ); } diff --git a/woocommerce/payment-gateway/External_Checkout/apple-pay/class-sv-wc-payment-gateway-apple-pay.php b/woocommerce/payment-gateway/External_Checkout/apple-pay/class-sv-wc-payment-gateway-apple-pay.php index 14669170f..c253e17ad 100755 --- a/woocommerce/payment-gateway/External_Checkout/apple-pay/class-sv-wc-payment-gateway-apple-pay.php +++ b/woocommerce/payment-gateway/External_Checkout/apple-pay/class-sv-wc-payment-gateway-apple-pay.php @@ -22,13 +22,13 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 */ -namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1; +namespace SkyVerge\WooCommerce\PluginFramework\v5_14_0; -use SkyVerge\WooCommerce\PluginFramework\v5_13_1\Payment_Gateway\External_Checkout\Orders; +use SkyVerge\WooCommerce\PluginFramework\v5_14_0\Payment_Gateway\External_Checkout\Orders; defined( 'ABSPATH' ) or exit; -if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\SV_WC_Payment_Gateway_Apple_Pay' ) ) : +if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_14_0\\SV_WC_Payment_Gateway_Apple_Pay' ) ) : /** @@ -942,7 +942,7 @@ public function get_supported_networks() { $accepted_card_types = ( $this->get_processing_gateway() ) ? $this->get_processing_gateway()->get_card_types() : array(); - $accepted_card_types = array_map( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\SV_WC_Payment_Gateway_Helper::normalize_card_type', $accepted_card_types ); + $accepted_card_types = array_map( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_14_0\\SV_WC_Payment_Gateway_Helper::normalize_card_type', $accepted_card_types ); $valid_networks = array( SV_WC_Payment_Gateway_Helper::CARD_TYPE_AMEX => 'amex', diff --git a/woocommerce/payment-gateway/Handlers/Abstract_Hosted_Payment_Handler.php b/woocommerce/payment-gateway/Handlers/Abstract_Hosted_Payment_Handler.php index bc627bece..7ea6f7090 100644 --- a/woocommerce/payment-gateway/Handlers/Abstract_Hosted_Payment_Handler.php +++ b/woocommerce/payment-gateway/Handlers/Abstract_Hosted_Payment_Handler.php @@ -22,11 +22,11 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 */ -namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1\Payment_Gateway\Handlers; +namespace SkyVerge\WooCommerce\PluginFramework\v5_14_0\Payment_Gateway\Handlers; -use SkyVerge\WooCommerce\PluginFramework\v5_13_1 as FrameworkBase; +use SkyVerge\WooCommerce\PluginFramework\v5_14_0 as FrameworkBase; -if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\Payment_Gateway\\Handlers\\Abstract_Hosted_Payment_Handler' ) ) : +if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_14_0\\Payment_Gateway\\Handlers\\Abstract_Hosted_Payment_Handler' ) ) : /** diff --git a/woocommerce/payment-gateway/Handlers/Abstract_Payment_Handler.php b/woocommerce/payment-gateway/Handlers/Abstract_Payment_Handler.php index 11938640c..725c94ef7 100644 --- a/woocommerce/payment-gateway/Handlers/Abstract_Payment_Handler.php +++ b/woocommerce/payment-gateway/Handlers/Abstract_Payment_Handler.php @@ -22,11 +22,11 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 */ -namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1\Payment_Gateway\Handlers; +namespace SkyVerge\WooCommerce\PluginFramework\v5_14_0\Payment_Gateway\Handlers; -use SkyVerge\WooCommerce\PluginFramework\v5_13_1 as FrameworkBase; +use SkyVerge\WooCommerce\PluginFramework\v5_14_0 as FrameworkBase; -if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\Payment_Gateway\\Handlers\\Abstract_Payment_Handler' ) ) : +if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_14_0\\Payment_Gateway\\Handlers\\Abstract_Payment_Handler' ) ) : /** diff --git a/woocommerce/payment-gateway/Handlers/Capture.php b/woocommerce/payment-gateway/Handlers/Capture.php index 0a3e1b1ab..1ae0ba535 100644 --- a/woocommerce/payment-gateway/Handlers/Capture.php +++ b/woocommerce/payment-gateway/Handlers/Capture.php @@ -22,13 +22,13 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 */ -namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1\Payment_Gateway\Handlers; +namespace SkyVerge\WooCommerce\PluginFramework\v5_14_0\Payment_Gateway\Handlers; -use SkyVerge\WooCommerce\PluginFramework\v5_13_1 as Framework; +use SkyVerge\WooCommerce\PluginFramework\v5_14_0 as Framework; defined( 'ABSPATH' ) or exit; -if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\Payment_Gateway\\Handlers\\Capture' ) ) : +if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_14_0\\Payment_Gateway\\Handlers\\Capture' ) ) : /** diff --git a/woocommerce/payment-gateway/PaymentFormContextChecker.php b/woocommerce/payment-gateway/PaymentFormContextChecker.php index 98b96bab6..69d3ff803 100644 --- a/woocommerce/payment-gateway/PaymentFormContextChecker.php +++ b/woocommerce/payment-gateway/PaymentFormContextChecker.php @@ -1,8 +1,8 @@ 0&&void 0!==arguments[0]?arguments[0]:{};return this.block_ui(),this.get_payment_request(n).then(function(n){return e(t.button).show(),e(t.wrapper).show(),t.payment_request=JSON.parse(n),t.unblock_ui()},function(n){return console.error("[Apple Pay] Could not build payment request. "+n.message),e(t.button).hide(),1===e(t.container).children().length&&e(t.wrapper).hide(),t.unblock_ui()})}},{key:"get_payment_request",value:function(t){var n=this;return new Promise(function(i,o){var a;return a={action:"wc_".concat(n.gateway_id,"_apple_pay_get_payment_request")},e.extend(t,a),e.post(n.ajax_url,t,function(e){return e.success?i(e.data):o(e.data)})})}},{key:"render_errors",value:function(t){return e(".woocommerce-error, .woocommerce-message").remove(),this.ui_element.prepend('
    • '+t.join("
    • ")+"
    "),this.ui_element.removeClass("processing").unblock(),e("html, body").animate({scrollTop:this.ui_element.offset().top-100},1e3)}},{key:"block_ui",value:function(){return this.ui_element.block({message:null,overlayCSS:{background:"#fff",opacity:.6}})}},{key:"unblock_ui",value:function(){return this.ui_element.unblock()}}])}(),e(document.body).trigger("sv_wc_apple_pay_handler_v5_13_1_loaded")})}).call(this); +function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(t)}function t(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function n(e,t){for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:{};return this.block_ui(),this.get_payment_request(n).then(function(n){return e(t.button).show(),e(t.wrapper).show(),t.payment_request=JSON.parse(n),t.unblock_ui()},function(n){return console.error("[Apple Pay] Could not build payment request. "+n.message),e(t.button).hide(),1===e(t.container).children().length&&e(t.wrapper).hide(),t.unblock_ui()})}},{key:"get_payment_request",value:function(t){var n=this;return new Promise(function(i,o){var a;return a={action:"wc_".concat(n.gateway_id,"_apple_pay_get_payment_request")},e.extend(t,a),e.post(n.ajax_url,t,function(e){return e.success?i(e.data):o(e.data)})})}},{key:"render_errors",value:function(t){return e(".woocommerce-error, .woocommerce-message").remove(),this.ui_element.prepend('
    • '+t.join("
    • ")+"
    "),this.ui_element.removeClass("processing").unblock(),e("html, body").animate({scrollTop:this.ui_element.offset().top-100},1e3)}},{key:"block_ui",value:function(){return this.ui_element.block({message:null,overlayCSS:{background:"#fff",opacity:.6}})}},{key:"unblock_ui",value:function(){return this.ui_element.unblock()}}])}(),e(document.body).trigger("sv_wc_apple_pay_handler_v5_14_0_loaded")})}).call(this); },{}]},{},["L57g"], null) //# sourceMappingURL=../frontend/sv-wc-payment-gateway-apple-pay.js.map diff --git a/woocommerce/payment-gateway/assets/dist/frontend/sv-wc-payment-gateway-apple-pay.js.map b/woocommerce/payment-gateway/assets/dist/frontend/sv-wc-payment-gateway-apple-pay.js.map index 29b0484b0..6eda3e44e 100644 --- a/woocommerce/payment-gateway/assets/dist/frontend/sv-wc-payment-gateway-apple-pay.js.map +++ b/woocommerce/payment-gateway/assets/dist/frontend/sv-wc-payment-gateway-apple-pay.js.map @@ -1 +1 @@ -{"version":3,"sources":["frontend/sv-wc-payment-gateway-apple-pay.coffee"],"names":["jQuery","$","window","SV_WC_Apple_Pay_Handler_v5_13_1","args","init_product_page","bind","init_cart_page","init_checkout_page","on_validate_merchant","validate_merchant","on_payment_method_selected","on_shipping_contact_selected","on_shipping_method_selected","on_payment_authorized","process_authorization","on_cancel_payment","reset_payment_request","get_payment_request","gateway_id","gateway_slug","merchant_id","ajax_url","validate_nonce","recalculate_totals_nonce","process_nonce","payment_request","generic_error","wrapper","container","button","ApplePaySession","canMakePaymentsWithActiveCard","then","canMakePayments","children","length","hide","is_available","ui_element","show","document","body","on","e","error","preventDefault","block_ui","session","get_new_session","onvalidatemerchant","event","onpaymentmethodselected","onshippingcontactselected","onshippingmethodselected","onpaymentauthorized","oncancel","begin","error1","fail_payment","parents","get_sdk_version","validationURL","merchant_session","JSON","parse","completeMerchantValidation","response","abort","message","url","Promise","resolve","reject","data","post","success","completePaymentMethodSelection","total","line_items","console","lineItems","shippingContact","completeShippingContactSelection","STATUS_SUCCESS","shipping_methods","STATUS_FAILURE","shippingMethod","identifier","completeShippingMethodSelection","payment","set_payment_status","complete_purchase","action","nonce","stringify","unblock_ui","location","redirect","render_errors","status","completePayment","base_data","extend","errors","remove","prepend","join","removeClass","unblock","animate","scrollTop","offset","top","block","overlayCSS","background","opacity","trigger","call"],"mappings":";AAAA,SAAA,EAAA,GAAA,OAAA,EAAA,mBAAA,QAAA,iBAAA,OAAA,SAAA,SAAA,GAAA,cAAA,GAAA,SAAA,GAAA,OAAA,GAAA,mBAAA,QAAA,EAAA,cAAA,QAAA,IAAA,OAAA,UAAA,gBAAA,IAAA,GAAA,SAAA,EAAA,EAAA,GAAA,KAAA,aAAA,GAAA,MAAA,IAAA,UAAA,qCAAA,SAAA,EAAA,EAAA,GAAA,IAAA,IAAA,EAAA,EAAA,EAAA,EAAA,OAAA,IAAA,CAAA,IAAA,EAAA,EAAA,GAAA,EAAA,WAAA,EAAA,aAAA,EAAA,EAAA,cAAA,EAAA,UAAA,IAAA,EAAA,UAAA,GAAA,OAAA,eAAA,EAAA,EAAA,EAAA,KAAA,IAAA,SAAA,EAAA,EAAA,EAAA,GAAA,OAAA,GAAA,EAAA,EAAA,UAAA,GAAA,GAAA,EAAA,EAAA,GAAA,OAAA,eAAA,EAAA,YAAA,CAAA,UA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C,OAnYP,CAAA,IAAA,WAyYE,MAAA,WACS,OAAA,KAAK1E,WAAW2E,MAAM,CAC3B7C,QAAS,KACT8C,WAAY,CACVC,WAAY,OACZC,QAAS,QA9YjB,CAAA,IAAA,aAsZE,MAAA,WACS,OAAA,KAAK9E,WAAWsE,cAvZ3B,GA4ZO5G,EAAEwC,SAASC,MAAM4E,QAAQ,8CAGjCC,KAAK","file":"sv-wc-payment-gateway-apple-pay.js","sourceRoot":"../js","sourcesContent":["(function() {\n /*\n WooCommerce Apple Pay Handler\n Version 4.7.0\n\n Copyright (c) 2016, SkyVerge, Inc.\n Licensed under the GNU General Public License v3.0\n http://www.gnu.org/licenses/gpl-3.0.html\n */\n jQuery(function($) {\n \"use strict\";\n // The WooCommerce Apple Pay handler base class.\n\n // @since 4.7.0\n window.SV_WC_Apple_Pay_Handler_v5_13_1 = class SV_WC_Apple_Pay_Handler_v5_13_1 {\n // Constructs the handler.\n\n // @since 4.7.0\n constructor(args) {\n // Initializes the product page.\n\n // @since 5.6.0\n this.init_product_page = this.init_product_page.bind(this);\n // Initializes the cart page.\n\n // @since 5.6.0\n this.init_cart_page = this.init_cart_page.bind(this);\n // Initializes the checkout page.\n\n // @since 5.6.0\n this.init_checkout_page = this.init_checkout_page.bind(this);\n // The callback for after the merchant data is validated.\n\n // @since 4.7.0\n this.on_validate_merchant = this.on_validate_merchant.bind(this);\n // Validates the merchant data.\n\n // @since 4.7.0\n // @return object\n this.validate_merchant = this.validate_merchant.bind(this);\n // Fires after a payment method has been selected.\n\n // @since 4.7.0\n this.on_payment_method_selected = this.on_payment_method_selected.bind(this);\n // Fires after a shipping contact has been selected.\n\n // @since 4.7.0\n this.on_shipping_contact_selected = this.on_shipping_contact_selected.bind(this);\n // Fires after a shipping method has been selected.\n\n // @since 4.7.0\n this.on_shipping_method_selected = this.on_shipping_method_selected.bind(this);\n // The callback for after the payment data is authorized.\n\n // @since 4.7.0\n this.on_payment_authorized = this.on_payment_authorized.bind(this);\n // Processes the transaction data.\n\n // @since 4.7.0\n this.process_authorization = this.process_authorization.bind(this);\n // The callback for when the payment card is cancelled/dismissed.\n\n // @since 4.7.0\n this.on_cancel_payment = this.on_cancel_payment.bind(this);\n // Resets the payment request via AJAX.\n\n // Extending handlers can call this on change events to refresh the data.\n\n // @since 4.7.0\n this.reset_payment_request = this.reset_payment_request.bind(this);\n // Gets the payment request via AJAX.\n\n // @since 4.7.0\n this.get_payment_request = this.get_payment_request.bind(this);\n this.gateway_id = args.gateway_id;\n this.gateway_slug = args.gateway_slug;\n this.merchant_id = args.merchant_id;\n this.ajax_url = args.ajax_url;\n this.validate_nonce = args.validate_nonce;\n this.recalculate_totals_nonce = args.recalculate_totals_nonce;\n this.process_nonce = args.process_nonce;\n this.payment_request = args.payment_request;\n this.generic_error = args.generic_error;\n this.wrapper = '.sv-wc-external-checkout';\n this.container = '.buttons-container';\n this.button = '.sv-wc-apple-pay-button';\n }\n\n // Determines if Apple Pay is available.\n\n // @since 4.7.0\n // @return bool\n is_available() {\n if (!window.ApplePaySession) {\n return false;\n }\n return ApplePaySession.canMakePaymentsWithActiveCard(this.merchant_id).then((canMakePayments) => {\n return canMakePayments;\n });\n }\n\n // Initializes the handler.\n\n // @since 4.7.0\n init() {\n // hide the wrapper if Apple Pay is the only button\n if ($(this.container).children().length === 1) {\n $(this.wrapper).hide();\n }\n if (!this.is_available()) {\n return;\n }\n // initialize for the various pages\n if ($('form.cart').length) {\n this.init_product_page();\n } else if ($('form.woocommerce-cart-form').length) {\n this.init_cart_page();\n } else if ($('form.woocommerce-checkout').length) {\n this.init_checkout_page();\n }\n // bail if no UI was initialized\n if (!this.ui_element) {\n return;\n }\n if (this.payment_request) {\n $(this.button).show();\n $(this.wrapper).show();\n }\n return $(document.body).on('click', '.sv-wc-apple-pay-button', (e) => {\n var error;\n e.preventDefault();\n this.block_ui();\n try {\n this.session = this.get_new_session(this.payment_request);\n // set the payment card events\n this.session.onvalidatemerchant = (event) => {\n return this.on_validate_merchant(event);\n };\n this.session.onpaymentmethodselected = (event) => {\n return this.on_payment_method_selected(event);\n };\n this.session.onshippingcontactselected = (event) => {\n return this.on_shipping_contact_selected(event);\n };\n this.session.onshippingmethodselected = (event) => {\n return this.on_shipping_method_selected(event);\n };\n this.session.onpaymentauthorized = (event) => {\n return this.on_payment_authorized(event);\n };\n this.session.oncancel = (event) => {\n return this.on_cancel_payment(event);\n };\n return this.session.begin();\n } catch (error1) {\n error = error1;\n return this.fail_payment(error);\n }\n });\n }\n\n init_product_page() {\n return this.ui_element = $('form.cart');\n }\n\n init_cart_page() {\n this.ui_element = $('form.woocommerce-cart-form').parents('div.woocommerce');\n // re-init if the cart totals are updated\n return $(document.body).on('updated_cart_totals', () => {\n return this.reset_payment_request();\n });\n }\n\n init_checkout_page() {\n this.ui_element = $('form.woocommerce-checkout');\n return $(document.body).on('updated_checkout', () => {\n // re-init if the checkout is updated\n return this.reset_payment_request();\n });\n }\n\n // Gets a new Apple Pay session.\n\n // @since 5.6.0\n\n // @param [Object] payment_request payment request object\n // @return ApplePaySession\n get_new_session(payment_request) {\n return new ApplePaySession(this.get_sdk_version(), payment_request);\n }\n\n // Gets the Apple SDK version to use.\n\n // @since 5.6.0\n // @return int\n get_sdk_version() {\n return 2;\n }\n\n on_validate_merchant(event) {\n return this.validate_merchant(event.validationURL).then((merchant_session) => {\n merchant_session = JSON.parse(merchant_session);\n return this.session.completeMerchantValidation(merchant_session);\n }, (response) => {\n this.session.abort();\n return this.fail_payment('Merchant could no be validated. ' + response.message);\n });\n }\n\n validate_merchant(url) {\n return new Promise((resolve, reject) => {\n var data;\n data = {\n 'action': `wc_${this.gateway_id}_apple_pay_validate_merchant`,\n 'nonce': this.validate_nonce,\n 'merchant_id': this.merchant_id,\n 'url': url\n };\n // retrieve a payment request object\n return $.post(this.ajax_url, data, (response) => {\n if (response.success) {\n return resolve(response.data);\n } else {\n return reject(response.data);\n }\n });\n });\n }\n\n on_payment_method_selected(event) {\n return new Promise((resolve, reject) => {\n var data;\n data = {\n 'action': `wc_${this.gateway_id}_apple_pay_recalculate_totals`,\n 'nonce': this.recalculate_totals_nonce\n };\n // retrieve a payment request object\n return $.post(this.ajax_url, data, (response) => {\n if (response.success) {\n data = response.data;\n return resolve(this.session.completePaymentMethodSelection(data.total, data.line_items));\n } else {\n console.error('[Apple Pay] Error selecting a shipping contact. ' + response.data.message);\n return reject(this.session.completePaymentMethodSelection(this.payment_request.total, this.payment_request.lineItems));\n }\n });\n });\n }\n\n on_shipping_contact_selected(event) {\n return new Promise((resolve, reject) => {\n var data;\n data = {\n 'action': `wc_${this.gateway_id}_apple_pay_recalculate_totals`,\n 'nonce': this.recalculate_totals_nonce,\n 'contact': event.shippingContact\n };\n // retrieve a payment request object\n return $.post(this.ajax_url, data, (response) => {\n if (response.success) {\n data = response.data;\n return resolve(this.session.completeShippingContactSelection(ApplePaySession.STATUS_SUCCESS, data.shipping_methods, data.total, data.line_items));\n } else {\n console.error('[Apple Pay] Error selecting a shipping contact. ' + response.data.message);\n return reject(this.session.completeShippingContactSelection(ApplePaySession.STATUS_FAILURE, [], this.payment_request.total, this.payment_request.lineItems));\n }\n });\n });\n }\n\n on_shipping_method_selected(event) {\n return new Promise((resolve, reject) => {\n var data;\n data = {\n 'action': `wc_${this.gateway_id}_apple_pay_recalculate_totals`,\n 'nonce': this.recalculate_totals_nonce,\n 'method': event.shippingMethod.identifier\n };\n // retrieve a payment request object\n return $.post(this.ajax_url, data, (response) => {\n if (response.success) {\n data = response.data;\n return resolve(this.session.completeShippingMethodSelection(ApplePaySession.STATUS_SUCCESS, data.total, data.line_items));\n } else {\n console.error('[Apple Pay] Error selecting a shipping method. ' + response.data.message);\n return reject(this.session.completeShippingMethodSelection(ApplePaySession.STATUS_FAILURE, this.payment_request.total, this.payment_request.lineItems));\n }\n });\n });\n }\n\n on_payment_authorized(event) {\n return this.process_authorization(event.payment).then((response) => {\n this.set_payment_status(true);\n return this.complete_purchase(response);\n }, (response) => {\n this.set_payment_status(false);\n return this.fail_payment('Payment could no be processed. ' + response.message);\n });\n }\n\n process_authorization(payment) {\n return new Promise((resolve, reject) => {\n var data;\n data = {\n action: `wc_${this.gateway_id}_apple_pay_process_payment`,\n nonce: this.process_nonce,\n payment: JSON.stringify(payment)\n };\n return $.post(this.ajax_url, data, (response) => {\n if (response.success) {\n return resolve(response.data);\n } else {\n return reject(response.data);\n }\n });\n });\n }\n\n on_cancel_payment(event) {\n return this.unblock_ui();\n }\n\n // Completes the purchase based on the gateway result.\n\n // @since 4.7.0\n complete_purchase(response) {\n return window.location = response.redirect;\n }\n\n // Fails the purchase based on the gateway result.\n\n // @since 4.7.0\n fail_payment(error) {\n console.error('[Apple Pay] ' + error);\n this.unblock_ui();\n return this.render_errors([this.generic_error]);\n }\n\n // Sets the Apple Pay payment status depending on the gateway result.\n\n // @since 4.7.0\n set_payment_status(success) {\n var status;\n if (success) {\n status = ApplePaySession.STATUS_SUCCESS;\n } else {\n status = ApplePaySession.STATUS_FAILURE;\n }\n return this.session.completePayment(status);\n }\n\n reset_payment_request(data = {}) {\n this.block_ui();\n return this.get_payment_request(data).then((response) => {\n $(this.button).show();\n $(this.wrapper).show();\n this.payment_request = JSON.parse(response);\n return this.unblock_ui();\n }, (response) => {\n console.error('[Apple Pay] Could not build payment request. ' + response.message);\n $(this.button).hide();\n // hide the wrapper if Apple Pay is the only button\n if ($(this.container).children().length === 1) {\n $(this.wrapper).hide();\n }\n return this.unblock_ui();\n });\n }\n\n get_payment_request(data) {\n return new Promise((resolve, reject) => {\n var base_data;\n base_data = {\n 'action': `wc_${this.gateway_id}_apple_pay_get_payment_request`\n };\n $.extend(data, base_data);\n // retrieve a payment request object\n return $.post(this.ajax_url, data, (response) => {\n if (response.success) {\n return resolve(response.data);\n } else {\n return reject(response.data);\n }\n });\n });\n }\n\n // Renders any new errors and bring them into the viewport.\n\n // @since 4.7.0\n render_errors(errors) {\n // hide and remove any previous errors\n $('.woocommerce-error, .woocommerce-message').remove();\n // add errors\n this.ui_element.prepend('
    • ' + errors.join('
    • ') + '
    ');\n // unblock UI\n this.ui_element.removeClass('processing').unblock();\n // scroll to top\n return $('html, body').animate({\n scrollTop: this.ui_element.offset().top - 100\n }, 1000);\n }\n\n // Blocks the payment form UI.\n\n // @since 4.7.0\n block_ui() {\n return this.ui_element.block({\n message: null,\n overlayCSS: {\n background: '#fff',\n opacity: 0.6\n }\n });\n }\n\n // Unblocks the payment form UI.\n\n // @since 4.7.0\n unblock_ui() {\n return this.ui_element.unblock();\n }\n\n };\n // dispatch loaded event\n return $(document.body).trigger('sv_wc_apple_pay_handler_v5_13_1_loaded');\n });\n\n}).call(this);\n"]} +{"version":3,"sources":["frontend/sv-wc-payment-gateway-apple-pay.coffee"],"names":["jQuery","$","window","SV_WC_Apple_Pay_Handler_v5_14_0","args","init_product_page","bind","init_cart_page","init_checkout_page","on_validate_merchant","validate_merchant","on_payment_method_selected","on_shipping_contact_selected","on_shipping_method_selected","on_payment_authorized","process_authorization","on_cancel_payment","reset_payment_request","get_payment_request","gateway_id","gateway_slug","merchant_id","ajax_url","validate_nonce","recalculate_totals_nonce","process_nonce","payment_request","generic_error","wrapper","container","button","ApplePaySession","canMakePaymentsWithActiveCard","then","canMakePayments","children","length","hide","is_available","ui_element","show","document","body","on","e","error","preventDefault","block_ui","session","get_new_session","onvalidatemerchant","event","onpaymentmethodselected","onshippingcontactselected","onshippingmethodselected","onpaymentauthorized","oncancel","begin","error1","fail_payment","parents","get_sdk_version","validationURL","merchant_session","JSON","parse","completeMerchantValidation","response","abort","message","url","Promise","resolve","reject","data","post","success","completePaymentMethodSelection","total","line_items","console","lineItems","shippingContact","completeShippingContactSelection","STATUS_SUCCESS","shipping_methods","STATUS_FAILURE","shippingMethod","identifier","completeShippingMethodSelection","payment","set_payment_status","complete_purchase","action","nonce","stringify","unblock_ui","location","redirect","render_errors","status","completePayment","base_data","extend","errors","remove","prepend","join","removeClass","unblock","animate","scrollTop","offset","top","block","overlayCSS","background","opacity","trigger","call"],"mappings":";AAAA,SAA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AEX,EAAK2D,iBAhWlB,CAAA,IAAA,sBAoWE,MAAA,SAAoBtB,GAAM,IAAA,EAAA,KACjB,OAAA,IAAIH,QAAQ,SAACC,EAASC,GACvB6B,IAAAA,EAMGrG,OALPqG,EAAY,CACM,OAAA,MAAA,OAAA,EAAKnF,WAArB,mCAEFlB,EAAEsG,OAAO7B,EAAM4B,GAERrG,EAAE0E,KAAK,EAAKrD,SAAUoD,EAAM,SAACP,GAC9BA,OAAAA,EAASS,QACJJ,EAAQL,EAASO,MAEjBD,EAAON,EAASO,YAhXjC,CAAA,IAAA,gBAyXE,MAAA,SAAc8B,GAQLvG,OANPA,EAAE,4CAA4CwG,SAEzClE,KAAAA,WAAWmE,QAAQ,qCAAuCF,EAAOG,KAAK,aAAe,cAErFpE,KAAAA,WAAWqE,YAAY,cAAcC,UAEnC5G,EAAE,cAAc6G,QAAQ,CAC7BC,UAAW,KAAKxE,WAAWyE,SAASC,IAAM,KACzC,OAnYP,CAAA,IAAA,WAyYE,MAAA,WACS,OAAA,KAAK1E,WAAW2E,MAAM,CAC3B7C,QAAS,KACT8C,WAAY,CACVC,WAAY,OACZC,QAAS,QA9YjB,CAAA,IAAA,aAsZE,MAAA,WACS,OAAA,KAAK9E,WAAWsE,cAvZ3B,GA4ZO5G,EAAEwC,SAASC,MAAM4E,QAAQ,8CAGjCC,KAAK","file":"sv-wc-payment-gateway-apple-pay.js","sourceRoot":"../js","sourcesContent":["(function() {\n /*\n WooCommerce Apple Pay Handler\n Version 4.7.0\n\n Copyright (c) 2016, SkyVerge, Inc.\n Licensed under the GNU General Public License v3.0\n http://www.gnu.org/licenses/gpl-3.0.html\n */\n jQuery(function($) {\n \"use strict\";\n // The WooCommerce Apple Pay handler base class.\n\n // @since 4.7.0\n window.SV_WC_Apple_Pay_Handler_v5_14_0 = class SV_WC_Apple_Pay_Handler_v5_14_0 {\n // Constructs the handler.\n\n // @since 4.7.0\n constructor(args) {\n // Initializes the product page.\n\n // @since 5.6.0\n this.init_product_page = this.init_product_page.bind(this);\n // Initializes the cart page.\n\n // @since 5.6.0\n this.init_cart_page = this.init_cart_page.bind(this);\n // Initializes the checkout page.\n\n // @since 5.6.0\n this.init_checkout_page = this.init_checkout_page.bind(this);\n // The callback for after the merchant data is validated.\n\n // @since 4.7.0\n this.on_validate_merchant = this.on_validate_merchant.bind(this);\n // Validates the merchant data.\n\n // @since 4.7.0\n // @return object\n this.validate_merchant = this.validate_merchant.bind(this);\n // Fires after a payment method has been selected.\n\n // @since 4.7.0\n this.on_payment_method_selected = this.on_payment_method_selected.bind(this);\n // Fires after a shipping contact has been selected.\n\n // @since 4.7.0\n this.on_shipping_contact_selected = this.on_shipping_contact_selected.bind(this);\n // Fires after a shipping method has been selected.\n\n // @since 4.7.0\n this.on_shipping_method_selected = this.on_shipping_method_selected.bind(this);\n // The callback for after the payment data is authorized.\n\n // @since 4.7.0\n this.on_payment_authorized = this.on_payment_authorized.bind(this);\n // Processes the transaction data.\n\n // @since 4.7.0\n this.process_authorization = this.process_authorization.bind(this);\n // The callback for when the payment card is cancelled/dismissed.\n\n // @since 4.7.0\n this.on_cancel_payment = this.on_cancel_payment.bind(this);\n // Resets the payment request via AJAX.\n\n // Extending handlers can call this on change events to refresh the data.\n\n // @since 4.7.0\n this.reset_payment_request = this.reset_payment_request.bind(this);\n // Gets the payment request via AJAX.\n\n // @since 4.7.0\n this.get_payment_request = this.get_payment_request.bind(this);\n this.gateway_id = args.gateway_id;\n this.gateway_slug = args.gateway_slug;\n this.merchant_id = args.merchant_id;\n this.ajax_url = args.ajax_url;\n this.validate_nonce = args.validate_nonce;\n this.recalculate_totals_nonce = args.recalculate_totals_nonce;\n this.process_nonce = args.process_nonce;\n this.payment_request = args.payment_request;\n this.generic_error = args.generic_error;\n this.wrapper = '.sv-wc-external-checkout';\n this.container = '.buttons-container';\n this.button = '.sv-wc-apple-pay-button';\n }\n\n // Determines if Apple Pay is available.\n\n // @since 4.7.0\n // @return bool\n is_available() {\n if (!window.ApplePaySession) {\n return false;\n }\n return ApplePaySession.canMakePaymentsWithActiveCard(this.merchant_id).then((canMakePayments) => {\n return canMakePayments;\n });\n }\n\n // Initializes the handler.\n\n // @since 4.7.0\n init() {\n // hide the wrapper if Apple Pay is the only button\n if ($(this.container).children().length === 1) {\n $(this.wrapper).hide();\n }\n if (!this.is_available()) {\n return;\n }\n // initialize for the various pages\n if ($('form.cart').length) {\n this.init_product_page();\n } else if ($('form.woocommerce-cart-form').length) {\n this.init_cart_page();\n } else if ($('form.woocommerce-checkout').length) {\n this.init_checkout_page();\n }\n // bail if no UI was initialized\n if (!this.ui_element) {\n return;\n }\n if (this.payment_request) {\n $(this.button).show();\n $(this.wrapper).show();\n }\n return $(document.body).on('click', '.sv-wc-apple-pay-button', (e) => {\n var error;\n e.preventDefault();\n this.block_ui();\n try {\n this.session = this.get_new_session(this.payment_request);\n // set the payment card events\n this.session.onvalidatemerchant = (event) => {\n return this.on_validate_merchant(event);\n };\n this.session.onpaymentmethodselected = (event) => {\n return this.on_payment_method_selected(event);\n };\n this.session.onshippingcontactselected = (event) => {\n return this.on_shipping_contact_selected(event);\n };\n this.session.onshippingmethodselected = (event) => {\n return this.on_shipping_method_selected(event);\n };\n this.session.onpaymentauthorized = (event) => {\n return this.on_payment_authorized(event);\n };\n this.session.oncancel = (event) => {\n return this.on_cancel_payment(event);\n };\n return this.session.begin();\n } catch (error1) {\n error = error1;\n return this.fail_payment(error);\n }\n });\n }\n\n init_product_page() {\n return this.ui_element = $('form.cart');\n }\n\n init_cart_page() {\n this.ui_element = $('form.woocommerce-cart-form').parents('div.woocommerce');\n // re-init if the cart totals are updated\n return $(document.body).on('updated_cart_totals', () => {\n return this.reset_payment_request();\n });\n }\n\n init_checkout_page() {\n this.ui_element = $('form.woocommerce-checkout');\n return $(document.body).on('updated_checkout', () => {\n // re-init if the checkout is updated\n return this.reset_payment_request();\n });\n }\n\n // Gets a new Apple Pay session.\n\n // @since 5.6.0\n\n // @param [Object] payment_request payment request object\n // @return ApplePaySession\n get_new_session(payment_request) {\n return new ApplePaySession(this.get_sdk_version(), payment_request);\n }\n\n // Gets the Apple SDK version to use.\n\n // @since 5.6.0\n // @return int\n get_sdk_version() {\n return 2;\n }\n\n on_validate_merchant(event) {\n return this.validate_merchant(event.validationURL).then((merchant_session) => {\n merchant_session = JSON.parse(merchant_session);\n return this.session.completeMerchantValidation(merchant_session);\n }, (response) => {\n this.session.abort();\n return this.fail_payment('Merchant could no be validated. ' + response.message);\n });\n }\n\n validate_merchant(url) {\n return new Promise((resolve, reject) => {\n var data;\n data = {\n 'action': `wc_${this.gateway_id}_apple_pay_validate_merchant`,\n 'nonce': this.validate_nonce,\n 'merchant_id': this.merchant_id,\n 'url': url\n };\n // retrieve a payment request object\n return $.post(this.ajax_url, data, (response) => {\n if (response.success) {\n return resolve(response.data);\n } else {\n return reject(response.data);\n }\n });\n });\n }\n\n on_payment_method_selected(event) {\n return new Promise((resolve, reject) => {\n var data;\n data = {\n 'action': `wc_${this.gateway_id}_apple_pay_recalculate_totals`,\n 'nonce': this.recalculate_totals_nonce\n };\n // retrieve a payment request object\n return $.post(this.ajax_url, data, (response) => {\n if (response.success) {\n data = response.data;\n return resolve(this.session.completePaymentMethodSelection(data.total, data.line_items));\n } else {\n console.error('[Apple Pay] Error selecting a shipping contact. ' + response.data.message);\n return reject(this.session.completePaymentMethodSelection(this.payment_request.total, this.payment_request.lineItems));\n }\n });\n });\n }\n\n on_shipping_contact_selected(event) {\n return new Promise((resolve, reject) => {\n var data;\n data = {\n 'action': `wc_${this.gateway_id}_apple_pay_recalculate_totals`,\n 'nonce': this.recalculate_totals_nonce,\n 'contact': event.shippingContact\n };\n // retrieve a payment request object\n return $.post(this.ajax_url, data, (response) => {\n if (response.success) {\n data = response.data;\n return resolve(this.session.completeShippingContactSelection(ApplePaySession.STATUS_SUCCESS, data.shipping_methods, data.total, data.line_items));\n } else {\n console.error('[Apple Pay] Error selecting a shipping contact. ' + response.data.message);\n return reject(this.session.completeShippingContactSelection(ApplePaySession.STATUS_FAILURE, [], this.payment_request.total, this.payment_request.lineItems));\n }\n });\n });\n }\n\n on_shipping_method_selected(event) {\n return new Promise((resolve, reject) => {\n var data;\n data = {\n 'action': `wc_${this.gateway_id}_apple_pay_recalculate_totals`,\n 'nonce': this.recalculate_totals_nonce,\n 'method': event.shippingMethod.identifier\n };\n // retrieve a payment request object\n return $.post(this.ajax_url, data, (response) => {\n if (response.success) {\n data = response.data;\n return resolve(this.session.completeShippingMethodSelection(ApplePaySession.STATUS_SUCCESS, data.total, data.line_items));\n } else {\n console.error('[Apple Pay] Error selecting a shipping method. ' + response.data.message);\n return reject(this.session.completeShippingMethodSelection(ApplePaySession.STATUS_FAILURE, this.payment_request.total, this.payment_request.lineItems));\n }\n });\n });\n }\n\n on_payment_authorized(event) {\n return this.process_authorization(event.payment).then((response) => {\n this.set_payment_status(true);\n return this.complete_purchase(response);\n }, (response) => {\n this.set_payment_status(false);\n return this.fail_payment('Payment could no be processed. ' + response.message);\n });\n }\n\n process_authorization(payment) {\n return new Promise((resolve, reject) => {\n var data;\n data = {\n action: `wc_${this.gateway_id}_apple_pay_process_payment`,\n nonce: this.process_nonce,\n payment: JSON.stringify(payment)\n };\n return $.post(this.ajax_url, data, (response) => {\n if (response.success) {\n return resolve(response.data);\n } else {\n return reject(response.data);\n }\n });\n });\n }\n\n on_cancel_payment(event) {\n return this.unblock_ui();\n }\n\n // Completes the purchase based on the gateway result.\n\n // @since 4.7.0\n complete_purchase(response) {\n return window.location = response.redirect;\n }\n\n // Fails the purchase based on the gateway result.\n\n // @since 4.7.0\n fail_payment(error) {\n console.error('[Apple Pay] ' + error);\n this.unblock_ui();\n return this.render_errors([this.generic_error]);\n }\n\n // Sets the Apple Pay payment status depending on the gateway result.\n\n // @since 4.7.0\n set_payment_status(success) {\n var status;\n if (success) {\n status = ApplePaySession.STATUS_SUCCESS;\n } else {\n status = ApplePaySession.STATUS_FAILURE;\n }\n return this.session.completePayment(status);\n }\n\n reset_payment_request(data = {}) {\n this.block_ui();\n return this.get_payment_request(data).then((response) => {\n $(this.button).show();\n $(this.wrapper).show();\n this.payment_request = JSON.parse(response);\n return this.unblock_ui();\n }, (response) => {\n console.error('[Apple Pay] Could not build payment request. ' + response.message);\n $(this.button).hide();\n // hide the wrapper if Apple Pay is the only button\n if ($(this.container).children().length === 1) {\n $(this.wrapper).hide();\n }\n return this.unblock_ui();\n });\n }\n\n get_payment_request(data) {\n return new Promise((resolve, reject) => {\n var base_data;\n base_data = {\n 'action': `wc_${this.gateway_id}_apple_pay_get_payment_request`\n };\n $.extend(data, base_data);\n // retrieve a payment request object\n return $.post(this.ajax_url, data, (response) => {\n if (response.success) {\n return resolve(response.data);\n } else {\n return reject(response.data);\n }\n });\n });\n }\n\n // Renders any new errors and bring them into the viewport.\n\n // @since 4.7.0\n render_errors(errors) {\n // hide and remove any previous errors\n $('.woocommerce-error, .woocommerce-message').remove();\n // add errors\n this.ui_element.prepend('
    • ' + errors.join('
    • ') + '
    ');\n // unblock UI\n this.ui_element.removeClass('processing').unblock();\n // scroll to top\n return $('html, body').animate({\n scrollTop: this.ui_element.offset().top - 100\n }, 1000);\n }\n\n // Blocks the payment form UI.\n\n // @since 4.7.0\n block_ui() {\n return this.ui_element.block({\n message: null,\n overlayCSS: {\n background: '#fff',\n opacity: 0.6\n }\n });\n }\n\n // Unblocks the payment form UI.\n\n // @since 4.7.0\n unblock_ui() {\n return this.ui_element.unblock();\n }\n\n };\n // dispatch loaded event\n return $(document.body).trigger('sv_wc_apple_pay_handler_v5_14_0_loaded');\n });\n\n}).call(this);\n"]} diff --git a/woocommerce/payment-gateway/assets/dist/frontend/sv-wc-payment-gateway-google-pay.js b/woocommerce/payment-gateway/assets/dist/frontend/sv-wc-payment-gateway-google-pay.js index d4c8fb320..fe2d1bb11 100644 --- a/woocommerce/payment-gateway/assets/dist/frontend/sv-wc-payment-gateway-google-pay.js +++ b/woocommerce/payment-gateway/assets/dist/frontend/sv-wc-payment-gateway-google-pay.js @@ -1,4 +1,4 @@ parcelRequire=function(e,r,t,n){var i,o="function"==typeof parcelRequire&&parcelRequire,u="function"==typeof require&&require;function f(t,n){if(!r[t]){if(!e[t]){var i="function"==typeof parcelRequire&&parcelRequire;if(!n&&i)return i(t,!0);if(o)return o(t,!0);if(u&&"string"==typeof t)return u(t);var c=new Error("Cannot find module '"+t+"'");throw c.code="MODULE_NOT_FOUND",c}p.resolve=function(r){return e[t][1][r]||r},p.cache={};var l=r[t]=new f.Module(t);e[t][0].call(l.exports,p,l,l.exports,this)}return r[t].exports;function p(e){return f(p.resolve(e))}}f.isParcelRequire=!0,f.Module=function(e){this.id=e,this.bundle=f,this.exports={}},f.modules=e,f.cache=r,f.parent=o,f.register=function(r,t){e[r]=[function(e,r){r.exports=t},{}]};for(var c=0;c
  • '+t.join("
  • ")+"
  • "),this.uiElement.removeClass("processing").unblock(),e("html, body").animate({scrollTop:this.uiElement.offset().top-100},1e3)}},{key:"blockUI",value:function(){this.uiElement.block({message:null,overlayCSS:{background:"#fff",opacity:.6}})}},{key:"unblockUI",value:function(){this.uiElement.unblock()}}])}(),e(document.body).trigger("sv_wc_google_pay_handler_v5_13_1_loaded")}); +function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(t)}function t(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function n(e,t){for(var n=0;n
  • '+t.join("
  • ")+"
  • "),this.uiElement.removeClass("processing").unblock(),e("html, body").animate({scrollTop:this.uiElement.offset().top-100},1e3)}},{key:"blockUI",value:function(){this.uiElement.block({message:null,overlayCSS:{background:"#fff",opacity:.6}})}},{key:"unblockUI",value:function(){this.uiElement.unblock()}}])}(),e(document.body).trigger("sv_wc_google_pay_handler_v5_14_0_loaded")}); },{}]},{},["O8A1"], null) //# sourceMappingURL=../frontend/sv-wc-payment-gateway-google-pay.js.map diff --git a/woocommerce/payment-gateway/assets/dist/frontend/sv-wc-payment-gateway-google-pay.js.map b/woocommerce/payment-gateway/assets/dist/frontend/sv-wc-payment-gateway-google-pay.js.map index 4f62a31f6..d48c063f7 100644 --- a/woocommerce/payment-gateway/assets/dist/frontend/sv-wc-payment-gateway-google-pay.js.map +++ b/woocommerce/payment-gateway/assets/dist/frontend/sv-wc-payment-gateway-google-pay.js.map @@ -1 +1 @@ -{"version":3,"sources":["frontend/sv-wc-payment-gateway-google-pay.js"],"names":["jQuery","$","window","SV_WC_Google_Pay_Handler_v5_13_1","params","plugin_id","merchant_id","merchant_name","gateway_id","environment","gateway_id_dasherized","ajax_url","recalculate_totals_nonce","process_nonce","button_style","card_types","available_countries","currency_code","needs_shipping","generic_error","gatewayID","merchantID","merchantName","ajaxURL","recalculateTotalsNonce","processNonce","buttonStyle","availableCountries","currencyCode","needsShipping","genericError","product_id","productID","allowedCardNetworks","baseRequest","apiVersion","apiVersionMinor","allowedCardAuthMethods","tokenizationSpecification","type","parameters","baseCardPaymentMethod","allowedAuthMethods","billingAddressRequired","billingAddressParameters","format","phoneNumberRequired","cardPaymentMethod","Object","assign","paymentsClient","allowedPaymentMethods","resolve","getGoogleTransactionInfo","transactionInfo","paymentDataRequest","merchantInfo","merchantId","emailRequired","callbackIntents","shippingAddressRequired","shippingAddressParameters","getGoogleShippingAddressParameters","shippingOptionRequired","args","paymentDataCallbacks","onPaymentAuthorized","paymentData","onPaymentDataChanged","google","payments","api","PaymentsClient","blockUI","Promise","reject","processPayment","err","transactionState","error","intent","message","reason","unblockUI","intermediatePaymentData","shippingAddress","shippingOptionData","chosenShippingMethod","callbackTrigger","id","getUpdatedTotals","paymentDataRequestUpdate","newShippingOptionParameters","shippingOptions","length","getGoogleUnserviceableAddressError","failPayment","data","action","post","response","success","JSON","parse","shippingMethod","allowedCountryCodes","button","getGooglePaymentsClient","createButton","onClick","event","onGooglePaymentButtonClicked","buttonColor","buttonSizeMode","document","getElementById","appendChild","getGooglePaymentDataRequest","totalPriceStatus","prefetchPaymentData","nonce","stringify","location","redirect","preventDefault","loadPaymentData","initProductPage","initCartPage","initCheckoutPage","initGooglePay","isReadyToPay","getGoogleIsReadyToPayRequest","then","result","addGooglePayButton","prefetchGooglePaymentData","catch","uiElement","parents","body","on","console","renderErrors","errors","remove","prepend","join","removeClass","unblock","animate","scrollTop","offset","top","block","overlayCSS","background","opacity","trigger"],"mappings":";AAAA,SAAA,EAAA,GAAA,OAAA,EAAA,mBAAA,QAAA,iBAAA,OAAA,SAAA,SAAA,GAAA,cAAA,GAAA,SAAA,GAAA,OAAA,GAAA,mBAAA,QAAA,EAAA,cAAA,QAAA,IAAA,OAAA,UAAA,gBAAA,IAAA,GAAA,SAAA,EAAA,EAAA,GAAA,KAAA,aAAA,GAAA,MAAA,IAAA,UAAA,qCAAA,SAAA,EAAA,EAAA,GAAA,IAAA,IAAA,EAAA,EAAA,EAAA,EAAA,OAAA,IAAA,CAAA,IAAA,EAAA,EAAA,GAAA,EAAA,WAAA,EAAA,aAAA,EAAA,EAAA,cAAA,EAAA,UAAA,IAAA,EAAA,UAAA,GAAA,OAAA,eAAA,EAAA,EAAA,EAAA,KAAA,IAAA,SAAA,EAAA,EAAA,EAAA,GAAA,OAAA,GAAA,EAAA,EAAA,UAAA,GAAA,GAAA,EAAA,EAAA,GAAA,OAAA,eAAA,EAAA,YAAA,CAAA,UAAA,IAAA,EAAA,SAAA,EAAA,GAAA,IAAA,EAAA,EAAA,EAAA,UAAA,MAAA,UAAA,EAAA,GAAA,EAAA,EAAA,GAAA,SAAA,EAAA,EAAA,GAAA,GAAA,UAAA,EAAA,KAAA,EAAA,OAAA,EAAA,IAAA,EAAA,EAAA,OAAA,aAAA,QAAA,IAAA,EAAA,CAAA,IAAA,EAAA,EAAA,KAAA,EAAA,GAAA,WAAA,GAAA,UAAA,EAAA,GAAA,OAAA,EAAA,MAAA,IAAA,UAAA,gDAAA,OAAA,WAAA,EAAA,OAAA,QAAA,GAAAA,OAAQ,SAAUC,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GAwlBAnJ,EAAGiH,SAASyB,MAAOkB,QAAS","file":"sv-wc-payment-gateway-google-pay.js","sourceRoot":"../js","sourcesContent":["jQuery( function( $ ) {\n\n\t\"use strict\"\n\n\t/**\n\t * Google Pay handler.\n\t *\n\t * @since 5.10.0\n\t *\n\t * @type {SV_WC_Google_Pay_Handler_v5_13_1} object\n\t */\n\twindow.SV_WC_Google_Pay_Handler_v5_13_1 = class SV_WC_Google_Pay_Handler_v5_13_1 {\n\n\t\t/**\n\t\t * Handler constructor.\n\t\t *\n\t\t * @since 5.10.0\n\t\t *\n\t\t * @param {Object} params The plugin ID\n\t\t * @param {string} params.plugin_id The plugin ID\n\t\t * @param {string} params.merchant_id The merchant ID\n\t\t * @param {string} params.merchant_name The site name\n\t\t * @param {string} params.gateway_id The gateway ID\n\t\t * @param {string} params.gateway_id_dasherized The gateway ID dasherized\n\t\t * @param {string} params.environment The gateway environment (PRODUCTION or TEST)\n\t\t * @param {string} params.ajax_url The AJAX URL\n\t\t * @param {string} params.recalculate_totals_nonce Nonce for the recalculate_totals AJAX action\n\t\t * @param {string} params.process_nonce Nonce for the process AJAX action\n\t\t * @param {string} params.button_style The button style\n\t\t * @param {string[]} params.card_types The supported card types\n\t\t * @param {string[]} params.available_countries Array of two-letter country codes the gateway is available for\n\t\t * @param {string[]} params.currency_code WC configured currency\n\t\t * @param {boolean} params.needs_shipping Whether or not the cart or product needs shipping\n\t\t * @param {string} params.generic_error The generic error message\n\t\t * @param {string} params.product_id The product ID if we are on a Product page\n\t\t */\n\t\tconstructor( params ) {\n\n\t\t\tlet {\n\t\t\t\tplugin_id,\n\t\t\t\tmerchant_id,\n\t\t\t\tmerchant_name,\n\t\t\t\tgateway_id,\n\t\t\t\tgateway_id_dasherized,\n\t\t\t\tenvironment,\n\t\t\t\tajax_url,\n\t\t\t\trecalculate_totals_nonce,\n\t\t\t\tprocess_nonce,\n\t\t\t\tbutton_style,\n\t\t\t\tcard_types,\n\t\t\t\tavailable_countries,\n\t\t\t\tcurrency_code,\n\t\t\t\tneeds_shipping,\n\t\t\t\tgeneric_error\n\t\t\t} = params;\n\n\t\t\tthis.gatewayID = gateway_id;\n\t\t\tthis.merchantID = merchant_id;\n\t\t\tthis.merchantName = merchant_name;\n\t\t\tthis.environment = environment;\n\t\t\tthis.ajaxURL = ajax_url;\n\t\t\tthis.recalculateTotalsNonce = recalculate_totals_nonce;\n\t\t\tthis.processNonce = process_nonce;\n\t\t\tthis.buttonStyle = button_style;\n\t\t\tthis.availableCountries = available_countries;\n\t\t\tthis.currencyCode = currency_code;\n\t\t\tthis.needsShipping = needs_shipping;\n\t\t\tthis.genericError = generic_error;\n\n\t\t\tif ( params.product_id ) {\n\t\t\t\tthis.productID = params.product_id;\n\t\t\t}\n\n\t\t\t/**\n\t\t\t * Card networks supported by your site and your gateway\n\t\t\t *\n\t\t\t * @see {@link https://developers.google.com/pay/api/web/reference/request-objects#CardParameters|CardParameters}\n\t\t\t */\n\t\t\tconst allowedCardNetworks = card_types;\n\n\t\t\t/**\n\t\t\t * Define the version of the Google Pay API referenced when creating your configuration\n\t\t\t *\n\t\t\t * @see {@link https://developers.google.com/pay/api/web/reference/request-objects#PaymentDataRequest|apiVersion in PaymentDataRequest}\n\t\t\t */\n\t\t\tthis.baseRequest = {\n\t\t\t\tapiVersion: 2,\n\t\t\t\tapiVersionMinor: 0\n\t\t\t};\n\n\t\t\t/**\n\t\t\t * Card authentication methods supported by your site and your gateway\n\t\t\t *\n\t\t\t * @see {@link https://developers.google.com/pay/api/web/reference/request-objects#CardParameters|CardParameters}\n\t\t\t *\n\t\t\t * @todo confirm your processor supports Android device tokens for your supported card networks\n\t\t\t */\n\t\t\tconst allowedCardAuthMethods = [ 'PAN_ONLY', 'CRYPTOGRAM_3DS' ];\n\n\t\t\t/**\n\t\t\t * Identify your gateway and your site's gateway merchant identifier\n\t\t\t *\n\t\t\t * The Google Pay API response will return an encrypted payment method capable\n\t\t\t * of being charged by a supported gateway after payer authorization\n\t\t\t *\n\t\t\t * @see {@link https://developers.google.com/pay/api/web/reference/request-objects#gateway|PaymentMethodTokenizationSpecification}\n\t\t\t */\n\t\t\tconst tokenizationSpecification = {\n\t\t\t\ttype: 'PAYMENT_GATEWAY',\n\t\t\t\tparameters: {\n\t\t\t\t\t'gateway': plugin_id,\n\t\t\t\t\t'gatewayMerchantId': this.merchantID\n\t\t\t\t}\n\t\t\t};\n\n\t\t\t/**\n\t\t\t * Describe your site's support for the CARD payment method and its required fields\n\t\t\t *\n\t\t\t * @see {@link https://developers.google.com/pay/api/web/reference/request-objects#CardParameters|CardParameters}\n\t\t\t */\n\t\t\tthis.baseCardPaymentMethod = {\n\t\t\t\ttype: 'CARD',\n\t\t\t\tparameters: {\n\t\t\t\t\tallowedAuthMethods: allowedCardAuthMethods,\n\t\t\t\t\tallowedCardNetworks: allowedCardNetworks,\n\t\t\t\t\tbillingAddressRequired: true,\n\t\t\t\t\tbillingAddressParameters: {\n\t\t\t\t\t\tformat: 'FULL',\n\t\t\t\t\t\tphoneNumberRequired: true\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t};\n\n\t\t\t/**\n\t\t\t * Describe your site's support for the CARD payment method including optional fields\n\t\t\t *\n\t\t\t * @see {@link https://developers.google.com/pay/api/web/reference/request-objects#CardParameters|CardParameters}\n\t\t\t */\n\t\t\tthis.cardPaymentMethod = Object.assign(\n\t\t\t\t{},\n\t\t\t\tthis.baseCardPaymentMethod,\n\t\t\t\t{\n\t\t\t\t\ttokenizationSpecification: tokenizationSpecification\n\t\t\t\t}\n\t\t\t);\n\n\t\t\t/**\n\t\t\t * An initialized google.payments.api.PaymentsClient object or null if not yet set\n\t\t\t *\n\t\t\t * @see {@link getGooglePaymentsClient}\n\t\t\t */\n\t\t\tthis.paymentsClient = null;\n\t\t}\n\n\t\t/**\n\t\t * Configure your site's support for payment methods supported by the Google Pay\n\t\t * API.\n\t\t *\n\t\t * Each member of allowedPaymentMethods should contain only the required fields,\n\t\t * allowing reuse of this base request when determining a viewer's ability\n\t\t * to pay and later requesting a supported payment method\n\t\t *\n\t\t * @returns {object} Google Pay API version, payment methods supported by the site\n\t\t */\n\t\tgetGoogleIsReadyToPayRequest() {\n\n\t\t\treturn Object.assign(\n\t\t\t\t{},\n\t\t\t\tthis.baseRequest,\n\t\t\t\t{\n\t\t\t\t\tallowedPaymentMethods: [ this.baseCardPaymentMethod ]\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\n\t\t/**\n\t\t * Configure support for the Google Pay API\n\t\t *\n\t\t * @see {@link https://developers.google.com/pay/api/web/reference/request-objects#PaymentDataRequest|PaymentDataRequest}\n\t\t *\n\t\t * @param {function} resolve callback\n\t\t * @returns {object} PaymentDataRequest fields\n\t\t */\n\t\tgetGooglePaymentDataRequest( resolve ) {\n\n\t\t\treturn this.getGoogleTransactionInfo( ( transactionInfo ) => {\n\n\t\t\t\tconst paymentDataRequest = Object.assign( {}, this.baseRequest );\n\t\t\t\tpaymentDataRequest.allowedPaymentMethods = [ this.cardPaymentMethod ];\n\t\t\t\tpaymentDataRequest.transactionInfo = transactionInfo;\n\t\t\t\tpaymentDataRequest.merchantInfo = {\n\t\t\t\t\tmerchantId: this.merchantID,\n\t\t\t\t\tmerchantName: this.merchantName\n\t\t\t\t};\n\n\t\t\t\tpaymentDataRequest.emailRequired = true;\n\t\t\t\tpaymentDataRequest.callbackIntents = [ 'PAYMENT_AUTHORIZATION' ];\n\n\t\t\t\tif ( this.needsShipping ) {\n\t\t\t\t\tpaymentDataRequest.callbackIntents = [ 'SHIPPING_ADDRESS', 'SHIPPING_OPTION', 'PAYMENT_AUTHORIZATION' ];\n\t\t\t\t\tpaymentDataRequest.shippingAddressRequired = true;\n\t\t\t\t\tpaymentDataRequest.shippingAddressParameters = this.getGoogleShippingAddressParameters();\n\t\t\t\t\tpaymentDataRequest.shippingOptionRequired = true;\n\t\t\t\t}\n\n\t\t\t\tresolve( paymentDataRequest );\n\t\t\t} );\n\t\t}\n\n\t\t/**\n\t\t * Return an active PaymentsClient or initialize\n\t\t *\n\t\t * @see {@link https://developers.google.com/pay/api/web/reference/client#PaymentsClient|PaymentsClient constructor}\n\t\t * @returns {google.payments.api.PaymentsClient} Google Pay API client\n\t\t */\n\t\tgetGooglePaymentsClient() {\n\t\t\tif ( this.paymentsClient === null ) {\n\t\t\t\tlet args = {\n\t\t\t\t\tenvironment: this.environment,\n\t\t\t\t\tmerchantInfo: {\n\t\t\t\t\t\tmerchantName: this.merchantName,\n\t\t\t\t\t\tmerchantId: this.merchantID\n\t\t\t\t\t},\n\t\t\t\t\tpaymentDataCallbacks: {\n\t\t\t\t\t\tonPaymentAuthorized: ( paymentData ) => this.onPaymentAuthorized( paymentData ),\n\t\t\t\t\t}\n\t\t\t\t};\n\n\t\t\t\tif ( this.needsShipping ) {\n\t\t\t\t\targs.paymentDataCallbacks.onPaymentDataChanged = ( paymentData ) => this.onPaymentDataChanged( paymentData );\n\t\t\t\t}\n\n\t\t\t\tthis.paymentsClient = new google.payments.api.PaymentsClient( args );\n\t\t\t}\n\t\t\treturn this.paymentsClient;\n\t\t}\n\n\t\t/**\n\t\t * Handles payment authorization callback intent.\n\t\t *\n\t\t * @param {object} paymentData response from Google Pay API after a payer approves payment.\n\t\t * @see {@link https://developers.google.com/pay/api/web/reference/response-objects#PaymentData|PaymentData object reference}\n\t\t *\n\t\t * @returns Promise<{object}> Promise object to complete or fail the transaction.\n\t\t */\n\t\tonPaymentAuthorized( paymentData ) {\n\n\t\t\tthis.blockUI();\n\n\t\t\treturn new Promise( (resolve, reject) => {\n\n\t\t\t\t// handle the response\n\t\t\t\ttry {\n\t\t\t\t\tthis.processPayment( paymentData, resolve );\n\t\t\t\t}\tcatch( err ) {\n\t\t\t\t\treject( {\n\t\t\t\t\t\ttransactionState: 'ERROR',\n\t\t\t\t\t\terror: {\n\t\t\t\t\t\t\tintent: 'PAYMENT_AUTHORIZATION',\n\t\t\t\t\t\t\tmessage: 'Payment could not be processed',\n\t\t\t\t\t\t\treason: 'PAYMENT_DATA_INVALID'\n\t\t\t\t\t\t}\n\t\t\t\t\t} );\n\t\t\t\t}\n\n\t\t\t\tthis.unblockUI();\n\t\t\t} );\n\t\t}\n\n\t\t/**\n\t\t * Handles dynamic buy flow shipping address and shipping options callback intents.\n\t\t *\n\t\t * @param {object} intermediatePaymentData response from Google Pay API a shipping address or shipping option is selected in the payment sheet.\n\t\t * @see {@link https://developers.google.com/pay/api/web/reference/response-objects#IntermediatePaymentData|IntermediatePaymentData object reference}\n\t\t *\n\t\t * @see {@link https://developers.google.com/pay/api/web/reference/response-objects#PaymentDataRequestUpdate|PaymentDataRequestUpdate}\n\t\t * @returns Promise<{object}> Promise of PaymentDataRequestUpdate object to update the payment sheet.\n\t\t */\n\t\tonPaymentDataChanged( intermediatePaymentData ) {\n\n\t\t\tthis.blockUI();\n\n\t\t\treturn new Promise(( resolve, reject ) => {\n\n\t\t\t\ttry {\n\t\t\t\t\tlet shippingAddress = intermediatePaymentData.shippingAddress;\n\t\t\t\t\tlet shippingOptionData = intermediatePaymentData.shippingOptionData;\n\t\t\t\t\tlet chosenShippingMethod = '';\n\n\t\t\t\t\tif ( intermediatePaymentData.callbackTrigger == 'SHIPPING_OPTION' ) {\n\t\t\t\t\t\tchosenShippingMethod = shippingOptionData.id;\n\t\t\t\t\t}\n\n\t\t\t\t\tthis.getUpdatedTotals( shippingAddress, chosenShippingMethod, ( paymentDataRequestUpdate ) => {\n\n\t\t\t\t\t\tif ( paymentDataRequestUpdate.newShippingOptionParameters.shippingOptions.length == 0 ) {\n\t\t\t\t\t\t\tpaymentDataRequestUpdate = {\n\t\t\t\t\t\t\t\terror: this.getGoogleUnserviceableAddressError()\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tresolve( paymentDataRequestUpdate );\n\t\t\t\t\t} );\n\n\t\t\t\t}\tcatch( err ) {\n\t\t\t\t\tthis.failPayment( 'Could not load updated totals or process payment data request update. ' + err );\n\t\t\t\t}\n\n\t\t\t\tthis.unblockUI();\n\t\t\t} );\n\t\t}\n\n\t\t/**\n\t\t * Provide Google Pay API with a payment amount, currency, and amount status\n\t\t *\n\t\t * @see {@link https://developers.google.com/pay/api/web/reference/request-objects#TransactionInfo|TransactionInfo}\n\t\t *\n\t\t * @param {function} resolve callback\n\t\t * @returns {object} transaction info, suitable for use as transactionInfo property of PaymentDataRequest\n\t\t */\n\t\tgetGoogleTransactionInfo( resolve ) {\n\n\t\t\t// get transaction info from cart\n\t\t\tconst data = {\n\t\t\t\taction: `wc_${this.gatewayID}_google_pay_get_transaction_info`,\n\t\t\t}\n\n\t\t\tif ( this.productID ) {\n\t\t\t\tdata.productID = this.productID;\n\t\t\t}\n\n\t\t\t$.post( this.ajaxURL, data, ( response ) => {\n\n\t\t\t\tif ( response.success ) {\n\t\t\t\t\tresolve( JSON.parse( response.data ) )\n\t\t\t\t} else {\n\t\t\t\t\tthis.failPayment( 'Could not build transaction info. ' + response.data.message );\n\t\t\t\t}\n\t\t\t} );\n\t\t}\n\n\t\t/**\n\t\t * Get updated totals and shipping options via AJAX for use in the PaymentDataRequest\n\t\t *\n\t\t * @see {@link https://developers.google.com/pay/api/web/reference/response-objects#PaymentDataRequestUpdate|PaymentDataRequestUpdate}\n\t\t *\n\t\t * @param {object} shippingAddress shipping address\n\t\t * @param {object} shippingMethod chosen shipping method\n\t\t * @param {function} resolve callback\n\t\t */\n\t\tgetUpdatedTotals( shippingAddress, shippingMethod, resolve ) {\n\n\t\t\tconst data = {\n\t\t\t\taction: `wc_${this.gatewayID}_google_pay_recalculate_totals`,\n\t\t\t\t'nonce': this.recalculateTotalsNonce,\n\t\t\t\tshippingAddress,\n\t\t\t\tshippingMethod\n\t\t\t}\n\n\t\t\tif ( this.productID ) {\n\t\t\t\tdata.productID = this.productID;\n\t\t\t}\n\n\t\t\t$.post( this.ajaxURL, data, ( response ) => {\n\n\t\t\t\tif ( response.success ) {\n\t\t\t\t\tresolve( JSON.parse( response.data ) )\n\t\t\t\t} else {\n\t\t\t\t\tthis.failPayment( 'Could not recalculate totals. ' + response.data.message );\n\t\t\t\t}\n\t\t\t} );\n\t\t}\n\n\t\t/**\n\t\t * Provide Google Pay API with shipping address parameters when using dynamic buy flow.\n\t\t *\n\t\t * @see {@link https://developers.google.com/pay/api/web/reference/request-objects#ShippingAddressParameters|ShippingAddressParameters}\n\t\t * @returns {object} shipping address details, suitable for use as shippingAddressParameters property of PaymentDataRequest\n\t\t */\n\t\tgetGoogleShippingAddressParameters() {\n\n\t\t\treturn {\n\t\t\t\tallowedCountryCodes: this.availableCountries\n\t\t\t};\n\t\t}\n\n\t\t/**\n\t\t * Provide Google Pay API with a payment data error.\n\t\t *\n\t\t * @see {@link https://developers.google.com/pay/api/web/reference/response-objects#PaymentDataError|PaymentDataError}\n\t\t * @returns {object} payment data error, suitable for use as error property of PaymentDataRequestUpdate\n\t\t */\n\t\tgetGoogleUnserviceableAddressError() {\n\t\t\treturn {\n\t\t\t\treason: 'SHIPPING_ADDRESS_UNSERVICEABLE',\n\t\t\t\tmessage: 'Cannot ship to the selected address',\n\t\t\t\tintent: 'SHIPPING_ADDRESS'\n\t\t\t};\n\t\t}\n\n\t\t/**\n\t\t * Add a Google Pay purchase button alongside an existing checkout button\n\t\t *\n\t\t * @see {@link https://developers.google.com/pay/api/web/reference/request-objects#ButtonOptions|Button options}\n\t\t * @see {@link https://developers.google.com/pay/api/web/guides/brand-guidelines|Google Pay brand guidelines}\n\t\t */\n\t\taddGooglePayButton() {\n\n\t\t\tconst paymentsClient = this.getGooglePaymentsClient();\n\t\t\tconst button = paymentsClient.createButton( {\n\t\t\t\tonClick: ( event ) => this.onGooglePaymentButtonClicked( event ),\n\t\t\t\tbuttonColor: this.buttonStyle,\n\t\t\t\tbuttonSizeMode: 'fill'\n\t\t\t} );\n\t\t\tdocument.getElementById( 'sv-wc-google-pay-button-container' ).appendChild( button );\n\t\t}\n\n\t\t/**\n\t\t * Prefetch payment data to improve performance\n\t\t *\n\t\t * @see {@link https://developers.google.com/pay/api/web/reference/client#prefetchPaymentData|prefetchPaymentData()}\n\t\t */\n\t\tprefetchGooglePaymentData() {\n\n\t\t\tthis.getGooglePaymentDataRequest( ( paymentDataRequest ) => {\n\n\t\t\t\t// transactionInfo must be set but does not affect cache\n\t\t\t\tpaymentDataRequest.transactionInfo = {\n\t\t\t\t\ttotalPriceStatus: 'NOT_CURRENTLY_KNOWN',\n\t\t\t\t\tcurrencyCode: this.currencyCode\n\t\t\t\t};\n\t\t\t\tconst paymentsClient = this.getGooglePaymentsClient();\n\t\t\t\tpaymentsClient.prefetchPaymentData( paymentDataRequest );\n\t\t\t} );\n\t\t}\n\n\t\t/**\n\t\t * Process payment data returned by the Google Pay API\n\t\t *\n\t\t * @see {@link https://developers.google.com/pay/api/web/reference/response-objects#PaymentData|PaymentData object reference}\n\t\t *\n\t\t * @param {object} paymentData response from Google Pay API after user approves payment\n\t\t * @param {function} resolve callback\n\t\t */\n\t\tprocessPayment( paymentData, resolve ) {\n\n\t\t\t// pass payment token to your gateway to process payment\n\t\t\tconst data = {\n\t\t\t\taction: `wc_${this.gatewayID}_google_pay_process_payment`,\n\t\t\t\tnonce: this.processNonce,\n\t\t\t\tpaymentData: JSON.stringify( paymentData ),\n\t\t\t}\n\n\t\t\tif ( this.productID && ! this.needsShipping ) {\n\t\t\t\tdata.productID = this.productID;\n\t\t\t}\n\n\t\t\treturn $.post( this.ajaxURL, data, ( response ) => {\n\t\t\t\tif ( response.success ) {\n\t\t\t\t\tresolve( {\n\t\t\t\t\t\ttransactionState: 'SUCCESS'\n\t\t\t\t\t} );\n\t\t\t\t\twindow.location = response.data.redirect;\n\t\t\t\t} else {\n\t\t\t\t\tresolve( {\n\t\t\t\t\t\ttransactionState: 'ERROR',\n\t\t\t\t\t\terror: {\n\t\t\t\t\t\t\tintent: 'SHIPPING_ADDRESS',\n\t\t\t\t\t\t\tmessage: 'Invalid data',\n\t\t\t\t\t\t\treason: 'PAYMENT_DATA_INVALID'\n\t\t\t\t\t\t}\n\t\t\t\t\t} );\n\t\t\t\t\tthis.failPayment( 'Payment could not be processed. ' + response.data.message );\n\t\t\t\t}\n\t\t\t} );\n\t\t}\n\n\t\t/**\n\t\t * Show Google Pay payment sheet when Google Pay payment button is clicked\n\t\t */\n\t\tonGooglePaymentButtonClicked( event ) {\n\n\t\t\tevent.preventDefault();\n\n\t\t\tthis.blockUI();\n\n\t\t\tthis.getGooglePaymentDataRequest( ( paymentDataRequest ) => {\n\n\t\t\t\tconst paymentsClient = this.getGooglePaymentsClient();\n\t\t\t\ttry {\n\t\t\t\t\tpaymentsClient.loadPaymentData( paymentDataRequest );\n\t\t\t\t} catch ( err ) {\n\t\t\t\t\tthis.failPayment( 'Could not load payment data. ' + err );\n\t\t\t\t}\n\n\t\t\t\tthis.unblockUI();\n\t\t\t} );\n\t\t}\n\n\t\t/**\n\t\t * Initialize Google PaymentsClient after Google-hosted JavaScript has loaded\n\t\t *\n\t\t * Display a Google Pay payment button after confirmation of the viewer's\n\t\t * ability to pay.\n\t\t */\n\t\tinit() {\n\n\t\t\t// initialize for the various pages\n\t\t\tif ( $( 'form.cart' ).length ) {\n\t\t\t\tthis.initProductPage();\n\t\t\t} else if ( $( 'form.woocommerce-cart-form' ).length ) {\n\t\t\t\tthis.initCartPage();\n\t\t\t} else if ( $( 'form.woocommerce-checkout' ).length) {\n\t\t\t\tthis.initCheckoutPage()\n\t\t\t} else {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tthis.initGooglePay();\n\t\t}\n\n\t\t/**\n\t\t * Initializes Google Pay.\n\t\t */\n\t\tinitGooglePay() {\n\n\t\t\tconst paymentsClient = this.getGooglePaymentsClient();\n\t\t\tpaymentsClient.isReadyToPay( this.getGoogleIsReadyToPayRequest() )\n\t\t\t\t.then( ( response ) => {\n\t\t\t\t\tif ( response.result ) {\n\t\t\t\t\t\tthis.addGooglePayButton();\n\t\t\t\t\t\t// prefetch payment data to improve performance\n\t\t\t\t\t\tthis.prefetchGooglePaymentData();\n\t\t\t\t\t}\n\t\t\t\t} )\n\t\t\t\t.catch( ( err ) => {\n\t\t\t\t\tthis.failPayment( 'Google Pay is not ready. ' + err );\n\t\t\t\t} );\n\t\t}\n\n\t\t/**\n\t\t * Initializes the product page.\n\t\t */\n\t\tinitProductPage() {\n\t\t\tthis.uiElement = $( 'form.cart' );\n\t\t}\n\n\t\t/**\n\t\t * Initializes the cart page.\n\t\t */\n\t\tinitCartPage() {\n\t\t\tthis.uiElement = $( 'form.woocommerce-cart-form' ).parents( 'div.woocommerce' );\n\n\t\t\t// re-init if the cart totals are updated\n\t\t\t$( document.body ).on( 'updated_cart_totals', () => {\n\t\t\t\tthis.initGooglePay();\n\t\t\t} );\n\t\t}\n\n\t\t/**\n\t\t * Initializes the checkout page.\n\t\t */\n\t\tinitCheckoutPage() {\n\t\t\tthis.uiElement = $( 'form.woocommerce-checkout' );\n\t\t}\n\n\t\t/**\n\t\t * Fails the purchase based on the gateway result.\n\t\t */\n\t\tfailPayment( error ) {\n\n\t\t\tconsole.error( '[Google Pay] ' + error );\n\n\t\t\tthis.unblockUI();\n\n\t\t\tthis.renderErrors( [ this.genericError ] );\n\t\t}\n\n\t\t/**\n\t\t * Renders any new errors and bring them into the viewport.\n \t\t */\n\t\trenderErrors( errors ) {\n\n\t\t\t// hide and remove any previous errors\n\t\t\t$( '.woocommerce-error, .woocommerce-message' ).remove();\n\n\t\t\t// add errors\n\t\t\tthis.uiElement.prepend( '
    • ' + errors.join( '
    • ' ) + '
    ' );\n\n\t\t\t// unblock UI\n\t\t\tthis.uiElement.removeClass( 'processing' ).unblock();\n\n\t\t\t// scroll to top\n\t\t\t$( 'html, body' ).animate( { scrollTop: this.uiElement.offset().top - 100 }, 1000 );\n\t\t}\n\n\t\t/**\n\t\t * Blocks the payment form UI.\n\t\t */\n\t\tblockUI() {\n\t\t\tthis.uiElement.block( { message: null, overlayCSS: { background: '#fff', opacity: 0.6 } } );\n\t\t}\n\n\t\t/**\n\t\t * Unblocks the payment form UI.\n\t\t */\n\t\tunblockUI() {\n\t\t\tthis.uiElement.unblock();\n\t\t}\n\t}\n\n\t$( document.body ).trigger( 'sv_wc_google_pay_handler_v5_13_1_loaded' );\n\n} );\n"]} +{"version":3,"sources":["frontend/sv-wc-payment-gateway-google-pay.js"],"names":["jQuery","$","window","SV_WC_Google_Pay_Handler_v5_14_0","params","plugin_id","merchant_id","merchant_name","gateway_id","environment","gateway_id_dasherized","ajax_url","recalculate_totals_nonce","process_nonce","button_style","card_types","available_countries","currency_code","needs_shipping","generic_error","gatewayID","merchantID","merchantName","ajaxURL","recalculateTotalsNonce","processNonce","buttonStyle","availableCountries","currencyCode","needsShipping","genericError","product_id","productID","allowedCardNetworks","baseRequest","apiVersion","apiVersionMinor","allowedCardAuthMethods","tokenizationSpecification","type","parameters","baseCardPaymentMethod","allowedAuthMethods","billingAddressRequired","billingAddressParameters","format","phoneNumberRequired","cardPaymentMethod","Object","assign","paymentsClient","allowedPaymentMethods","resolve","getGoogleTransactionInfo","transactionInfo","paymentDataRequest","merchantInfo","merchantId","emailRequired","callbackIntents","shippingAddressRequired","shippingAddressParameters","getGoogleShippingAddressParameters","shippingOptionRequired","args","paymentDataCallbacks","onPaymentAuthorized","paymentData","onPaymentDataChanged","google","payments","api","PaymentsClient","blockUI","Promise","reject","processPayment","err","transactionState","error","intent","message","reason","unblockUI","intermediatePaymentData","shippingAddress","shippingOptionData","chosenShippingMethod","callbackTrigger","id","getUpdatedTotals","paymentDataRequestUpdate","newShippingOptionParameters","shippingOptions","length","getGoogleUnserviceableAddressError","failPayment","data","action","post","response","success","JSON","parse","shippingMethod","allowedCountryCodes","button","getGooglePaymentsClient","createButton","onClick","event","onGooglePaymentButtonClicked","buttonColor","buttonSizeMode","document","getElementById","appendChild","getGooglePaymentDataRequest","totalPriceStatus","prefetchPaymentData","nonce","stringify","location","redirect","preventDefault","loadPaymentData","initProductPage","initCartPage","initCheckoutPage","initGooglePay","isReadyToPay","getGoogleIsReadyToPayRequest","then","result","addGooglePayButton","prefetchGooglePaymentData","catch","uiElement","parents","body","on","console","renderErrors","errors","remove","prepend","join","removeClass","unblock","animate","scrollTop","offset","top","block","overlayCSS","background","opacity","trigger"],"mappings":";AAAA,SAAA,EAAA,GAAA,OAAA,EAAA,mBAAA,QAAA,iBAAA,OAAA,SAAA,SAAA,GAAA,cAAA,GAAA,SAAA,GAAA,OAAA,GAAA,mBAAA,QAAA,EAAA,cAAA,QAAA,IAAA,OAAA,UAAA,gBAAA,IAAA,GAAA,SAAA,EAAA,EAAA,GAAA,KAAA,aAAA,GAAA,MAAA,IAAA,UAAA,qCAAA,SAAA,EAAA,EAAA,GAAA,IAAA,IAAA,EAAA,EAAA,EAAA,EAAA,OAAA,IAAA,CAAA,IAAA,EAAA,EAAA,GAAA,EAAA,WAAA,EAAA,aAAA,EAAA,EAAA,cAAA,EAAA,UAAA,IAAA,EAAA,UAAA,GAAA,OAAA,eAAA,EAAA,EAAA,EAAA,KAAA,IAAA,SAAA,EAAA,EAAA,EAAA,GAAA,OAAA,GAAA,EAAA,EAAA,UAAA,GAAA,GAAA,EAAA,EAAA,GAAA,OAAA,eAAA,EAAA,YAAA,CAAA,UAAA,IAAA,EAAA,SAAA,EAAA,GAAA,IAAA,EAAA,EAAA,EAAA,UAAA,MAAA,UAAA,EAAA,GAAA,EAAA,EAAA,GAAA,SAAA,EAAA,EAAA,GAAA,GAAA,UAAA,EAAA,KAAA,EAAA,OAAA,EAAA,IAAA,EAAA,EAAA,OAAA,aAAA,QAAA,IAAA,EAAA,CAAA,IAAA,EAAA,EAAA,KAAA,EAAA,GAAA,WAAA,GAAA,UAAA,EAAA,GAAA,OAAA,EAAA,MAAA,IAAA,UAAA,gDAAA,OAAA,WAAA,EAAA,OAAA,QAAA,GAAAA,OAAQ,SAAUC,GAEjB,aASAC,OAAOC,iCAAP,WAAA,OAAA,EAyBcC,SAAAA,EAAAA,GAAS,EAAA,KAAA,GAGpBC,IAAAA,EAeGD,EAfHC,UACAC,EAcGF,EAdHE,YACAC,EAaG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pay handler.\n\t *\n\t * @since 5.10.0\n\t *\n\t * @type {SV_WC_Google_Pay_Handler_v5_14_0} object\n\t */\n\twindow.SV_WC_Google_Pay_Handler_v5_14_0 = class SV_WC_Google_Pay_Handler_v5_14_0 {\n\n\t\t/**\n\t\t * Handler constructor.\n\t\t *\n\t\t * @since 5.10.0\n\t\t *\n\t\t * @param {Object} params The plugin ID\n\t\t * @param {string} params.plugin_id The plugin ID\n\t\t * @param {string} params.merchant_id The merchant ID\n\t\t * @param {string} params.merchant_name The site name\n\t\t * @param {string} params.gateway_id The gateway ID\n\t\t * @param {string} params.gateway_id_dasherized The gateway ID dasherized\n\t\t * @param {string} params.environment The gateway environment (PRODUCTION or TEST)\n\t\t * @param {string} params.ajax_url The AJAX URL\n\t\t * @param {string} params.recalculate_totals_nonce Nonce for the recalculate_totals AJAX action\n\t\t * @param {string} params.process_nonce Nonce for the process AJAX action\n\t\t * @param {string} params.button_style The button style\n\t\t * @param {string[]} params.card_types The supported card types\n\t\t * @param {string[]} params.available_countries Array of two-letter country codes the gateway is available for\n\t\t * @param {string[]} params.currency_code WC configured currency\n\t\t * @param {boolean} params.needs_shipping Whether or not the cart or product needs shipping\n\t\t * @param {string} params.generic_error The generic error message\n\t\t * @param {string} params.product_id The product ID if we are on a Product page\n\t\t */\n\t\tconstructor( params ) {\n\n\t\t\tlet {\n\t\t\t\tplugin_id,\n\t\t\t\tmerchant_id,\n\t\t\t\tmerchant_name,\n\t\t\t\tgateway_id,\n\t\t\t\tgateway_id_dasherized,\n\t\t\t\tenvironment,\n\t\t\t\tajax_url,\n\t\t\t\trecalculate_totals_nonce,\n\t\t\t\tprocess_nonce,\n\t\t\t\tbutton_style,\n\t\t\t\tcard_types,\n\t\t\t\tavailable_countries,\n\t\t\t\tcurrency_code,\n\t\t\t\tneeds_shipping,\n\t\t\t\tgeneric_error\n\t\t\t} = params;\n\n\t\t\tthis.gatewayID = gateway_id;\n\t\t\tthis.merchantID = merchant_id;\n\t\t\tthis.merchantName = merchant_name;\n\t\t\tthis.environment = environment;\n\t\t\tthis.ajaxURL = ajax_url;\n\t\t\tthis.recalculateTotalsNonce = recalculate_totals_nonce;\n\t\t\tthis.processNonce = process_nonce;\n\t\t\tthis.buttonStyle = button_style;\n\t\t\tthis.availableCountries = available_countries;\n\t\t\tthis.currencyCode = currency_code;\n\t\t\tthis.needsShipping = needs_shipping;\n\t\t\tthis.genericError = generic_error;\n\n\t\t\tif ( params.product_id ) {\n\t\t\t\tthis.productID = params.product_id;\n\t\t\t}\n\n\t\t\t/**\n\t\t\t * Card networks supported by your site and your gateway\n\t\t\t *\n\t\t\t * @see {@link https://developers.google.com/pay/api/web/reference/request-objects#CardParameters|CardParameters}\n\t\t\t */\n\t\t\tconst allowedCardNetworks = card_types;\n\n\t\t\t/**\n\t\t\t * Define the version of the Google Pay API referenced when creating your configuration\n\t\t\t *\n\t\t\t * @see {@link https://developers.google.com/pay/api/web/reference/request-objects#PaymentDataRequest|apiVersion in PaymentDataRequest}\n\t\t\t */\n\t\t\tthis.baseRequest = {\n\t\t\t\tapiVersion: 2,\n\t\t\t\tapiVersionMinor: 0\n\t\t\t};\n\n\t\t\t/**\n\t\t\t * Card authentication methods supported by your site and your gateway\n\t\t\t *\n\t\t\t * @see {@link https://developers.google.com/pay/api/web/reference/request-objects#CardParameters|CardParameters}\n\t\t\t *\n\t\t\t * @todo confirm your processor supports Android device tokens for your supported card networks\n\t\t\t */\n\t\t\tconst allowedCardAuthMethods = [ 'PAN_ONLY', 'CRYPTOGRAM_3DS' ];\n\n\t\t\t/**\n\t\t\t * Identify your gateway and your site's gateway merchant identifier\n\t\t\t *\n\t\t\t * The Google Pay API response will return an encrypted payment method capable\n\t\t\t * of being charged by a supported gateway after payer authorization\n\t\t\t *\n\t\t\t * @see {@link https://developers.google.com/pay/api/web/reference/request-objects#gateway|PaymentMethodTokenizationSpecification}\n\t\t\t */\n\t\t\tconst tokenizationSpecification = {\n\t\t\t\ttype: 'PAYMENT_GATEWAY',\n\t\t\t\tparameters: {\n\t\t\t\t\t'gateway': plugin_id,\n\t\t\t\t\t'gatewayMerchantId': this.merchantID\n\t\t\t\t}\n\t\t\t};\n\n\t\t\t/**\n\t\t\t * Describe your site's support for the CARD payment method and its required fields\n\t\t\t *\n\t\t\t * @see {@link https://developers.google.com/pay/api/web/reference/request-objects#CardParameters|CardParameters}\n\t\t\t */\n\t\t\tthis.baseCardPaymentMethod = {\n\t\t\t\ttype: 'CARD',\n\t\t\t\tparameters: {\n\t\t\t\t\tallowedAuthMethods: allowedCardAuthMethods,\n\t\t\t\t\tallowedCardNetworks: allowedCardNetworks,\n\t\t\t\t\tbillingAddressRequired: true,\n\t\t\t\t\tbillingAddressParameters: {\n\t\t\t\t\t\tformat: 'FULL',\n\t\t\t\t\t\tphoneNumberRequired: true\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t};\n\n\t\t\t/**\n\t\t\t * Describe your site's support for the CARD payment method including optional fields\n\t\t\t *\n\t\t\t * @see {@link https://developers.google.com/pay/api/web/reference/request-objects#CardParameters|CardParameters}\n\t\t\t */\n\t\t\tthis.cardPaymentMethod = Object.assign(\n\t\t\t\t{},\n\t\t\t\tthis.baseCardPaymentMethod,\n\t\t\t\t{\n\t\t\t\t\ttokenizationSpecification: tokenizationSpecification\n\t\t\t\t}\n\t\t\t);\n\n\t\t\t/**\n\t\t\t * An initialized google.payments.api.PaymentsClient object or null if not yet set\n\t\t\t *\n\t\t\t * @see {@link getGooglePaymentsClient}\n\t\t\t */\n\t\t\tthis.paymentsClient = null;\n\t\t}\n\n\t\t/**\n\t\t * Configure your site's support for payment methods supported by the Google Pay\n\t\t * API.\n\t\t *\n\t\t * Each member of allowedPaymentMethods should contain only the required fields,\n\t\t * allowing reuse of this base request when determining a viewer's ability\n\t\t * to pay and later requesting a supported payment method\n\t\t *\n\t\t * @returns {object} Google Pay API version, payment methods supported by the site\n\t\t */\n\t\tgetGoogleIsReadyToPayRequest() {\n\n\t\t\treturn Object.assign(\n\t\t\t\t{},\n\t\t\t\tthis.baseRequest,\n\t\t\t\t{\n\t\t\t\t\tallowedPaymentMethods: [ this.baseCardPaymentMethod ]\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\n\t\t/**\n\t\t * Configure support for the Google Pay API\n\t\t *\n\t\t * @see {@link https://developers.google.com/pay/api/web/reference/request-objects#PaymentDataRequest|PaymentDataRequest}\n\t\t *\n\t\t * @param {function} resolve callback\n\t\t * @returns {object} PaymentDataRequest fields\n\t\t */\n\t\tgetGooglePaymentDataRequest( resolve ) {\n\n\t\t\treturn this.getGoogleTransactionInfo( ( transactionInfo ) => {\n\n\t\t\t\tconst paymentDataRequest = Object.assign( {}, this.baseRequest );\n\t\t\t\tpaymentDataRequest.allowedPaymentMethods = [ this.cardPaymentMethod ];\n\t\t\t\tpaymentDataRequest.transactionInfo = transactionInfo;\n\t\t\t\tpaymentDataRequest.merchantInfo = {\n\t\t\t\t\tmerchantId: this.merchantID,\n\t\t\t\t\tmerchantName: this.merchantName\n\t\t\t\t};\n\n\t\t\t\tpaymentDataRequest.emailRequired = true;\n\t\t\t\tpaymentDataRequest.callbackIntents = [ 'PAYMENT_AUTHORIZATION' ];\n\n\t\t\t\tif ( this.needsShipping ) {\n\t\t\t\t\tpaymentDataRequest.callbackIntents = [ 'SHIPPING_ADDRESS', 'SHIPPING_OPTION', 'PAYMENT_AUTHORIZATION' ];\n\t\t\t\t\tpaymentDataRequest.shippingAddressRequired = true;\n\t\t\t\t\tpaymentDataRequest.shippingAddressParameters = this.getGoogleShippingAddressParameters();\n\t\t\t\t\tpaymentDataRequest.shippingOptionRequired = true;\n\t\t\t\t}\n\n\t\t\t\tresolve( paymentDataRequest );\n\t\t\t} );\n\t\t}\n\n\t\t/**\n\t\t * Return an active PaymentsClient or initialize\n\t\t *\n\t\t * @see {@link https://developers.google.com/pay/api/web/reference/client#PaymentsClient|PaymentsClient constructor}\n\t\t * @returns {google.payments.api.PaymentsClient} Google Pay API client\n\t\t */\n\t\tgetGooglePaymentsClient() {\n\t\t\tif ( this.paymentsClient === null ) {\n\t\t\t\tlet args = {\n\t\t\t\t\tenvironment: this.environment,\n\t\t\t\t\tmerchantInfo: {\n\t\t\t\t\t\tmerchantName: this.merchantName,\n\t\t\t\t\t\tmerchantId: this.merchantID\n\t\t\t\t\t},\n\t\t\t\t\tpaymentDataCallbacks: {\n\t\t\t\t\t\tonPaymentAuthorized: ( paymentData ) => this.onPaymentAuthorized( paymentData ),\n\t\t\t\t\t}\n\t\t\t\t};\n\n\t\t\t\tif ( this.needsShipping ) {\n\t\t\t\t\targs.paymentDataCallbacks.onPaymentDataChanged = ( paymentData ) => this.onPaymentDataChanged( paymentData );\n\t\t\t\t}\n\n\t\t\t\tthis.paymentsClient = new google.payments.api.PaymentsClient( args );\n\t\t\t}\n\t\t\treturn this.paymentsClient;\n\t\t}\n\n\t\t/**\n\t\t * Handles payment authorization callback intent.\n\t\t *\n\t\t * @param {object} paymentData response from Google Pay API after a payer approves payment.\n\t\t * @see {@link https://developers.google.com/pay/api/web/reference/response-objects#PaymentData|PaymentData object reference}\n\t\t *\n\t\t * @returns Promise<{object}> Promise object to complete or fail the transaction.\n\t\t */\n\t\tonPaymentAuthorized( paymentData ) {\n\n\t\t\tthis.blockUI();\n\n\t\t\treturn new Promise( (resolve, reject) => {\n\n\t\t\t\t// handle the response\n\t\t\t\ttry {\n\t\t\t\t\tthis.processPayment( paymentData, resolve );\n\t\t\t\t}\tcatch( err ) {\n\t\t\t\t\treject( {\n\t\t\t\t\t\ttransactionState: 'ERROR',\n\t\t\t\t\t\terror: {\n\t\t\t\t\t\t\tintent: 'PAYMENT_AUTHORIZATION',\n\t\t\t\t\t\t\tmessage: 'Payment could not be processed',\n\t\t\t\t\t\t\treason: 'PAYMENT_DATA_INVALID'\n\t\t\t\t\t\t}\n\t\t\t\t\t} );\n\t\t\t\t}\n\n\t\t\t\tthis.unblockUI();\n\t\t\t} );\n\t\t}\n\n\t\t/**\n\t\t * Handles dynamic buy flow shipping address and shipping options callback intents.\n\t\t *\n\t\t * @param {object} intermediatePaymentData response from Google Pay API a shipping address or shipping option is selected in the payment sheet.\n\t\t * @see {@link https://developers.google.com/pay/api/web/reference/response-objects#IntermediatePaymentData|IntermediatePaymentData object reference}\n\t\t *\n\t\t * @see {@link https://developers.google.com/pay/api/web/reference/response-objects#PaymentDataRequestUpdate|PaymentDataRequestUpdate}\n\t\t * @returns Promise<{object}> Promise of PaymentDataRequestUpdate object to update the payment sheet.\n\t\t */\n\t\tonPaymentDataChanged( intermediatePaymentData ) {\n\n\t\t\tthis.blockUI();\n\n\t\t\treturn new Promise(( resolve, reject ) => {\n\n\t\t\t\ttry {\n\t\t\t\t\tlet shippingAddress = intermediatePaymentData.shippingAddress;\n\t\t\t\t\tlet shippingOptionData = intermediatePaymentData.shippingOptionData;\n\t\t\t\t\tlet chosenShippingMethod = '';\n\n\t\t\t\t\tif ( intermediatePaymentData.callbackTrigger == 'SHIPPING_OPTION' ) {\n\t\t\t\t\t\tchosenShippingMethod = shippingOptionData.id;\n\t\t\t\t\t}\n\n\t\t\t\t\tthis.getUpdatedTotals( shippingAddress, chosenShippingMethod, ( paymentDataRequestUpdate ) => {\n\n\t\t\t\t\t\tif ( paymentDataRequestUpdate.newShippingOptionParameters.shippingOptions.length == 0 ) {\n\t\t\t\t\t\t\tpaymentDataRequestUpdate = {\n\t\t\t\t\t\t\t\terror: this.getGoogleUnserviceableAddressError()\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tresolve( paymentDataRequestUpdate );\n\t\t\t\t\t} );\n\n\t\t\t\t}\tcatch( err ) {\n\t\t\t\t\tthis.failPayment( 'Could not load updated totals or process payment data request update. ' + err );\n\t\t\t\t}\n\n\t\t\t\tthis.unblockUI();\n\t\t\t} );\n\t\t}\n\n\t\t/**\n\t\t * Provide Google Pay API with a payment amount, currency, and amount status\n\t\t *\n\t\t * @see {@link https://developers.google.com/pay/api/web/reference/request-objects#TransactionInfo|TransactionInfo}\n\t\t *\n\t\t * @param {function} resolve callback\n\t\t * @returns {object} transaction info, suitable for use as transactionInfo property of PaymentDataRequest\n\t\t */\n\t\tgetGoogleTransactionInfo( resolve ) {\n\n\t\t\t// get transaction info from cart\n\t\t\tconst data = {\n\t\t\t\taction: `wc_${this.gatewayID}_google_pay_get_transaction_info`,\n\t\t\t}\n\n\t\t\tif ( this.productID ) {\n\t\t\t\tdata.productID = this.productID;\n\t\t\t}\n\n\t\t\t$.post( this.ajaxURL, data, ( response ) => {\n\n\t\t\t\tif ( response.success ) {\n\t\t\t\t\tresolve( JSON.parse( response.data ) )\n\t\t\t\t} else {\n\t\t\t\t\tthis.failPayment( 'Could not build transaction info. ' + response.data.message );\n\t\t\t\t}\n\t\t\t} );\n\t\t}\n\n\t\t/**\n\t\t * Get updated totals and shipping options via AJAX for use in the PaymentDataRequest\n\t\t *\n\t\t * @see {@link https://developers.google.com/pay/api/web/reference/response-objects#PaymentDataRequestUpdate|PaymentDataRequestUpdate}\n\t\t *\n\t\t * @param {object} shippingAddress shipping address\n\t\t * @param {object} shippingMethod chosen shipping method\n\t\t * @param {function} resolve callback\n\t\t */\n\t\tgetUpdatedTotals( shippingAddress, shippingMethod, resolve ) {\n\n\t\t\tconst data = {\n\t\t\t\taction: `wc_${this.gatewayID}_google_pay_recalculate_totals`,\n\t\t\t\t'nonce': this.recalculateTotalsNonce,\n\t\t\t\tshippingAddress,\n\t\t\t\tshippingMethod\n\t\t\t}\n\n\t\t\tif ( this.productID ) {\n\t\t\t\tdata.productID = this.productID;\n\t\t\t}\n\n\t\t\t$.post( this.ajaxURL, data, ( response ) => {\n\n\t\t\t\tif ( response.success ) {\n\t\t\t\t\tresolve( JSON.parse( response.data ) )\n\t\t\t\t} else {\n\t\t\t\t\tthis.failPayment( 'Could not recalculate totals. ' + response.data.message );\n\t\t\t\t}\n\t\t\t} );\n\t\t}\n\n\t\t/**\n\t\t * Provide Google Pay API with shipping address parameters when using dynamic buy flow.\n\t\t *\n\t\t * @see {@link https://developers.google.com/pay/api/web/reference/request-objects#ShippingAddressParameters|ShippingAddressParameters}\n\t\t * @returns {object} shipping address details, suitable for use as shippingAddressParameters property of PaymentDataRequest\n\t\t */\n\t\tgetGoogleShippingAddressParameters() {\n\n\t\t\treturn {\n\t\t\t\tallowedCountryCodes: this.availableCountries\n\t\t\t};\n\t\t}\n\n\t\t/**\n\t\t * Provide Google Pay API with a payment data error.\n\t\t *\n\t\t * @see {@link https://developers.google.com/pay/api/web/reference/response-objects#PaymentDataError|PaymentDataError}\n\t\t * @returns {object} payment data error, suitable for use as error property of PaymentDataRequestUpdate\n\t\t */\n\t\tgetGoogleUnserviceableAddressError() {\n\t\t\treturn {\n\t\t\t\treason: 'SHIPPING_ADDRESS_UNSERVICEABLE',\n\t\t\t\tmessage: 'Cannot ship to the selected address',\n\t\t\t\tintent: 'SHIPPING_ADDRESS'\n\t\t\t};\n\t\t}\n\n\t\t/**\n\t\t * Add a Google Pay purchase button alongside an existing checkout button\n\t\t *\n\t\t * @see {@link https://developers.google.com/pay/api/web/reference/request-objects#ButtonOptions|Button options}\n\t\t * @see {@link https://developers.google.com/pay/api/web/guides/brand-guidelines|Google Pay brand guidelines}\n\t\t */\n\t\taddGooglePayButton() {\n\n\t\t\tconst paymentsClient = this.getGooglePaymentsClient();\n\t\t\tconst button = paymentsClient.createButton( {\n\t\t\t\tonClick: ( event ) => this.onGooglePaymentButtonClicked( event ),\n\t\t\t\tbuttonColor: this.buttonStyle,\n\t\t\t\tbuttonSizeMode: 'fill'\n\t\t\t} );\n\t\t\tdocument.getElementById( 'sv-wc-google-pay-button-container' ).appendChild( button );\n\t\t}\n\n\t\t/**\n\t\t * Prefetch payment data to improve performance\n\t\t *\n\t\t * @see {@link https://developers.google.com/pay/api/web/reference/client#prefetchPaymentData|prefetchPaymentData()}\n\t\t */\n\t\tprefetchGooglePaymentData() {\n\n\t\t\tthis.getGooglePaymentDataRequest( ( paymentDataRequest ) => {\n\n\t\t\t\t// transactionInfo must be set but does not affect cache\n\t\t\t\tpaymentDataRequest.transactionInfo = {\n\t\t\t\t\ttotalPriceStatus: 'NOT_CURRENTLY_KNOWN',\n\t\t\t\t\tcurrencyCode: this.currencyCode\n\t\t\t\t};\n\t\t\t\tconst paymentsClient = this.getGooglePaymentsClient();\n\t\t\t\tpaymentsClient.prefetchPaymentData( paymentDataRequest );\n\t\t\t} );\n\t\t}\n\n\t\t/**\n\t\t * Process payment data returned by the Google Pay API\n\t\t *\n\t\t * @see {@link https://developers.google.com/pay/api/web/reference/response-objects#PaymentData|PaymentData object reference}\n\t\t *\n\t\t * @param {object} paymentData response from Google Pay API after user approves payment\n\t\t * @param {function} resolve callback\n\t\t */\n\t\tprocessPayment( paymentData, resolve ) {\n\n\t\t\t// pass payment token to your gateway to process payment\n\t\t\tconst data = {\n\t\t\t\taction: `wc_${this.gatewayID}_google_pay_process_payment`,\n\t\t\t\tnonce: this.processNonce,\n\t\t\t\tpaymentData: JSON.stringify( paymentData ),\n\t\t\t}\n\n\t\t\tif ( this.productID && ! this.needsShipping ) {\n\t\t\t\tdata.productID = this.productID;\n\t\t\t}\n\n\t\t\treturn $.post( this.ajaxURL, data, ( response ) => {\n\t\t\t\tif ( response.success ) {\n\t\t\t\t\tresolve( {\n\t\t\t\t\t\ttransactionState: 'SUCCESS'\n\t\t\t\t\t} );\n\t\t\t\t\twindow.location = response.data.redirect;\n\t\t\t\t} else {\n\t\t\t\t\tresolve( {\n\t\t\t\t\t\ttransactionState: 'ERROR',\n\t\t\t\t\t\terror: {\n\t\t\t\t\t\t\tintent: 'SHIPPING_ADDRESS',\n\t\t\t\t\t\t\tmessage: 'Invalid data',\n\t\t\t\t\t\t\treason: 'PAYMENT_DATA_INVALID'\n\t\t\t\t\t\t}\n\t\t\t\t\t} );\n\t\t\t\t\tthis.failPayment( 'Payment could not be processed. ' + response.data.message );\n\t\t\t\t}\n\t\t\t} );\n\t\t}\n\n\t\t/**\n\t\t * Show Google Pay payment sheet when Google Pay payment button is clicked\n\t\t */\n\t\tonGooglePaymentButtonClicked( event ) {\n\n\t\t\tevent.preventDefault();\n\n\t\t\tthis.blockUI();\n\n\t\t\tthis.getGooglePaymentDataRequest( ( paymentDataRequest ) => {\n\n\t\t\t\tconst paymentsClient = this.getGooglePaymentsClient();\n\t\t\t\ttry {\n\t\t\t\t\tpaymentsClient.loadPaymentData( paymentDataRequest );\n\t\t\t\t} catch ( err ) {\n\t\t\t\t\tthis.failPayment( 'Could not load payment data. ' + err );\n\t\t\t\t}\n\n\t\t\t\tthis.unblockUI();\n\t\t\t} );\n\t\t}\n\n\t\t/**\n\t\t * Initialize Google PaymentsClient after Google-hosted JavaScript has loaded\n\t\t *\n\t\t * Display a Google Pay payment button after confirmation of the viewer's\n\t\t * ability to pay.\n\t\t */\n\t\tinit() {\n\n\t\t\t// initialize for the various pages\n\t\t\tif ( $( 'form.cart' ).length ) {\n\t\t\t\tthis.initProductPage();\n\t\t\t} else if ( $( 'form.woocommerce-cart-form' ).length ) {\n\t\t\t\tthis.initCartPage();\n\t\t\t} else if ( $( 'form.woocommerce-checkout' ).length) {\n\t\t\t\tthis.initCheckoutPage()\n\t\t\t} else {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tthis.initGooglePay();\n\t\t}\n\n\t\t/**\n\t\t * Initializes Google Pay.\n\t\t */\n\t\tinitGooglePay() {\n\n\t\t\tconst paymentsClient = this.getGooglePaymentsClient();\n\t\t\tpaymentsClient.isReadyToPay( this.getGoogleIsReadyToPayRequest() )\n\t\t\t\t.then( ( response ) => {\n\t\t\t\t\tif ( response.result ) {\n\t\t\t\t\t\tthis.addGooglePayButton();\n\t\t\t\t\t\t// prefetch payment data to improve performance\n\t\t\t\t\t\tthis.prefetchGooglePaymentData();\n\t\t\t\t\t}\n\t\t\t\t} )\n\t\t\t\t.catch( ( err ) => {\n\t\t\t\t\tthis.failPayment( 'Google Pay is not ready. ' + err );\n\t\t\t\t} );\n\t\t}\n\n\t\t/**\n\t\t * Initializes the product page.\n\t\t */\n\t\tinitProductPage() {\n\t\t\tthis.uiElement = $( 'form.cart' );\n\t\t}\n\n\t\t/**\n\t\t * Initializes the cart page.\n\t\t */\n\t\tinitCartPage() {\n\t\t\tthis.uiElement = $( 'form.woocommerce-cart-form' ).parents( 'div.woocommerce' );\n\n\t\t\t// re-init if the cart totals are updated\n\t\t\t$( document.body ).on( 'updated_cart_totals', () => {\n\t\t\t\tthis.initGooglePay();\n\t\t\t} );\n\t\t}\n\n\t\t/**\n\t\t * Initializes the checkout page.\n\t\t */\n\t\tinitCheckoutPage() {\n\t\t\tthis.uiElement = $( 'form.woocommerce-checkout' );\n\t\t}\n\n\t\t/**\n\t\t * Fails the purchase based on the gateway result.\n\t\t */\n\t\tfailPayment( error ) {\n\n\t\t\tconsole.error( '[Google Pay] ' + error );\n\n\t\t\tthis.unblockUI();\n\n\t\t\tthis.renderErrors( [ this.genericError ] );\n\t\t}\n\n\t\t/**\n\t\t * Renders any new errors and bring them into the viewport.\n \t\t */\n\t\trenderErrors( errors ) {\n\n\t\t\t// hide and remove any previous errors\n\t\t\t$( '.woocommerce-error, .woocommerce-message' ).remove();\n\n\t\t\t// add errors\n\t\t\tthis.uiElement.prepend( '
    • ' + errors.join( '
    • ' ) + '
    ' );\n\n\t\t\t// unblock UI\n\t\t\tthis.uiElement.removeClass( 'processing' ).unblock();\n\n\t\t\t// scroll to top\n\t\t\t$( 'html, body' ).animate( { scrollTop: this.uiElement.offset().top - 100 }, 1000 );\n\t\t}\n\n\t\t/**\n\t\t * Blocks the payment form UI.\n\t\t */\n\t\tblockUI() {\n\t\t\tthis.uiElement.block( { message: null, overlayCSS: { background: '#fff', opacity: 0.6 } } );\n\t\t}\n\n\t\t/**\n\t\t * Unblocks the payment form UI.\n\t\t */\n\t\tunblockUI() {\n\t\t\tthis.uiElement.unblock();\n\t\t}\n\t}\n\n\t$( document.body ).trigger( 'sv_wc_google_pay_handler_v5_14_0_loaded' );\n\n} );\n"]} diff --git a/woocommerce/payment-gateway/assets/dist/frontend/sv-wc-payment-gateway-my-payment-methods.js b/woocommerce/payment-gateway/assets/dist/frontend/sv-wc-payment-gateway-my-payment-methods.js index c107dd5aa..6519bba92 100644 --- a/woocommerce/payment-gateway/assets/dist/frontend/sv-wc-payment-gateway-my-payment-methods.js +++ b/woocommerce/payment-gateway/assets/dist/frontend/sv-wc-payment-gateway-my-payment-methods.js @@ -1,4 +1,4 @@ parcelRequire=function(e,r,t,n){var i,o="function"==typeof parcelRequire&&parcelRequire,u="function"==typeof require&&require;function f(t,n){if(!r[t]){if(!e[t]){var i="function"==typeof parcelRequire&&parcelRequire;if(!n&&i)return i(t,!0);if(o)return o(t,!0);if(u&&"string"==typeof t)return u(t);var c=new Error("Cannot find module '"+t+"'");throw c.code="MODULE_NOT_FOUND",c}p.resolve=function(r){return e[t][1][r]||r},p.cache={};var l=r[t]=new f.Module(t);e[t][0].call(l.exports,p,l,l.exports,this)}return r[t].exports;function p(e){return f(p.resolve(e))}}f.isParcelRequire=!0,f.Module=function(e){this.id=e,this.bundle=f,this.exports={}},f.modules=e,f.cache=r,f.parent=o,f.register=function(r,t){e[r]=[function(e,r){r.exports=t},{}]};for(var c=0;c0&&e(o).find("td.woocommerce-PaymentMethod--method").html(i.html()),e(o).find("td.woocommerce-PaymentMethod--title").remove()})}},{key:"remove_duplicate_default_marks",value:function(){return e(".woocommerce-MyAccount-paymentMethods").find("tr").each(function(t,n){return e(n).find("td.woocommerce-PaymentMethod--default").find("mark.default:not(:first-child)").remove()})}},{key:"edit_method",value:function(t){var n,o;if(t.preventDefault(),0!==(o=(n=e(t.currentTarget)).parents("tr")).find("input[name=plugin-id][value=".concat(this.slug,"]")).length)return o.find("div.view").hide(),o.find("div.edit").show(),o.addClass("editing"),n.text(this.i18n.cancel_button).removeClass("edit").addClass("cancel-edit").removeClass("button"),this.enable_editing_ui()}},{key:"save_method",value:function(t){var n,o,i,a=this;if(t.preventDefault(),n=e(t.currentTarget),0!==(i=n.parents("tr")).find("input[name=plugin-id][value=".concat(this.slug,"]")).length)return this.block_ui(),i.next(".error").remove(),o={action:"wc_".concat(this.id,"_save_payment_method"),nonce:this.ajax_nonce,token_id:i.find("input[name=token-id]").val(),data:i.find("input[name]").serialize()},e.post(this.ajax_url,o).done(function(e){return e.success?(null!=e.data.title&&i.find(".woocommerce-PaymentMethod--method").html(e.data.title),null!=e.data.nonce&&(a.ajax_nonce=e.data.nonce),n.siblings(".cancel-edit").removeClass("cancel-edit").addClass("edit").text(a.i18n.edit_button).addClass("button"),i.removeClass("editing"),a.disable_editing_ui()):a.display_error(i,e.data)}).fail(function(e,t,n){return a.display_error(i,n)}).always(function(){return a.unblock_ui()})}},{key:"cancel_edit",value:function(t){var n,o;if(t.preventDefault(),0!==(o=(n=e(t.currentTarget)).parents("tr")).find("input[name=plugin-id][value=".concat(this.slug,"]")).length)return o.find("div.view").show(),o.find("div.edit").hide(),o.removeClass("editing"),n.removeClass("cancel-edit").addClass("edit").text(this.i18n.edit_button).addClass("button"),this.disable_editing_ui()}},{key:"enable_editing_ui",value:function(){return e(".woocommerce-MyAccount-paymentMethods").addClass("editing"),e('.button[href*="add-payment-method"]').addClass("disabled")}},{key:"disable_editing_ui",value:function(){return e(".woocommerce-MyAccount-paymentMethods").removeClass("editing"),e('.button[href*="add-payment-method"]').removeClass("disabled")}},{key:"block_ui",value:function(){return e(".woocommerce-MyAccount-paymentMethods").parent("div").block({message:null,overlayCSS:{background:"#fff",opacity:.6}})}},{key:"unblock_ui",value:function(){return e(".woocommerce-MyAccount-paymentMethods").parent("div").unblock()}},{key:"display_error",value:function(t,n){var o,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";return console.error(n),i||(i=this.i18n.save_error),o=e(".woocommerce-MyAccount-paymentMethods thead tr th").length,e(''+i+"").insertAfter(t).find("td").delay(8e3).slideUp(200)}}])}(),e(document.body).trigger("sv_wc_payment_methods_handler_v5_13_1_loaded")})}).call(this); +function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(t)}function t(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function n(e,t){for(var n=0;n0&&e(o).find("td.woocommerce-PaymentMethod--method").html(i.html()),e(o).find("td.woocommerce-PaymentMethod--title").remove()})}},{key:"remove_duplicate_default_marks",value:function(){return e(".woocommerce-MyAccount-paymentMethods").find("tr").each(function(t,n){return e(n).find("td.woocommerce-PaymentMethod--default").find("mark.default:not(:first-child)").remove()})}},{key:"edit_method",value:function(t){var n,o;if(t.preventDefault(),0!==(o=(n=e(t.currentTarget)).parents("tr")).find("input[name=plugin-id][value=".concat(this.slug,"]")).length)return o.find("div.view").hide(),o.find("div.edit").show(),o.addClass("editing"),n.text(this.i18n.cancel_button).removeClass("edit").addClass("cancel-edit").removeClass("button"),this.enable_editing_ui()}},{key:"save_method",value:function(t){var n,o,i,a=this;if(t.preventDefault(),n=e(t.currentTarget),0!==(i=n.parents("tr")).find("input[name=plugin-id][value=".concat(this.slug,"]")).length)return this.block_ui(),i.next(".error").remove(),o={action:"wc_".concat(this.id,"_save_payment_method"),nonce:this.ajax_nonce,token_id:i.find("input[name=token-id]").val(),data:i.find("input[name]").serialize()},e.post(this.ajax_url,o).done(function(e){return e.success?(null!=e.data.title&&i.find(".woocommerce-PaymentMethod--method").html(e.data.title),null!=e.data.nonce&&(a.ajax_nonce=e.data.nonce),n.siblings(".cancel-edit").removeClass("cancel-edit").addClass("edit").text(a.i18n.edit_button).addClass("button"),i.removeClass("editing"),a.disable_editing_ui()):a.display_error(i,e.data)}).fail(function(e,t,n){return a.display_error(i,n)}).always(function(){return a.unblock_ui()})}},{key:"cancel_edit",value:function(t){var n,o;if(t.preventDefault(),0!==(o=(n=e(t.currentTarget)).parents("tr")).find("input[name=plugin-id][value=".concat(this.slug,"]")).length)return o.find("div.view").show(),o.find("div.edit").hide(),o.removeClass("editing"),n.removeClass("cancel-edit").addClass("edit").text(this.i18n.edit_button).addClass("button"),this.disable_editing_ui()}},{key:"enable_editing_ui",value:function(){return e(".woocommerce-MyAccount-paymentMethods").addClass("editing"),e('.button[href*="add-payment-method"]').addClass("disabled")}},{key:"disable_editing_ui",value:function(){return e(".woocommerce-MyAccount-paymentMethods").removeClass("editing"),e('.button[href*="add-payment-method"]').removeClass("disabled")}},{key:"block_ui",value:function(){return e(".woocommerce-MyAccount-paymentMethods").parent("div").block({message:null,overlayCSS:{background:"#fff",opacity:.6}})}},{key:"unblock_ui",value:function(){return e(".woocommerce-MyAccount-paymentMethods").parent("div").unblock()}},{key:"display_error",value:function(t,n){var o,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";return console.error(n),i||(i=this.i18n.save_error),o=e(".woocommerce-MyAccount-paymentMethods thead tr th").length,e(''+i+"").insertAfter(t).find("td").delay(8e3).slideUp(200)}}])}(),e(document.body).trigger("sv_wc_payment_methods_handler_v5_14_0_loaded")})}).call(this); },{}]},{},["nDDW"], null) //# sourceMappingURL=../frontend/sv-wc-payment-gateway-my-payment-methods.js.map diff --git a/woocommerce/payment-gateway/assets/dist/frontend/sv-wc-payment-gateway-my-payment-methods.js.map b/woocommerce/payment-gateway/assets/dist/frontend/sv-wc-payment-gateway-my-payment-methods.js.map index d9171fe90..c852398dc 100644 --- a/woocommerce/payment-gateway/assets/dist/frontend/sv-wc-payment-gateway-my-payment-methods.js.map +++ b/woocommerce/payment-gateway/assets/dist/frontend/sv-wc-payment-gateway-my-payment-methods.js.map @@ -1 +1 @@ -{"version":3,"sources":["frontend/sv-wc-payment-gateway-my-payment-methods.coffee"],"names":["jQuery","$","window","SV_WC_Payment_Methods_Handler_v5_13_1","args","replace_method_column","bind","remove_duplicate_default_marks","edit_method","save_method","cancel_edit","id","slug","i18n","ajax_url","ajax_nonce","on","event","row","currentTarget","parents","find","length","confirm","delete_ays","preventDefault","hasClass","each","index","element","titleColumn","remove","children","html","button","hide","show","addClass","text","cancel_button","removeClass","enable_editing_ui","data","block_ui","next","action","nonce","token_id","val","serialize","post","done","response","success","title","siblings","edit_button","disable_editing_ui","display_error","fail","jqXHR","textStatus","error","always","unblock_ui","parent","block","message","overlayCSS","background","opacity","unblock","columns","console","save_error","insertAfter","delay","slideUp","document","body","trigger","call"],"mappings":";AAAA,SAAA,EAAA,GAAA,OAAA,EAAA,mBAAA,QAAA,iBAAA,OAAA,SAAA,SAAA,GAAA,cAAA,GAAA,SAAA,GAAA,OAAA,GAAA,mBAAA,QAAA,EAAA,cAAA,QAAA,IAAA,OAAA,UAAA,gBAAA,IAAA,GAAA,SAAA,EAAA,EAAA,GAAA,KAAA,aAAA,GAAA,MAAA,IAAA,UAAA,qCAAA,SAAA,EAAA,EAAA,GAAA,IAAA,IAAA,EAAA,EAAA,EAAA,EAAA,OAAA,IAAA,CAAA,IAAA,EAAA,EAAA,GAAA,EAAA,WAAA,EAAA,aAAA,EAAA,EAAA,cAAA,EAAA,UAAA,IAAA,EAAA,UAAA,GAAA,OAAA,eAAA,EAAA,EAAA,EAAA,KAAA,IAAA,SAAA,EAAA,EAAA,EAAA,GAAA,OAAA,GAAA,EAAA,EAAA,UAAA,GAAA,GAAA,EAAA,EAAA,GAAA,OAAA,eAAA,EAAA,YAAA,CAAA,UAAA,IAAA,EAAA,SAAA,EAAA,GAAA,IAAA,EAAA,EAAA,EAAA,UAAA,MAAA,UAAA,EAAA,GAAA,EAAA,EAAA,GAAA,SAAA,EAAA,EAAA,GAAA,GAAA,UAAA,EAAA,KAAA,EAAA,OAAA,EAAA,IAAA,EAAA,EAAA,OAAA,aAAA,QAAA,IAAA,EAAA,CAAA,IAAA,EAAA,EAAA,KAAA,EAAA,GAAA,WAAA,GAAA,UAAA,EAAA,GAAA,OAAA,EAAA,MAAA,IAAA,UAAA,gDAAA,OAAA,WAAA,EAAA,OAAA,QAAA,IAAA,WASEA,OAAO,SAASC,GAAG,aAwPVA,OAnPPC,OAAOC,sCAAP,WAAA,OAAA,EAWcC,SAAAA,EAAA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GAAOK,IACpBK,EADoBL,EAAU,UAAA,OAAA,QAAA,IAAA,UAAA,GAAA,UAAA,GAAA,GAO3BlE,OALPwE,QAAQX,MAAMA,GACTK,IACHA,EAAU,KAAKtD,KAAK6D,YAEtBF,EAAUvE,EAAE,qDAAqDqB,OAC1DrB,EAAE,kCAAoCuE,EAAU,KAAOL,EAAU,cAAcQ,YAAYzD,GAAKG,KAAK,MAAMuD,MAAM,KAAMC,QAAQ,SA9O1I,GAmPO5E,EAAE6E,SAASC,MAAMC,QAAQ,oDAGjCC,KAAK","file":"sv-wc-payment-gateway-my-payment-methods.js","sourceRoot":"../js","sourcesContent":["(function() {\n /*\n WooCommerce SkyVerge Payment Gateway My Payment Methods CoffeeScript\n Version 5.1.0\n\n Copyright (c) 2014-2024, SkyVerge, Inc.\n Licensed under the GNU General Public License v3.0\n http://www.gnu.org/licenses/gpl-3.0.html\n */\n jQuery(function($) {\n \"use strict\";\n // The My Payment Methods handler.\n\n // @since 5.1.0\n window.SV_WC_Payment_Methods_Handler_v5_13_1 = class SV_WC_Payment_Methods_Handler_v5_13_1 {\n // Constructs the class.\n\n // @since 5.1.0\n\n // @param [Object] args, with the properties:\n // id: [String] plugin ID\n // slug: [String] plugin slug or dasherized ID\n // i18n: [Object] localized text strings\n // ajax_url: [String] URL for AJAX requests\n // ajax_nonce: [String] nonce for AJAX requests\n constructor(args) {\n // Replace Method column content with Title column content, for FW tokens.\n\n // @since 5.8.0\n this.replace_method_column = this.replace_method_column.bind(this);\n // Removes duplicate \"Default\" marks.\n\n // They are already hidden using CSS, but should also be removed for accessibility.\n\n // @since 5.8.0\n this.remove_duplicate_default_marks = this.remove_duplicate_default_marks.bind(this);\n // Edits a payment method.\n\n // @since 5.1.0\n\n // @param [Object] event jQuery event object\n this.edit_method = this.edit_method.bind(this);\n // Saves a payment method.\n\n // @since 5.1.0\n\n // @param [Object] event jQuery event object\n this.save_method = this.save_method.bind(this);\n // Cancels/stop editing a payment method.\n\n // @since 5.1.0\n\n // @param [Object] event jQuery event object\n this.cancel_edit = this.cancel_edit.bind(this);\n this.id = args.id;\n this.slug = args.slug;\n this.i18n = args.i18n;\n this.ajax_url = args.ajax_url;\n this.ajax_nonce = args.ajax_nonce;\n // replace the \"Method\" column content for FW tokens\n this.replace_method_column();\n // remove duplicate \"Default\" marks\n this.remove_duplicate_default_marks();\n // handle the edit action\n $(\".woocommerce-MyAccount-paymentMethods\").on('click', \".woocommerce-PaymentMethod--actions .button.edit\", (event) => {\n return this.edit_method(event);\n });\n // handle the save action\n $(\".woocommerce-MyAccount-paymentMethods\").on('click', \".woocommerce-PaymentMethod--actions .button.save\", (event) => {\n return this.save_method(event);\n });\n // handle the cancel action\n $(\".woocommerce-MyAccount-paymentMethods\").on('click', \".woocommerce-PaymentMethod--actions .cancel-edit\", (event) => {\n return this.cancel_edit(event);\n });\n // handle the delete action\n $(\".woocommerce-MyAccount-paymentMethods\").on('click', \".woocommerce-PaymentMethod--actions .button.delete\", (event) => {\n var button, row;\n button = $(event.currentTarget);\n row = button.parents('tr');\n // check if the method belongs to this plugin\n if (row.find(`input[name=plugin-id][value=${this.slug}]`).length === 0) {\n return;\n }\n if (!confirm(this.i18n.delete_ays)) {\n return event.preventDefault();\n }\n });\n // don't follow the Add Payment Method button URL if it's disabled\n $('.button[href*=\"add-payment-method\"]').on('click', event(function() {\n if ($(this).hasClass('disabled')) {\n return event.preventDefault();\n }\n }));\n }\n\n replace_method_column() {\n return $('.woocommerce-MyAccount-paymentMethods').find('tr').each((index, element) => {\n var titleColumn;\n // check if the method belongs to this plugin\n if ($(element).find(`input[name=plugin-id][value=${this.slug}]`).length === 0) {\n return;\n }\n // delete the Title header\n $(element).find('th.woocommerce-PaymentMethod--title').remove();\n titleColumn = $(element).find('td.woocommerce-PaymentMethod--title');\n // Title column is not empty, this is a FW token\n if (titleColumn.children().length > 0) {\n // replace Method column\n $(element).find('td.woocommerce-PaymentMethod--method').html(titleColumn.html());\n }\n // delete Title column\n return $(element).find('td.woocommerce-PaymentMethod--title').remove();\n });\n }\n\n remove_duplicate_default_marks() {\n return $('.woocommerce-MyAccount-paymentMethods').find('tr').each((index, element) => {\n return $(element).find('td.woocommerce-PaymentMethod--default').find('mark.default:not(:first-child)').remove();\n });\n }\n\n edit_method(event) {\n var button, row;\n event.preventDefault();\n button = $(event.currentTarget);\n row = button.parents('tr');\n // check if the method belongs to this plugin\n if (row.find(`input[name=plugin-id][value=${this.slug}]`).length === 0) {\n return;\n }\n row.find('div.view').hide();\n row.find('div.edit').show();\n row.addClass('editing');\n // change the Edit button to \"Cancel\"\n button.text(this.i18n.cancel_button).removeClass('edit').addClass('cancel-edit').removeClass('button');\n return this.enable_editing_ui();\n }\n\n save_method(event) {\n var button, data, row;\n event.preventDefault();\n button = $(event.currentTarget);\n row = button.parents('tr');\n // check if the method belongs to this plugin\n if (row.find(`input[name=plugin-id][value=${this.slug}]`).length === 0) {\n return;\n }\n this.block_ui();\n // remove any previous errors\n row.next('.error').remove();\n data = {\n action: `wc_${this.id}_save_payment_method`,\n nonce: this.ajax_nonce,\n token_id: row.find('input[name=token-id]').val(),\n data: row.find('input[name]').serialize()\n };\n return $.post(this.ajax_url, data).done((response) => {\n if (!response.success) {\n return this.display_error(row, response.data);\n }\n if (response.data.title != null) {\n row.find('.woocommerce-PaymentMethod--method').html(response.data.title);\n }\n if (response.data.nonce != null) {\n this.ajax_nonce = response.data.nonce;\n }\n // change the \"Cancel\" button back to \"Edit\"\n button.siblings('.cancel-edit').removeClass('cancel-edit').addClass('edit').text(this.i18n.edit_button).addClass('button');\n row.removeClass('editing');\n return this.disable_editing_ui();\n }).fail((jqXHR, textStatus, error) => {\n return this.display_error(row, error);\n }).always(() => {\n return this.unblock_ui();\n });\n }\n\n cancel_edit(event) {\n var button, row;\n event.preventDefault();\n button = $(event.currentTarget);\n row = button.parents('tr');\n // check if the method belongs to this plugin\n if (row.find(`input[name=plugin-id][value=${this.slug}]`).length === 0) {\n return;\n }\n row.find('div.view').show();\n row.find('div.edit').hide();\n row.removeClass('editing');\n // change the \"Cancel\" button back to \"Edit\"\n button.removeClass('cancel-edit').addClass('edit').text(this.i18n.edit_button).addClass('button');\n return this.disable_editing_ui();\n }\n\n // Sets the page UI to the \"editing\" state.\n\n // This brings proper focus to the method being edited and prevents\n // other available buttons/actions until the editing is finished or cancelled.\n\n // @since 5.1.1\n enable_editing_ui() {\n // set the methods table as 'editing'\n $(\".woocommerce-MyAccount-paymentMethods\").addClass('editing');\n // disable the Add Payment Method button\n return $('.button[href*=\"add-payment-method\"]').addClass('disabled');\n }\n\n // Sets the page UI back to the default state.\n\n // @since 5.1.1\n disable_editing_ui() {\n // removes the methods table's \"editing\" status\n $(\".woocommerce-MyAccount-paymentMethods\").removeClass('editing');\n // re-enable the Add Payment Method button\n return $('.button[href*=\"add-payment-method\"]').removeClass('disabled');\n }\n\n // Blocks the payment methods table UI.\n\n // @since 5.1.0\n block_ui() {\n return $(\".woocommerce-MyAccount-paymentMethods\").parent('div').block({\n message: null,\n overlayCSS: {\n background: '#fff',\n opacity: 0.6\n }\n });\n }\n\n // Unblocks the payment methods table UI.\n\n // @since 5.1.0\n unblock_ui() {\n return $(\".woocommerce-MyAccount-paymentMethods\").parent('div').unblock();\n }\n\n // Displays an error message to the user.\n\n // @since 5.1.0\n\n // @param [Object] row payment method table row\n // @param [String] error raw error message\n // @param [String] message user error message\n display_error(row, error, message = '') {\n var columns;\n console.error(error);\n if (!message) {\n message = this.i18n.save_error;\n }\n columns = $(\".woocommerce-MyAccount-paymentMethods thead tr th\").length;\n return $('' + message + '').insertAfter(row).find('td').delay(8000).slideUp(200);\n }\n\n };\n // dispatch loaded event\n return $(document.body).trigger('sv_wc_payment_methods_handler_v5_13_1_loaded');\n });\n\n}).call(this);\n"]} +{"version":3,"sources":["frontend/sv-wc-payment-gateway-my-payment-methods.coffee"],"names":["jQuery","$","window","SV_WC_Payment_Methods_Handler_v5_14_0","args","replace_method_column","bind","remove_duplicate_default_marks","edit_method","save_method","cancel_edit","id","slug","i18n","ajax_url","ajax_nonce","on","event","row","currentTarget","parents","find","length","confirm","delete_ays","preventDefault","hasClass","each","index","element","titleColumn","remove","children","html","button","hide","show","addClass","text","cancel_button","removeClass","enable_editing_ui","data","block_ui","next","action","nonce","token_id","val","serialize","post","done","response","success","title","siblings","edit_button","disable_editing_ui","display_error","fail","jqXHR","textStatus","error","always","unblock_ui","parent","block","message","overlayCSS","background","opacity","unblock","columns","console","save_error","insertAfter","delay","slideUp","document","body","trigger","call"],"mappings":";AAAA,SAAA,EAAA,GAAA,OAAA,EAAA,mBAAA,QAAA,iBAAA,OAAA,SAAA,SAAA,GAAA,cAAA,GAAA,SAAA,GAAA,OAAA,GAAA,mBAAA,QAAA,EAAA,cAAA,QAAA,IAAA,OAAA,UAAA,gBAAA,IAAA,GAAA,SAAA,EAAA,EAAA,GAAA,KAAA,aAAA,GAAA,MAAA,IAAA,UAAA,qCAAA,SAAA,EAAA,EAAA,GAAA,IAAA,IAAA,EAAA,EAAA,EAAA,EAAA,OAAA,IAAA,CAAA,IAAA,EAAA,EAAA,GAAA,EAAA,WAAA,EAAA,aAAA,EAAA,EAAA,cAAA,EAAA,UAAA,IAAA,EAAA,UAAA,GAAA,OAAA,eAAA,EAAA,EAAA,EAAA,KAAA,IAAA,SAAA,EAAA,EAAA,EAAA,GAAA,OAAA,GAAA,EAAA,EAAA,UAAA,GAAA,GAAA,EAAA,EAAA,GAAA,OAAA,eAAA,EAAA,YAAA,CAAA,UAAA,IAAA,EAAA,SAAA,EAAA,GAAA,IAAA,EAAA,EAAA,EAAA,UAAA,MAAA,UAAA,EAAA,GAAA,EAAA,EAAA,GAAA,SAAA,EAAA,EAAA,GAAA,GAAA,UAAA,EAAA,KAAA,EAAA,OAAA,EAAA,IAAA,EAAA,EAAA,OAAA,aAAA,QAAA,IAAA,EAAA,CAAA,IAAA,EAAA,EAAA,KAAA,EAAA,GAAA,WAAA,GAAA,UAAA,EAAA,GAAA,OAAA,EAAA,MAAA,IAAA,UAAA,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,QApNjB,CAAA,IAAA,aA4NE,MAAA,WACSrE,OAAAA,EAAE,yCAAyCgE,OAAO,OAAOM,YA7NpE,CAAA,IAAA,gBAuOE,MAAA,SAAcrD,EAAK4C,GAAOK,IACpBK,EADoBL,EAAU,UAAA,OAAA,QAAA,IAAA,UAAA,GAAA,UAAA,GAAA,GAO3BlE,OALPwE,QAAQX,MAAMA,GACTK,IACHA,EAAU,KAAKtD,KAAK6D,YAEtBF,EAAUvE,EAAE,qDAAqDqB,OAC1DrB,EAAE,kCAAoCuE,EAAU,KAAOL,EAAU,cAAcQ,YAAYzD,GAAKG,KAAK,MAAMuD,MAAM,KAAMC,QAAQ,SA9O1I,GAmPO5E,EAAE6E,SAASC,MAAMC,QAAQ,oDAGjCC,KAAK","file":"sv-wc-payment-gateway-my-payment-methods.js","sourceRoot":"../js","sourcesContent":["(function() {\n /*\n WooCommerce SkyVerge Payment Gateway My Payment Methods CoffeeScript\n Version 5.1.0\n\n Copyright (c) 2014-2024, SkyVerge, Inc.\n Licensed under the GNU General Public License v3.0\n http://www.gnu.org/licenses/gpl-3.0.html\n */\n jQuery(function($) {\n \"use strict\";\n // The My Payment Methods handler.\n\n // @since 5.1.0\n window.SV_WC_Payment_Methods_Handler_v5_14_0 = class SV_WC_Payment_Methods_Handler_v5_14_0 {\n // Constructs the class.\n\n // @since 5.1.0\n\n // @param [Object] args, with the properties:\n // id: [String] plugin ID\n // slug: [String] plugin slug or dasherized ID\n // i18n: [Object] localized text strings\n // ajax_url: [String] URL for AJAX requests\n // ajax_nonce: [String] nonce for AJAX requests\n constructor(args) {\n // Replace Method column content with Title column content, for FW tokens.\n\n // @since 5.8.0\n this.replace_method_column = this.replace_method_column.bind(this);\n // Removes duplicate \"Default\" marks.\n\n // They are already hidden using CSS, but should also be removed for accessibility.\n\n // @since 5.8.0\n this.remove_duplicate_default_marks = this.remove_duplicate_default_marks.bind(this);\n // Edits a payment method.\n\n // @since 5.1.0\n\n // @param [Object] event jQuery event object\n this.edit_method = this.edit_method.bind(this);\n // Saves a payment method.\n\n // @since 5.1.0\n\n // @param [Object] event jQuery event object\n this.save_method = this.save_method.bind(this);\n // Cancels/stop editing a payment method.\n\n // @since 5.1.0\n\n // @param [Object] event jQuery event object\n this.cancel_edit = this.cancel_edit.bind(this);\n this.id = args.id;\n this.slug = args.slug;\n this.i18n = args.i18n;\n this.ajax_url = args.ajax_url;\n this.ajax_nonce = args.ajax_nonce;\n // replace the \"Method\" column content for FW tokens\n this.replace_method_column();\n // remove duplicate \"Default\" marks\n this.remove_duplicate_default_marks();\n // handle the edit action\n $(\".woocommerce-MyAccount-paymentMethods\").on('click', \".woocommerce-PaymentMethod--actions .button.edit\", (event) => {\n return this.edit_method(event);\n });\n // handle the save action\n $(\".woocommerce-MyAccount-paymentMethods\").on('click', \".woocommerce-PaymentMethod--actions .button.save\", (event) => {\n return this.save_method(event);\n });\n // handle the cancel action\n $(\".woocommerce-MyAccount-paymentMethods\").on('click', \".woocommerce-PaymentMethod--actions .cancel-edit\", (event) => {\n return this.cancel_edit(event);\n });\n // handle the delete action\n $(\".woocommerce-MyAccount-paymentMethods\").on('click', \".woocommerce-PaymentMethod--actions .button.delete\", (event) => {\n var button, row;\n button = $(event.currentTarget);\n row = button.parents('tr');\n // check if the method belongs to this plugin\n if (row.find(`input[name=plugin-id][value=${this.slug}]`).length === 0) {\n return;\n }\n if (!confirm(this.i18n.delete_ays)) {\n return event.preventDefault();\n }\n });\n // don't follow the Add Payment Method button URL if it's disabled\n $('.button[href*=\"add-payment-method\"]').on('click', event(function() {\n if ($(this).hasClass('disabled')) {\n return event.preventDefault();\n }\n }));\n }\n\n replace_method_column() {\n return $('.woocommerce-MyAccount-paymentMethods').find('tr').each((index, element) => {\n var titleColumn;\n // check if the method belongs to this plugin\n if ($(element).find(`input[name=plugin-id][value=${this.slug}]`).length === 0) {\n return;\n }\n // delete the Title header\n $(element).find('th.woocommerce-PaymentMethod--title').remove();\n titleColumn = $(element).find('td.woocommerce-PaymentMethod--title');\n // Title column is not empty, this is a FW token\n if (titleColumn.children().length > 0) {\n // replace Method column\n $(element).find('td.woocommerce-PaymentMethod--method').html(titleColumn.html());\n }\n // delete Title column\n return $(element).find('td.woocommerce-PaymentMethod--title').remove();\n });\n }\n\n remove_duplicate_default_marks() {\n return $('.woocommerce-MyAccount-paymentMethods').find('tr').each((index, element) => {\n return $(element).find('td.woocommerce-PaymentMethod--default').find('mark.default:not(:first-child)').remove();\n });\n }\n\n edit_method(event) {\n var button, row;\n event.preventDefault();\n button = $(event.currentTarget);\n row = button.parents('tr');\n // check if the method belongs to this plugin\n if (row.find(`input[name=plugin-id][value=${this.slug}]`).length === 0) {\n return;\n }\n row.find('div.view').hide();\n row.find('div.edit').show();\n row.addClass('editing');\n // change the Edit button to \"Cancel\"\n button.text(this.i18n.cancel_button).removeClass('edit').addClass('cancel-edit').removeClass('button');\n return this.enable_editing_ui();\n }\n\n save_method(event) {\n var button, data, row;\n event.preventDefault();\n button = $(event.currentTarget);\n row = button.parents('tr');\n // check if the method belongs to this plugin\n if (row.find(`input[name=plugin-id][value=${this.slug}]`).length === 0) {\n return;\n }\n this.block_ui();\n // remove any previous errors\n row.next('.error').remove();\n data = {\n action: `wc_${this.id}_save_payment_method`,\n nonce: this.ajax_nonce,\n token_id: row.find('input[name=token-id]').val(),\n data: row.find('input[name]').serialize()\n };\n return $.post(this.ajax_url, data).done((response) => {\n if (!response.success) {\n return this.display_error(row, response.data);\n }\n if (response.data.title != null) {\n row.find('.woocommerce-PaymentMethod--method').html(response.data.title);\n }\n if (response.data.nonce != null) {\n this.ajax_nonce = response.data.nonce;\n }\n // change the \"Cancel\" button back to \"Edit\"\n button.siblings('.cancel-edit').removeClass('cancel-edit').addClass('edit').text(this.i18n.edit_button).addClass('button');\n row.removeClass('editing');\n return this.disable_editing_ui();\n }).fail((jqXHR, textStatus, error) => {\n return this.display_error(row, error);\n }).always(() => {\n return this.unblock_ui();\n });\n }\n\n cancel_edit(event) {\n var button, row;\n event.preventDefault();\n button = $(event.currentTarget);\n row = button.parents('tr');\n // check if the method belongs to this plugin\n if (row.find(`input[name=plugin-id][value=${this.slug}]`).length === 0) {\n return;\n }\n row.find('div.view').show();\n row.find('div.edit').hide();\n row.removeClass('editing');\n // change the \"Cancel\" button back to \"Edit\"\n button.removeClass('cancel-edit').addClass('edit').text(this.i18n.edit_button).addClass('button');\n return this.disable_editing_ui();\n }\n\n // Sets the page UI to the \"editing\" state.\n\n // This brings proper focus to the method being edited and prevents\n // other available buttons/actions until the editing is finished or cancelled.\n\n // @since 5.1.1\n enable_editing_ui() {\n // set the methods table as 'editing'\n $(\".woocommerce-MyAccount-paymentMethods\").addClass('editing');\n // disable the Add Payment Method button\n return $('.button[href*=\"add-payment-method\"]').addClass('disabled');\n }\n\n // Sets the page UI back to the default state.\n\n // @since 5.1.1\n disable_editing_ui() {\n // removes the methods table's \"editing\" status\n $(\".woocommerce-MyAccount-paymentMethods\").removeClass('editing');\n // re-enable the Add Payment Method button\n return $('.button[href*=\"add-payment-method\"]').removeClass('disabled');\n }\n\n // Blocks the payment methods table UI.\n\n // @since 5.1.0\n block_ui() {\n return $(\".woocommerce-MyAccount-paymentMethods\").parent('div').block({\n message: null,\n overlayCSS: {\n background: '#fff',\n opacity: 0.6\n }\n });\n }\n\n // Unblocks the payment methods table UI.\n\n // @since 5.1.0\n unblock_ui() {\n return $(\".woocommerce-MyAccount-paymentMethods\").parent('div').unblock();\n }\n\n // Displays an error message to the user.\n\n // @since 5.1.0\n\n // @param [Object] row payment method table row\n // @param [String] error raw error message\n // @param [String] message user error message\n display_error(row, error, message = '') {\n var columns;\n console.error(error);\n if (!message) {\n message = this.i18n.save_error;\n }\n columns = $(\".woocommerce-MyAccount-paymentMethods thead tr th\").length;\n return $('' + message + '').insertAfter(row).find('td').delay(8000).slideUp(200);\n }\n\n };\n // dispatch loaded event\n return $(document.body).trigger('sv_wc_payment_methods_handler_v5_14_0_loaded');\n });\n\n}).call(this);\n"]} diff --git a/woocommerce/payment-gateway/assets/dist/frontend/sv-wc-payment-gateway-payment-form.js b/woocommerce/payment-gateway/assets/dist/frontend/sv-wc-payment-gateway-payment-form.js index 4e69a7d12..e81a177e5 100644 --- a/woocommerce/payment-gateway/assets/dist/frontend/sv-wc-payment-gateway-payment-form.js +++ b/woocommerce/payment-gateway/assets/dist/frontend/sv-wc-payment-gateway-payment-form.js @@ -1,4 +1,4 @@ parcelRequire=function(e,r,t,n){var i,o="function"==typeof parcelRequire&&parcelRequire,u="function"==typeof require&&require;function f(t,n){if(!r[t]){if(!e[t]){var i="function"==typeof parcelRequire&&parcelRequire;if(!n&&i)return i(t,!0);if(o)return o(t,!0);if(u&&"string"==typeof t)return u(t);var c=new Error("Cannot find module '"+t+"'");throw c.code="MODULE_NOT_FOUND",c}p.resolve=function(r){return e[t][1][r]||r},p.cache={};var l=r[t]=new f.Module(t);e[t][0].call(l.exports,p,l,l.exports,this)}return r[t].exports;function p(e){return f(p.resolve(e))}}f.isParcelRequire=!0,f.Module=function(e){this.id=e,this.bundle=f,this.exports={}},f.modules=e,f.cache=r,f.parent=o,f.register=function(r,t){e[r]=[function(e,r){r.exports=t},{}]};for(var c=0;c0&&e.trigger("change"),r.val()&&r.val().length>0&&r.trigger("change"),t.val()&&t.val().length>0&&t.trigger("change"),a(".js-sv-wc-payment-gateway-credit-card-form-input").on("change paste keyup",function(){return n.do_inline_credit_card_validation()})}},{key:"do_inline_credit_card_validation",value:function(){var t,r,n,i;return t=a(".js-sv-wc-payment-gateway-credit-card-form-account-number"),i=a(".js-sv-wc-payment-gateway-credit-card-form-expiry"),n=a(".js-sv-wc-payment-gateway-credit-card-form-csc"),r=a.payment.cardType(t.val()),e.call(this.enabled_card_types,r)<0?t.addClass("invalid-card-type"):t.removeClass("invalid-card-type"),a.payment.validateCardExpiry(i.payment("cardExpiryVal"))?i.addClass("identified"):i.removeClass("identified"),a.payment.validateCardCVC(n.val())?n.addClass("identified"):n.removeClass("identified")}},{key:"validate_card_data",value:function(){var e,t,r,n;return r=[],null!=(t=this.payment_fields.find(".js-sv-wc-payment-gateway-credit-card-form-csc").val())&&(t?(/\D/.test(t)&&r.push(this.params.cvv_digits_invalid),(t.length<3||t.length>4)&&r.push(this.params.cvv_length_invalid)):this.csc_required&&(this.saved_payment_method_selected&&!this.csc_required_for_tokens||r.push(this.params.cvv_missing))),this.saved_payment_method_selected||(e=this.payment_fields.find(".js-sv-wc-payment-gateway-credit-card-form-account-number").val(),n=a.payment.cardExpiryVal(this.payment_fields.find(".js-sv-wc-payment-gateway-credit-card-form-expiry").val()),(e=e.replace(/-|\s/g,""))?((e.length<12||e.length>19)&&r.push(this.params.card_number_length_invalid),/\D/.test(e)&&r.push(this.params.card_number_digits_invalid),a.payment.validateCardNumber(e)||r.push(this.params.card_number_invalid)):r.push(this.params.card_number_missing),a.payment.validateCardExpiry(n)||r.push(this.params.card_exp_date_invalid)),r.length>0?(this.render_errors(r),!1):(this.payment_fields.find(".js-sv-wc-payment-gateway-credit-card-form-account-number").val(e),!0)}},{key:"validate_account_data",value:function(){var e,t,a;return!!this.saved_payment_method_selected||(t=[],a=this.payment_fields.find(".js-sv-wc-payment-gateway-echeck-form-routing-number").val(),e=this.payment_fields.find(".js-sv-wc-payment-gateway-echeck-form-account-number").val(),a?(9!==a.length&&t.push(this.params.routing_number_length_invalid),/\D/.test(a)&&t.push(this.params.routing_number_digits_invalid)):t.push(this.params.routing_number_missing),e?((e.length<3||e.length>17)&&t.push(this.params.account_number_length_invalid),/\D/.test(e)&&t.push(this.params.account_number_invalid)):t.push(this.params.account_number_missing),t.length>0?(this.render_errors(t),!1):(this.payment_fields.find(".js-sv-wc-payment-gateway-echeck-form-account-number").val(e),!0))}},{key:"render_errors",value:function(e){return a(".woocommerce-error, .woocommerce-message").remove(),this.form.prepend('
    • '+e.join("
    • ")+"
    "),this.form.removeClass("processing").unblock(),this.form.find(".input-text, select").blur(),a("html, body").animate({scrollTop:this.form.offset().top-100},1e3)}},{key:"handle_saved_payment_methods",value:function(){var e,t,r,n;if(n=this.id_dasherized,this.csc_required,r=this.csc_required_for_tokens,t=a("div.js-wc-".concat(n,"-new-payment-method-form")),e=t.find(".js-sv-wc-payment-gateway-credit-card-form-csc").closest(".form-row"),a("input.js-wc-".concat(this.id_dasherized,"-payment-token")).on("change",function(){if(a("input.js-wc-".concat(n,"-payment-token:checked")).val()){if(t.slideUp(200),r)return e.removeClass("form-row-last").addClass("form-row-first"),t.after(e)}else if(t.slideDown(200),r)return e.removeClass("form-row-first").addClass("form-row-last"),t.find(".js-sv-wc-payment-gateway-credit-card-form-expiry").closest(".form-row").after(e)}).change(),a("input#createaccount").on("change",function(){var e;return e=a("input.js-wc-".concat(n,"-tokenize-payment-method")).closest("p.form-row"),a(this).is(":checked")?(e.slideDown(),e.next().show()):(e.hide(),e.next().hide())}),!a("input#createaccount").is(":checked"))return a("input#createaccount").change()}},{key:"handle_sample_check_hint",value:function(){var e;return(e=this.payment_fields.find(".js-sv-wc-payment-gateway-echeck-form-sample-check")).is(":visible")?e.slideUp():e.slideDown()}},{key:"block_ui",value:function(){return this.form.block({message:null,overlayCSS:{background:"#fff",opacity:.6}})}},{key:"unblock_ui",value:function(){return this.form.unblock()}}])}(),a(document.body).trigger("sv_wc_payment_form_handler_v5_13_1_loaded")})}).call(this); +function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(t)}function t(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){for(var a=0;a0&&e.trigger("change"),r.val()&&r.val().length>0&&r.trigger("change"),t.val()&&t.val().length>0&&t.trigger("change"),a(".js-sv-wc-payment-gateway-credit-card-form-input").on("change paste keyup",function(){return n.do_inline_credit_card_validation()})}},{key:"do_inline_credit_card_validation",value:function(){var t,r,n,i;return t=a(".js-sv-wc-payment-gateway-credit-card-form-account-number"),i=a(".js-sv-wc-payment-gateway-credit-card-form-expiry"),n=a(".js-sv-wc-payment-gateway-credit-card-form-csc"),r=a.payment.cardType(t.val()),e.call(this.enabled_card_types,r)<0?t.addClass("invalid-card-type"):t.removeClass("invalid-card-type"),a.payment.validateCardExpiry(i.payment("cardExpiryVal"))?i.addClass("identified"):i.removeClass("identified"),a.payment.validateCardCVC(n.val())?n.addClass("identified"):n.removeClass("identified")}},{key:"validate_card_data",value:function(){var e,t,r,n;return r=[],null!=(t=this.payment_fields.find(".js-sv-wc-payment-gateway-credit-card-form-csc").val())&&(t?(/\D/.test(t)&&r.push(this.params.cvv_digits_invalid),(t.length<3||t.length>4)&&r.push(this.params.cvv_length_invalid)):this.csc_required&&(this.saved_payment_method_selected&&!this.csc_required_for_tokens||r.push(this.params.cvv_missing))),this.saved_payment_method_selected||(e=this.payment_fields.find(".js-sv-wc-payment-gateway-credit-card-form-account-number").val(),n=a.payment.cardExpiryVal(this.payment_fields.find(".js-sv-wc-payment-gateway-credit-card-form-expiry").val()),(e=e.replace(/-|\s/g,""))?((e.length<12||e.length>19)&&r.push(this.params.card_number_length_invalid),/\D/.test(e)&&r.push(this.params.card_number_digits_invalid),a.payment.validateCardNumber(e)||r.push(this.params.card_number_invalid)):r.push(this.params.card_number_missing),a.payment.validateCardExpiry(n)||r.push(this.params.card_exp_date_invalid)),r.length>0?(this.render_errors(r),!1):(this.payment_fields.find(".js-sv-wc-payment-gateway-credit-card-form-account-number").val(e),!0)}},{key:"validate_account_data",value:function(){var e,t,a;return!!this.saved_payment_method_selected||(t=[],a=this.payment_fields.find(".js-sv-wc-payment-gateway-echeck-form-routing-number").val(),e=this.payment_fields.find(".js-sv-wc-payment-gateway-echeck-form-account-number").val(),a?(9!==a.length&&t.push(this.params.routing_number_length_invalid),/\D/.test(a)&&t.push(this.params.routing_number_digits_invalid)):t.push(this.params.routing_number_missing),e?((e.length<3||e.length>17)&&t.push(this.params.account_number_length_invalid),/\D/.test(e)&&t.push(this.params.account_number_invalid)):t.push(this.params.account_number_missing),t.length>0?(this.render_errors(t),!1):(this.payment_fields.find(".js-sv-wc-payment-gateway-echeck-form-account-number").val(e),!0))}},{key:"render_errors",value:function(e){return a(".woocommerce-error, .woocommerce-message").remove(),this.form.prepend('
    • '+e.join("
    • ")+"
    "),this.form.removeClass("processing").unblock(),this.form.find(".input-text, select").blur(),a("html, body").animate({scrollTop:this.form.offset().top-100},1e3)}},{key:"handle_saved_payment_methods",value:function(){var e,t,r,n;if(n=this.id_dasherized,this.csc_required,r=this.csc_required_for_tokens,t=a("div.js-wc-".concat(n,"-new-payment-method-form")),e=t.find(".js-sv-wc-payment-gateway-credit-card-form-csc").closest(".form-row"),a("input.js-wc-".concat(this.id_dasherized,"-payment-token")).on("change",function(){if(a("input.js-wc-".concat(n,"-payment-token:checked")).val()){if(t.slideUp(200),r)return e.removeClass("form-row-last").addClass("form-row-first"),t.after(e)}else if(t.slideDown(200),r)return e.removeClass("form-row-first").addClass("form-row-last"),t.find(".js-sv-wc-payment-gateway-credit-card-form-expiry").closest(".form-row").after(e)}).change(),a("input#createaccount").on("change",function(){var e;return e=a("input.js-wc-".concat(n,"-tokenize-payment-method")).closest("p.form-row"),a(this).is(":checked")?(e.slideDown(),e.next().show()):(e.hide(),e.next().hide())}),!a("input#createaccount").is(":checked"))return a("input#createaccount").change()}},{key:"handle_sample_check_hint",value:function(){var e;return(e=this.payment_fields.find(".js-sv-wc-payment-gateway-echeck-form-sample-check")).is(":visible")?e.slideUp():e.slideDown()}},{key:"block_ui",value:function(){return this.form.block({message:null,overlayCSS:{background:"#fff",opacity:.6}})}},{key:"unblock_ui",value:function(){return this.form.unblock()}}])}(),a(document.body).trigger("sv_wc_payment_form_handler_v5_14_0_loaded")})}).call(this); },{}]},{},["7JA8"], null) //# sourceMappingURL=../frontend/sv-wc-payment-gateway-payment-form.js.map diff --git a/woocommerce/payment-gateway/assets/dist/frontend/sv-wc-payment-gateway-payment-form.js.map b/woocommerce/payment-gateway/assets/dist/frontend/sv-wc-payment-gateway-payment-form.js.map index aa4a96b11..939fc8f84 100644 --- a/woocommerce/payment-gateway/assets/dist/frontend/sv-wc-payment-gateway-payment-form.js.map +++ b/woocommerce/payment-gateway/assets/dist/frontend/sv-wc-payment-gateway-payment-form.js.map @@ -1 +1 @@ -{"version":3,"sources":["frontend/sv-wc-payment-gateway-payment-form.coffee"],"names":["indexOf","jQuery","$","window","SV_WC_Payment_Form_Handler_v5_13_1","args","id","id_dasherized","plugin_id","type","csc_required","csc_required_for_tokens","enabled_card_types","length","form","handle_checkout_page","handle_pay_page","console","log","handle_add_payment_method_page","params","on","handle_sample_check_hint","document","trigger","instance","body","format_credit_card_inputs","set_payment_fields","handle_saved_payment_methods","validate_payment_data","submit","val","$required_fields","payment_fields","find","each","i","input","handler","valid","is","saved_payment_method_selected","validate_card_data","validate_account_data","triggerHandler","payment_form","passed_validation","$card_number","$csc","$expiry","payment","do_inline_credit_card_validation","$card_type","cardType","call","addClass","removeClass","validateCardExpiry","validateCardCVC","account_number","csc","errors","expiry","test","push","cvv_digits_invalid","cvv_length_invalid","cvv_missing","cardExpiryVal","replace","card_number_length_invalid","card_number_digits_invalid","validateCardNumber","card_number_invalid","card_number_missing","card_exp_date_invalid","render_errors","routing_number","routing_number_length_invalid","routing_number_digits_invalid","routing_number_missing","account_number_length_invalid","account_number_invalid","account_number_missing","remove","prepend","join","unblock","blur","animate","scrollTop","offset","top","$csc_field","$new_payment_method_selection","closest","tokenized_payment_method_selected","slideUp","after","slideDown","change","$parent_row","next","show","hide","$sample_check","block","message","overlayCSS","background","opacity"],"mappings":";AAAA,SAAA,EAAA,GAAA,OAAA,EAAA,mBAAA,QAAA,iBAAA,OAAA,SAAA,SAAA,GAAA,cAAA,GAAA,SAAA,GAAA,OAAA,GAAA,mBAAA,QAAA,EAAA,cAAA,QAAA,IAAA,OAAA,UAAA,gBAAA,IAAA,GAAA,SAAA,EAAA,EAAA,GAAA,KAAA,aAAA,GAAA,MAAA,IAAA,UAAA,qCAAA,SAAA,EAAA,EAAA,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SAAS,kBAC1CuC,EAA8BI,MAAML,QAMzCnF,GAFJoF,EAA8BK,UAAU,KAEpCzF,EAEKoF,OADPD,EAAWrC,YAAY,kBAAkBD,SAAS,iBAC3CuC,EAA8B5D,KAAK,qDAAqD6D,QAAQ,aAAaG,MAAML,KAG7HO,SAGHnG,EAAE,uBAAuBmB,GAAG,SAAU,WAChCiF,IAAAA,EAEApG,OADJoG,EAAcpG,EAAiBK,eAAAA,OAAAA,EAAjB,6BAA0DyF,QAAQ,cAC5E9F,EAAE,MAAMuC,GAAG,aACb6D,EAAYF,YACLE,EAAYC,OAAOC,SAE1BF,EAAYG,OACLH,EAAYC,OAAOE,WAGzBvG,EAAE,uBAAuBuC,GAAG,YACxBvC,OAAAA,EAAE,uBAAuBmG,WA9WtC,CAAA,IAAA,2BAqXE,MAAA,WACMK,IAAAA,EAEAA,OADJA,EAAgB,KAAKxE,eAAeC,KAAK,uDACvBM,GAAG,YACZiE,EAAcR,UAEdQ,EAAcN,cA3X3B,CAAA,IAAA,WAkYE,MAAA,WACS,OAAA,KAAKtF,KAAK6F,MAAM,CACrBC,QAAS,KACTC,WAAY,CACVC,WAAY,OACZC,QAAS,QAvYjB,CAAA,IAAA,aA+YE,MAAA,WACS,OAAA,KAAKjG,KAAK0E,cAhZrB,GAqZOtF,EAAEqB,SAASG,MAAMF,QAAQ,iDAGjC+B,KAAK","file":"sv-wc-payment-gateway-payment-form.js","sourceRoot":"../js","sourcesContent":["(function() {\n /*\n WooCommerce SkyVerge Payment Gateway Framework Payment Form CoffeeScript\n Version 4.3.0\n\n Copyright (c) 2014-2024, SkyVerge, Inc.\n Licensed under the GNU General Public License v3.0\n http://www.gnu.org/licenses/gpl-3.0.html\n */\n var indexOf = [].indexOf;\n\n jQuery(function($) {\n \"use strict\";\n window.SV_WC_Payment_Form_Handler_v5_13_1 = class SV_WC_Payment_Form_Handler_v5_13_1 {\n // Public: Instantiate Payment Form Handler\n\n // args - object with properties:\n // id - gateway ID\n // id_dasherized - gateway ID dasherized\n // plugin_id - plugin ID\n // type - gateway type, either `credit-card` or `echeck`\n // csc_required - true if the gateway requires the CSC field to be displayed\n\n // Returns SV_WC_Payment_Form_Handler_v5_13_1 instance\n constructor(args) {\n this.id = args.id;\n this.id_dasherized = args.id_dasherized;\n this.plugin_id = args.plugin_id;\n this.type = args.type;\n this.csc_required = args.csc_required;\n this.csc_required_for_tokens = args.csc_required_for_tokens;\n this.enabled_card_types = args.enabled_card_types;\n // which payment form?\n if ($('form.checkout').length) {\n this.form = $('form.checkout');\n this.handle_checkout_page();\n } else if ($('form#order_review').length) {\n this.form = $('form#order_review');\n this.handle_pay_page();\n } else if ($('form#add_payment_method').length) {\n this.form = $('form#add_payment_method');\n this.handle_add_payment_method_page();\n } else {\n console.log('No payment form found!');\n return;\n }\n // localized error messages\n this.params = window[\"sv_wc_payment_gateway_payment_form_params\"];\n if (this.type === 'echeck') {\n // handle sample check image hint\n this.form.on('click', '.js-sv-wc-payment-gateway-echeck-form-check-hint, .js-sv-wc-payment-gateway-echeck-form-sample-check', () => {\n return this.handle_sample_check_hint();\n });\n }\n $(document).trigger('sv_wc_payment_form_handler_init', {\n id: this.id,\n instance: this\n });\n }\n\n // Public: Handle required actions on the checkout page\n\n // Returns nothing.\n handle_checkout_page() {\n if (this.type === 'credit-card') {\n // format/validate credit card inputs using jQuery.payment\n $(document.body).on('updated_checkout', () => {\n return this.format_credit_card_inputs();\n });\n }\n // updated payment fields jQuery object on each checkout update (prevents stale data)\n $(document.body).on('updated_checkout', () => {\n return this.set_payment_fields();\n });\n // handle saved payment methods\n // note on the checkout page, this is bound to `updated_checkout` so it\n // fires even when other parts of the checkout are changed\n $(document.body).on('updated_checkout', () => {\n return this.handle_saved_payment_methods();\n });\n // validate payment data before order is submitted\n return this.form.on(`checkout_place_order_${this.id}`, () => {\n return this.validate_payment_data();\n });\n }\n\n // Public: Handle required actions on the Order > Pay page\n\n // Returns nothing.\n handle_pay_page() {\n this.set_payment_fields();\n // format/validate credit card inputs using jQuery.payment\n if (this.type === 'credit-card') {\n this.format_credit_card_inputs();\n }\n // handle saved payment methods\n this.handle_saved_payment_methods();\n // validate payment data before order is submitted\n return this.form.submit(() => {\n if ($('#order_review input[name=payment_method]:checked').val() === this.id) {\n // but only when one of our payment gateways is selected\n return this.validate_payment_data();\n }\n });\n }\n\n // Public: Handle required actions on the Add Payment Method page\n\n // Returns nothing.\n handle_add_payment_method_page() {\n this.set_payment_fields();\n // format/validate credit card inputs using jQuery.payment\n if (this.type === 'credit-card') {\n this.format_credit_card_inputs();\n }\n // validate payment data before order is submitted\n return this.form.submit(() => {\n if ($('#add_payment_method input[name=payment_method]:checked').val() === this.id) {\n // but only when one of our payment gateways is selected\n return this.validate_payment_data();\n }\n });\n }\n\n // Public: Set payment fields class variable, this is done\n // during the updated_checkout event as otherwise the reference to\n // the checkout fields becomes stale (somehow ¯\\_(ツ)_/¯)\n\n // This ensures payment fields are not marked as \"invalid\" before the customer has interacted with them.\n\n // Returns nothing.\n set_payment_fields() {\n var $required_fields;\n this.payment_fields = $(`.payment_method_${this.id}`);\n $required_fields = this.payment_fields.find('.validate-required .input-text');\n return $required_fields.each((i, input) => {\n // if any of the required fields have a value, bail this loop and proceed with WooCommerce validation\n if ($(input).val()) {\n return false;\n }\n // otherwise remove all validation result classes from the inputs, since the form is freshly loaded\n return $(input).trigger('input');\n });\n }\n\n // Public: Validate Payment data when order is placed\n\n // Returns boolean, true if payment data is valid, false otherwise\n validate_payment_data() {\n var handler, valid;\n if (this.form.is('.processing')) {\n // bail when already processing\n return false;\n }\n this.saved_payment_method_selected = this.payment_fields.find('.js-sv-wc-payment-gateway-payment-token:checked').val();\n // perform internal validations (all fields present & valid, etc)\n valid = this.type === 'credit-card' ? this.validate_card_data() : this.validate_account_data();\n // let gateways perform their own validation prior to form submission\n handler = $(document.body).triggerHandler('sv_wc_payment_form_valid_payment_data', {\n payment_form: this,\n passed_validation: valid\n }) !== false;\n return valid && handler;\n }\n\n // Public: format card data using jQuery.Payment\n\n // Returns nothing.\n format_credit_card_inputs() {\n var $card_number, $csc, $expiry;\n $card_number = $('.js-sv-wc-payment-gateway-credit-card-form-account-number').payment('formatCardNumber');\n $expiry = $('.js-sv-wc-payment-gateway-credit-card-form-expiry').payment('formatCardExpiry');\n $csc = $('.js-sv-wc-payment-gateway-credit-card-form-csc').payment('formatCardCVC');\n if ($card_number.val() && $card_number.val().length > 0) {\n $card_number.trigger('change');\n }\n if ($expiry.val() && $expiry.val().length > 0) {\n $expiry.trigger('change');\n }\n if ($csc.val() && $csc.val().length > 0) {\n $csc.trigger('change');\n }\n // perform inline validation on credit card inputs\n return $('.js-sv-wc-payment-gateway-credit-card-form-input').on('change paste keyup', () => {\n return this.do_inline_credit_card_validation();\n });\n }\n\n // Public: perform inline validation on credit card fields\n\n // Returns nothing.\n do_inline_credit_card_validation() {\n var $card_number, $card_type, $csc, $expiry;\n $card_number = $('.js-sv-wc-payment-gateway-credit-card-form-account-number');\n $expiry = $('.js-sv-wc-payment-gateway-credit-card-form-expiry');\n $csc = $('.js-sv-wc-payment-gateway-credit-card-form-csc');\n $card_type = $.payment.cardType($card_number.val());\n if (indexOf.call(this.enabled_card_types, $card_type) < 0) {\n $card_number.addClass('invalid-card-type');\n } else {\n $card_number.removeClass('invalid-card-type');\n }\n if ($.payment.validateCardExpiry($expiry.payment('cardExpiryVal'))) {\n $expiry.addClass('identified');\n } else {\n $expiry.removeClass('identified');\n }\n if ($.payment.validateCardCVC($csc.val())) {\n return $csc.addClass('identified');\n } else {\n return $csc.removeClass('identified');\n }\n }\n\n // Public: Perform validation on the credit card info entered\n\n // Return boolean, true if credit card info is valid, false otherwise\n validate_card_data() {\n var account_number, csc, errors, expiry;\n errors = [];\n csc = this.payment_fields.find('.js-sv-wc-payment-gateway-credit-card-form-csc').val();\n // always validate the CSC if present\n if (csc != null) {\n if (csc) {\n if (/\\D/.test(csc)) {\n errors.push(this.params.cvv_digits_invalid);\n }\n if (csc.length < 3 || csc.length > 4) {\n errors.push(this.params.cvv_length_invalid);\n }\n } else if (this.csc_required) {\n if (!this.saved_payment_method_selected || this.csc_required_for_tokens) {\n errors.push(this.params.cvv_missing);\n }\n }\n }\n // Only validate the other CC fields if necessary\n if (!this.saved_payment_method_selected) {\n account_number = this.payment_fields.find('.js-sv-wc-payment-gateway-credit-card-form-account-number').val();\n expiry = $.payment.cardExpiryVal(this.payment_fields.find('.js-sv-wc-payment-gateway-credit-card-form-expiry').val());\n // replace any dashes or spaces in the card number\n account_number = account_number.replace(/-|\\s/g, '');\n // validate card number\n if (!account_number) {\n errors.push(this.params.card_number_missing);\n } else {\n if (account_number.length < 12 || account_number.length > 19) {\n errors.push(this.params.card_number_length_invalid);\n }\n if (/\\D/.test(account_number)) {\n errors.push(this.params.card_number_digits_invalid);\n }\n if (!$.payment.validateCardNumber(account_number)) { // performs luhn check\n errors.push(this.params.card_number_invalid);\n }\n }\n if (!$.payment.validateCardExpiry(expiry)) { // validates future date\n \n // validate expiration date\n errors.push(this.params.card_exp_date_invalid);\n }\n }\n if (errors.length > 0) {\n this.render_errors(errors);\n return false;\n } else {\n // get rid of any space/dash characters\n this.payment_fields.find('.js-sv-wc-payment-gateway-credit-card-form-account-number').val(account_number);\n return true;\n }\n }\n\n // Public: Perform validation on the eCheck info entered\n\n // Return boolean, true if eCheck info is valid, false otherwise\n validate_account_data() {\n var account_number, errors, routing_number;\n if (this.saved_payment_method_selected) {\n return true;\n }\n errors = [];\n routing_number = this.payment_fields.find('.js-sv-wc-payment-gateway-echeck-form-routing-number').val();\n account_number = this.payment_fields.find('.js-sv-wc-payment-gateway-echeck-form-account-number').val();\n // validate routing number\n if (!routing_number) {\n errors.push(this.params.routing_number_missing);\n } else {\n if (9 !== routing_number.length) {\n errors.push(this.params.routing_number_length_invalid);\n }\n if (/\\D/.test(routing_number)) {\n errors.push(this.params.routing_number_digits_invalid);\n }\n }\n // validate account number\n if (!account_number) {\n errors.push(this.params.account_number_missing);\n } else {\n if (account_number.length < 3 || account_number.length > 17) {\n errors.push(this.params.account_number_length_invalid);\n }\n if (/\\D/.test(account_number)) {\n errors.push(this.params.account_number_invalid);\n }\n }\n if (errors.length > 0) {\n this.render_errors(errors);\n return false;\n } else {\n // get rid of any space/dash characters\n this.payment_fields.find('.js-sv-wc-payment-gateway-echeck-form-account-number').val(account_number);\n return true;\n }\n }\n\n // Public: Render any new errors and bring them into the viewport\n\n // Returns nothing.\n render_errors(errors) {\n // hide and remove any previous errors\n $('.woocommerce-error, .woocommerce-message').remove();\n // add errors\n this.form.prepend('
    • ' + errors.join('
    • ') + '
    ');\n // unblock UI\n this.form.removeClass('processing').unblock();\n this.form.find('.input-text, select').blur();\n // scroll to top\n return $('html, body').animate({\n scrollTop: this.form.offset().top - 100\n }, 1000);\n }\n\n // Public: Handle associated actions for saved payment methods\n\n // Returns nothing.\n handle_saved_payment_methods() {\n var $csc_field, $new_payment_method_selection, csc_required, csc_required_for_tokens, id_dasherized;\n // make available inside change events\n id_dasherized = this.id_dasherized;\n csc_required = this.csc_required;\n csc_required_for_tokens = this.csc_required_for_tokens;\n $new_payment_method_selection = $(`div.js-wc-${id_dasherized}-new-payment-method-form`);\n $csc_field = $new_payment_method_selection.find('.js-sv-wc-payment-gateway-credit-card-form-csc').closest('.form-row');\n // show/hide the saved payment methods when a saved payment method is de-selected/selected\n $(`input.js-wc-${this.id_dasherized}-payment-token`).on('change', function() {\n var tokenized_payment_method_selected;\n tokenized_payment_method_selected = $(`input.js-wc-${id_dasherized}-payment-token:checked`).val();\n if (tokenized_payment_method_selected) {\n // using an existing tokenized payment method, hide the 'new method' fields\n $new_payment_method_selection.slideUp(200);\n // move the CSC field out of the 'new method' fields so it can be used with the tokenized transaction\n if (csc_required_for_tokens) {\n $csc_field.removeClass('form-row-last').addClass('form-row-first');\n return $new_payment_method_selection.after($csc_field);\n }\n } else {\n // use new payment method, display the 'new method' fields\n $new_payment_method_selection.slideDown(200);\n // move the CSC field back into its regular spot\n if (csc_required_for_tokens) {\n $csc_field.removeClass('form-row-first').addClass('form-row-last');\n return $new_payment_method_selection.find('.js-sv-wc-payment-gateway-credit-card-form-expiry').closest('.form-row').after($csc_field);\n }\n }\n }).change();\n // display the 'save payment method' option for guest checkouts if the 'create account' option is checked\n // but only hide the input if there is a 'create account' checkbox (some themes just display the password)\n $('input#createaccount').on('change', function() {\n var $parent_row;\n $parent_row = $(`input.js-wc-${id_dasherized}-tokenize-payment-method`).closest('p.form-row');\n if ($(this).is(':checked')) {\n $parent_row.slideDown();\n return $parent_row.next().show();\n } else {\n $parent_row.hide();\n return $parent_row.next().hide();\n }\n });\n if (!$('input#createaccount').is(':checked')) {\n return $('input#createaccount').change();\n }\n }\n\n // Public: Handle showing/hiding the sample check image\n\n // Returns nothing.\n handle_sample_check_hint() {\n var $sample_check;\n $sample_check = this.payment_fields.find('.js-sv-wc-payment-gateway-echeck-form-sample-check');\n if ($sample_check.is(\":visible\")) {\n return $sample_check.slideUp();\n } else {\n return $sample_check.slideDown();\n }\n }\n\n // Blocks the payment form UI\n\n // @since 3.0.0\n block_ui() {\n return this.form.block({\n message: null,\n overlayCSS: {\n background: '#fff',\n opacity: 0.6\n }\n });\n }\n\n // Unblocks the payment form UI\n\n // @since 3.0.0\n unblock_ui() {\n return this.form.unblock();\n }\n\n };\n // dispatch loaded event\n return $(document.body).trigger(\"sv_wc_payment_form_handler_v5_13_1_loaded\");\n });\n\n}).call(this);\n"]} +{"version":3,"sources":["frontend/sv-wc-payment-gateway-payment-form.coffee"],"names":["indexOf","jQuery","$","window","SV_WC_Payment_Form_Handler_v5_14_0","args","id","id_dasherized","plugin_id","type","csc_required","csc_required_for_tokens","enabled_card_types","length","form","handle_checkout_page","handle_pay_page","console","log","handle_add_payment_method_page","params","on","handle_sample_check_hint","document","trigger","instance","body","format_credit_card_inputs","set_payment_fields","handle_saved_payment_methods","validate_payment_data","submit","val","$required_fields","payment_fields","find","each","i","input","handler","valid","is","saved_payment_method_selected","validate_card_data","validate_account_data","triggerHandler","payment_form","passed_validation","$card_number","$csc","$expiry","payment","do_inline_credit_card_validation","$card_type","cardType","call","addClass","removeClass","validateCardExpiry","validateCardCVC","account_number","csc","errors","expiry","test","push","cvv_digits_invalid","cvv_length_invalid","cvv_missing","cardExpiryVal","replace","card_number_length_invalid","card_number_digits_invalid","validateCardNumber","card_number_invalid","card_number_missing","card_exp_date_invalid","render_errors","routing_number","routing_number_length_invalid","routing_number_digits_invalid","routing_number_missing","account_number_length_invalid","account_number_invalid","account_number_missing","remove","prepend","join","unblock","blur","animate","scrollTop","offset","top","$csc_field","$new_payment_method_selection","closest","tokenized_payment_method_selected","slideUp","after","slideDown","change","$parent_row","next","show","hide","$sample_check","block","message","overlayCSS","background","opacity"],"mappings":";AAAA,SAAA,EAAA,GAAA,OAAA,EAAA,mBAAA,QAAA,iBAAA,OAAA,SAAA,SAAA,GAAA,cAAA,GAAA,SAAA,GAAA,OAAA,GAAA,mBAAA,QAAA,EAAA,cAAA,QAAA,IAAA,OAAA,UAAA,gBAAA,IAAA,GAAA,SAAA,EAAA,EAAA,GAAA,KAAA,aAAA,GAAA,MAAA,IAAA,UAAA,qCAAA,SAAA,EAAA,EAAA,GAAA,IAAA,IAAA,EAAA,EAAA,EAAA,EAAA,OAAA,IAAA,CAAA,IAAA,EAAA,EAAA,GAAA,EAAA,WAAA,EAAA,aAAA,EAAA,EAAA,cAAA,EAAA,UAAA,IAAA,EAAA,UAAA,GAAA,OAAA,eAAA,EAAA,EAAA,EAAA,KAAA,IAAA,SAAA,EAAA,EAAA,EAAA,GAAA,OAAA,GAAA,EAAA,EAAA,UAAA,GAAA,GAAA,EAAA,EAAA,GAAA,OAAA,eAAA,EAAA,YAAA,CAAA,UAAA,IAAA,EAAA,SAAA,EAAA,GAAA,IAAA,EAAA,EAAA,EAAA,UAAA,MAAA,UAAA,EAAA,GAAA,EAAA,EAAA,GAAA,SAAA,EAAA,EAAA,GAAA,GAAA,UAAA,EAAA,KAAA,EAAA,OAAA,EAAA,IAAA,EAAA,EAAA,OAAA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EAEAA,OADJA,EAAgB,KAAKxE,eAAeC,KAAK,uDACvBM,GAAG,YACZiE,EAAcR,UAEdQ,EAAcN,cA3X3B,CAAA,IAAA,WAkYE,MAAA,WACS,OAAA,KAAKtF,KAAK6F,MAAM,CACrBC,QAAS,KACTC,WAAY,CACVC,WAAY,OACZC,QAAS,QAvYjB,CAAA,IAAA,aA+YE,MAAA,WACS,OAAA,KAAKjG,KAAK0E,cAhZrB,GAqZOtF,EAAEqB,SAASG,MAAMF,QAAQ,iDAGjC+B,KAAK","file":"sv-wc-payment-gateway-payment-form.js","sourceRoot":"../js","sourcesContent":["(function() {\n /*\n WooCommerce SkyVerge Payment Gateway Framework Payment Form CoffeeScript\n Version 4.3.0\n\n Copyright (c) 2014-2024, SkyVerge, Inc.\n Licensed under the GNU General Public License v3.0\n http://www.gnu.org/licenses/gpl-3.0.html\n */\n var indexOf = [].indexOf;\n\n jQuery(function($) {\n \"use strict\";\n window.SV_WC_Payment_Form_Handler_v5_14_0 = class SV_WC_Payment_Form_Handler_v5_14_0 {\n // Public: Instantiate Payment Form Handler\n\n // args - object with properties:\n // id - gateway ID\n // id_dasherized - gateway ID dasherized\n // plugin_id - plugin ID\n // type - gateway type, either `credit-card` or `echeck`\n // csc_required - true if the gateway requires the CSC field to be displayed\n\n // Returns SV_WC_Payment_Form_Handler_v5_14_0 instance\n constructor(args) {\n this.id = args.id;\n this.id_dasherized = args.id_dasherized;\n this.plugin_id = args.plugin_id;\n this.type = args.type;\n this.csc_required = args.csc_required;\n this.csc_required_for_tokens = args.csc_required_for_tokens;\n this.enabled_card_types = args.enabled_card_types;\n // which payment form?\n if ($('form.checkout').length) {\n this.form = $('form.checkout');\n this.handle_checkout_page();\n } else if ($('form#order_review').length) {\n this.form = $('form#order_review');\n this.handle_pay_page();\n } else if ($('form#add_payment_method').length) {\n this.form = $('form#add_payment_method');\n this.handle_add_payment_method_page();\n } else {\n console.log('No payment form found!');\n return;\n }\n // localized error messages\n this.params = window[\"sv_wc_payment_gateway_payment_form_params\"];\n if (this.type === 'echeck') {\n // handle sample check image hint\n this.form.on('click', '.js-sv-wc-payment-gateway-echeck-form-check-hint, .js-sv-wc-payment-gateway-echeck-form-sample-check', () => {\n return this.handle_sample_check_hint();\n });\n }\n $(document).trigger('sv_wc_payment_form_handler_init', {\n id: this.id,\n instance: this\n });\n }\n\n // Public: Handle required actions on the checkout page\n\n // Returns nothing.\n handle_checkout_page() {\n if (this.type === 'credit-card') {\n // format/validate credit card inputs using jQuery.payment\n $(document.body).on('updated_checkout', () => {\n return this.format_credit_card_inputs();\n });\n }\n // updated payment fields jQuery object on each checkout update (prevents stale data)\n $(document.body).on('updated_checkout', () => {\n return this.set_payment_fields();\n });\n // handle saved payment methods\n // note on the checkout page, this is bound to `updated_checkout` so it\n // fires even when other parts of the checkout are changed\n $(document.body).on('updated_checkout', () => {\n return this.handle_saved_payment_methods();\n });\n // validate payment data before order is submitted\n return this.form.on(`checkout_place_order_${this.id}`, () => {\n return this.validate_payment_data();\n });\n }\n\n // Public: Handle required actions on the Order > Pay page\n\n // Returns nothing.\n handle_pay_page() {\n this.set_payment_fields();\n // format/validate credit card inputs using jQuery.payment\n if (this.type === 'credit-card') {\n this.format_credit_card_inputs();\n }\n // handle saved payment methods\n this.handle_saved_payment_methods();\n // validate payment data before order is submitted\n return this.form.submit(() => {\n if ($('#order_review input[name=payment_method]:checked').val() === this.id) {\n // but only when one of our payment gateways is selected\n return this.validate_payment_data();\n }\n });\n }\n\n // Public: Handle required actions on the Add Payment Method page\n\n // Returns nothing.\n handle_add_payment_method_page() {\n this.set_payment_fields();\n // format/validate credit card inputs using jQuery.payment\n if (this.type === 'credit-card') {\n this.format_credit_card_inputs();\n }\n // validate payment data before order is submitted\n return this.form.submit(() => {\n if ($('#add_payment_method input[name=payment_method]:checked').val() === this.id) {\n // but only when one of our payment gateways is selected\n return this.validate_payment_data();\n }\n });\n }\n\n // Public: Set payment fields class variable, this is done\n // during the updated_checkout event as otherwise the reference to\n // the checkout fields becomes stale (somehow ¯\\_(ツ)_/¯)\n\n // This ensures payment fields are not marked as \"invalid\" before the customer has interacted with them.\n\n // Returns nothing.\n set_payment_fields() {\n var $required_fields;\n this.payment_fields = $(`.payment_method_${this.id}`);\n $required_fields = this.payment_fields.find('.validate-required .input-text');\n return $required_fields.each((i, input) => {\n // if any of the required fields have a value, bail this loop and proceed with WooCommerce validation\n if ($(input).val()) {\n return false;\n }\n // otherwise remove all validation result classes from the inputs, since the form is freshly loaded\n return $(input).trigger('input');\n });\n }\n\n // Public: Validate Payment data when order is placed\n\n // Returns boolean, true if payment data is valid, false otherwise\n validate_payment_data() {\n var handler, valid;\n if (this.form.is('.processing')) {\n // bail when already processing\n return false;\n }\n this.saved_payment_method_selected = this.payment_fields.find('.js-sv-wc-payment-gateway-payment-token:checked').val();\n // perform internal validations (all fields present & valid, etc)\n valid = this.type === 'credit-card' ? this.validate_card_data() : this.validate_account_data();\n // let gateways perform their own validation prior to form submission\n handler = $(document.body).triggerHandler('sv_wc_payment_form_valid_payment_data', {\n payment_form: this,\n passed_validation: valid\n }) !== false;\n return valid && handler;\n }\n\n // Public: format card data using jQuery.Payment\n\n // Returns nothing.\n format_credit_card_inputs() {\n var $card_number, $csc, $expiry;\n $card_number = $('.js-sv-wc-payment-gateway-credit-card-form-account-number').payment('formatCardNumber');\n $expiry = $('.js-sv-wc-payment-gateway-credit-card-form-expiry').payment('formatCardExpiry');\n $csc = $('.js-sv-wc-payment-gateway-credit-card-form-csc').payment('formatCardCVC');\n if ($card_number.val() && $card_number.val().length > 0) {\n $card_number.trigger('change');\n }\n if ($expiry.val() && $expiry.val().length > 0) {\n $expiry.trigger('change');\n }\n if ($csc.val() && $csc.val().length > 0) {\n $csc.trigger('change');\n }\n // perform inline validation on credit card inputs\n return $('.js-sv-wc-payment-gateway-credit-card-form-input').on('change paste keyup', () => {\n return this.do_inline_credit_card_validation();\n });\n }\n\n // Public: perform inline validation on credit card fields\n\n // Returns nothing.\n do_inline_credit_card_validation() {\n var $card_number, $card_type, $csc, $expiry;\n $card_number = $('.js-sv-wc-payment-gateway-credit-card-form-account-number');\n $expiry = $('.js-sv-wc-payment-gateway-credit-card-form-expiry');\n $csc = $('.js-sv-wc-payment-gateway-credit-card-form-csc');\n $card_type = $.payment.cardType($card_number.val());\n if (indexOf.call(this.enabled_card_types, $card_type) < 0) {\n $card_number.addClass('invalid-card-type');\n } else {\n $card_number.removeClass('invalid-card-type');\n }\n if ($.payment.validateCardExpiry($expiry.payment('cardExpiryVal'))) {\n $expiry.addClass('identified');\n } else {\n $expiry.removeClass('identified');\n }\n if ($.payment.validateCardCVC($csc.val())) {\n return $csc.addClass('identified');\n } else {\n return $csc.removeClass('identified');\n }\n }\n\n // Public: Perform validation on the credit card info entered\n\n // Return boolean, true if credit card info is valid, false otherwise\n validate_card_data() {\n var account_number, csc, errors, expiry;\n errors = [];\n csc = this.payment_fields.find('.js-sv-wc-payment-gateway-credit-card-form-csc').val();\n // always validate the CSC if present\n if (csc != null) {\n if (csc) {\n if (/\\D/.test(csc)) {\n errors.push(this.params.cvv_digits_invalid);\n }\n if (csc.length < 3 || csc.length > 4) {\n errors.push(this.params.cvv_length_invalid);\n }\n } else if (this.csc_required) {\n if (!this.saved_payment_method_selected || this.csc_required_for_tokens) {\n errors.push(this.params.cvv_missing);\n }\n }\n }\n // Only validate the other CC fields if necessary\n if (!this.saved_payment_method_selected) {\n account_number = this.payment_fields.find('.js-sv-wc-payment-gateway-credit-card-form-account-number').val();\n expiry = $.payment.cardExpiryVal(this.payment_fields.find('.js-sv-wc-payment-gateway-credit-card-form-expiry').val());\n // replace any dashes or spaces in the card number\n account_number = account_number.replace(/-|\\s/g, '');\n // validate card number\n if (!account_number) {\n errors.push(this.params.card_number_missing);\n } else {\n if (account_number.length < 12 || account_number.length > 19) {\n errors.push(this.params.card_number_length_invalid);\n }\n if (/\\D/.test(account_number)) {\n errors.push(this.params.card_number_digits_invalid);\n }\n if (!$.payment.validateCardNumber(account_number)) { // performs luhn check\n errors.push(this.params.card_number_invalid);\n }\n }\n if (!$.payment.validateCardExpiry(expiry)) { // validates future date\n \n // validate expiration date\n errors.push(this.params.card_exp_date_invalid);\n }\n }\n if (errors.length > 0) {\n this.render_errors(errors);\n return false;\n } else {\n // get rid of any space/dash characters\n this.payment_fields.find('.js-sv-wc-payment-gateway-credit-card-form-account-number').val(account_number);\n return true;\n }\n }\n\n // Public: Perform validation on the eCheck info entered\n\n // Return boolean, true if eCheck info is valid, false otherwise\n validate_account_data() {\n var account_number, errors, routing_number;\n if (this.saved_payment_method_selected) {\n return true;\n }\n errors = [];\n routing_number = this.payment_fields.find('.js-sv-wc-payment-gateway-echeck-form-routing-number').val();\n account_number = this.payment_fields.find('.js-sv-wc-payment-gateway-echeck-form-account-number').val();\n // validate routing number\n if (!routing_number) {\n errors.push(this.params.routing_number_missing);\n } else {\n if (9 !== routing_number.length) {\n errors.push(this.params.routing_number_length_invalid);\n }\n if (/\\D/.test(routing_number)) {\n errors.push(this.params.routing_number_digits_invalid);\n }\n }\n // validate account number\n if (!account_number) {\n errors.push(this.params.account_number_missing);\n } else {\n if (account_number.length < 3 || account_number.length > 17) {\n errors.push(this.params.account_number_length_invalid);\n }\n if (/\\D/.test(account_number)) {\n errors.push(this.params.account_number_invalid);\n }\n }\n if (errors.length > 0) {\n this.render_errors(errors);\n return false;\n } else {\n // get rid of any space/dash characters\n this.payment_fields.find('.js-sv-wc-payment-gateway-echeck-form-account-number').val(account_number);\n return true;\n }\n }\n\n // Public: Render any new errors and bring them into the viewport\n\n // Returns nothing.\n render_errors(errors) {\n // hide and remove any previous errors\n $('.woocommerce-error, .woocommerce-message').remove();\n // add errors\n this.form.prepend('
    • ' + errors.join('
    • ') + '
    ');\n // unblock UI\n this.form.removeClass('processing').unblock();\n this.form.find('.input-text, select').blur();\n // scroll to top\n return $('html, body').animate({\n scrollTop: this.form.offset().top - 100\n }, 1000);\n }\n\n // Public: Handle associated actions for saved payment methods\n\n // Returns nothing.\n handle_saved_payment_methods() {\n var $csc_field, $new_payment_method_selection, csc_required, csc_required_for_tokens, id_dasherized;\n // make available inside change events\n id_dasherized = this.id_dasherized;\n csc_required = this.csc_required;\n csc_required_for_tokens = this.csc_required_for_tokens;\n $new_payment_method_selection = $(`div.js-wc-${id_dasherized}-new-payment-method-form`);\n $csc_field = $new_payment_method_selection.find('.js-sv-wc-payment-gateway-credit-card-form-csc').closest('.form-row');\n // show/hide the saved payment methods when a saved payment method is de-selected/selected\n $(`input.js-wc-${this.id_dasherized}-payment-token`).on('change', function() {\n var tokenized_payment_method_selected;\n tokenized_payment_method_selected = $(`input.js-wc-${id_dasherized}-payment-token:checked`).val();\n if (tokenized_payment_method_selected) {\n // using an existing tokenized payment method, hide the 'new method' fields\n $new_payment_method_selection.slideUp(200);\n // move the CSC field out of the 'new method' fields so it can be used with the tokenized transaction\n if (csc_required_for_tokens) {\n $csc_field.removeClass('form-row-last').addClass('form-row-first');\n return $new_payment_method_selection.after($csc_field);\n }\n } else {\n // use new payment method, display the 'new method' fields\n $new_payment_method_selection.slideDown(200);\n // move the CSC field back into its regular spot\n if (csc_required_for_tokens) {\n $csc_field.removeClass('form-row-first').addClass('form-row-last');\n return $new_payment_method_selection.find('.js-sv-wc-payment-gateway-credit-card-form-expiry').closest('.form-row').after($csc_field);\n }\n }\n }).change();\n // display the 'save payment method' option for guest checkouts if the 'create account' option is checked\n // but only hide the input if there is a 'create account' checkbox (some themes just display the password)\n $('input#createaccount').on('change', function() {\n var $parent_row;\n $parent_row = $(`input.js-wc-${id_dasherized}-tokenize-payment-method`).closest('p.form-row');\n if ($(this).is(':checked')) {\n $parent_row.slideDown();\n return $parent_row.next().show();\n } else {\n $parent_row.hide();\n return $parent_row.next().hide();\n }\n });\n if (!$('input#createaccount').is(':checked')) {\n return $('input#createaccount').change();\n }\n }\n\n // Public: Handle showing/hiding the sample check image\n\n // Returns nothing.\n handle_sample_check_hint() {\n var $sample_check;\n $sample_check = this.payment_fields.find('.js-sv-wc-payment-gateway-echeck-form-sample-check');\n if ($sample_check.is(\":visible\")) {\n return $sample_check.slideUp();\n } else {\n return $sample_check.slideDown();\n }\n }\n\n // Blocks the payment form UI\n\n // @since 3.0.0\n block_ui() {\n return this.form.block({\n message: null,\n overlayCSS: {\n background: '#fff',\n opacity: 0.6\n }\n });\n }\n\n // Unblocks the payment form UI\n\n // @since 3.0.0\n unblock_ui() {\n return this.form.unblock();\n }\n\n };\n // dispatch loaded event\n return $(document.body).trigger(\"sv_wc_payment_form_handler_v5_14_0_loaded\");\n });\n\n}).call(this);\n"]} diff --git a/woocommerce/payment-gateway/assets/js/frontend/sv-wc-payment-gateway-apple-pay.coffee b/woocommerce/payment-gateway/assets/js/frontend/sv-wc-payment-gateway-apple-pay.coffee index 6866e594b..7c2918377 100644 --- a/woocommerce/payment-gateway/assets/js/frontend/sv-wc-payment-gateway-apple-pay.coffee +++ b/woocommerce/payment-gateway/assets/js/frontend/sv-wc-payment-gateway-apple-pay.coffee @@ -14,7 +14,7 @@ jQuery ( $ ) -> # The WooCommerce Apple Pay handler base class. # # @since 4.7.0 - class window.SV_WC_Apple_Pay_Handler_v5_13_1 + class window.SV_WC_Apple_Pay_Handler_v5_14_0 # Constructs the handler. @@ -440,4 +440,4 @@ jQuery ( $ ) -> # dispatch loaded event - $( document.body ).trigger( 'sv_wc_apple_pay_handler_v5_13_1_loaded' ) + $( document.body ).trigger( 'sv_wc_apple_pay_handler_v5_14_0_loaded' ) diff --git a/woocommerce/payment-gateway/assets/js/frontend/sv-wc-payment-gateway-google-pay.js b/woocommerce/payment-gateway/assets/js/frontend/sv-wc-payment-gateway-google-pay.js index da6159aec..3248d1b3b 100644 --- a/woocommerce/payment-gateway/assets/js/frontend/sv-wc-payment-gateway-google-pay.js +++ b/woocommerce/payment-gateway/assets/js/frontend/sv-wc-payment-gateway-google-pay.js @@ -7,9 +7,9 @@ jQuery( function( $ ) { * * @since 5.10.0 * - * @type {SV_WC_Google_Pay_Handler_v5_13_1} object + * @type {SV_WC_Google_Pay_Handler_v5_14_0} object */ - window.SV_WC_Google_Pay_Handler_v5_13_1 = class SV_WC_Google_Pay_Handler_v5_13_1 { + window.SV_WC_Google_Pay_Handler_v5_14_0 = class SV_WC_Google_Pay_Handler_v5_14_0 { /** * Handler constructor. @@ -609,6 +609,6 @@ jQuery( function( $ ) { } } - $( document.body ).trigger( 'sv_wc_google_pay_handler_v5_13_1_loaded' ); + $( document.body ).trigger( 'sv_wc_google_pay_handler_v5_14_0_loaded' ); } ); diff --git a/woocommerce/payment-gateway/assets/js/frontend/sv-wc-payment-gateway-my-payment-methods.coffee b/woocommerce/payment-gateway/assets/js/frontend/sv-wc-payment-gateway-my-payment-methods.coffee index 447662f81..bcaa9e583 100644 --- a/woocommerce/payment-gateway/assets/js/frontend/sv-wc-payment-gateway-my-payment-methods.coffee +++ b/woocommerce/payment-gateway/assets/js/frontend/sv-wc-payment-gateway-my-payment-methods.coffee @@ -12,7 +12,7 @@ jQuery ( $ ) -> # The My Payment Methods handler. # # @since 5.1.0 - class window.SV_WC_Payment_Methods_Handler_v5_13_1 + class window.SV_WC_Payment_Methods_Handler_v5_14_0 # Constructs the class. @@ -270,4 +270,4 @@ jQuery ( $ ) -> # dispatch loaded event - $( document.body ).trigger( 'sv_wc_payment_methods_handler_v5_13_1_loaded' ) + $( document.body ).trigger( 'sv_wc_payment_methods_handler_v5_14_0_loaded' ) diff --git a/woocommerce/payment-gateway/assets/js/frontend/sv-wc-payment-gateway-payment-form.coffee b/woocommerce/payment-gateway/assets/js/frontend/sv-wc-payment-gateway-payment-form.coffee index 31920e3ac..d650809fb 100644 --- a/woocommerce/payment-gateway/assets/js/frontend/sv-wc-payment-gateway-payment-form.coffee +++ b/woocommerce/payment-gateway/assets/js/frontend/sv-wc-payment-gateway-payment-form.coffee @@ -10,7 +10,7 @@ jQuery ( $ ) -> "use strict" - class window.SV_WC_Payment_Form_Handler_v5_13_1 + class window.SV_WC_Payment_Form_Handler_v5_14_0 # Public: Instantiate Payment Form Handler @@ -22,7 +22,7 @@ jQuery ( $ ) -> # type - gateway type, either `credit-card` or `echeck` # csc_required - true if the gateway requires the CSC field to be displayed # - # Returns SV_WC_Payment_Form_Handler_v5_13_1 instance + # Returns SV_WC_Payment_Form_Handler_v5_14_0 instance constructor: (args) -> @id = args.id @@ -385,4 +385,4 @@ jQuery ( $ ) -> # dispatch loaded event - $( document.body ).trigger( "sv_wc_payment_form_handler_v5_13_1_loaded" ) + $( document.body ).trigger( "sv_wc_payment_form_handler_v5_14_0_loaded" ) diff --git a/woocommerce/payment-gateway/class-sv-wc-payment-gateway-direct.php b/woocommerce/payment-gateway/class-sv-wc-payment-gateway-direct.php index ba380e79f..84845b676 100644 --- a/woocommerce/payment-gateway/class-sv-wc-payment-gateway-direct.php +++ b/woocommerce/payment-gateway/class-sv-wc-payment-gateway-direct.php @@ -22,13 +22,13 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 */ -namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1; +namespace SkyVerge\WooCommerce\PluginFramework\v5_14_0; -use SkyVerge\WooCommerce\PluginFramework\v5_13_1\Blocks\Blocks_Handler; +use SkyVerge\WooCommerce\PluginFramework\v5_14_0\Blocks\Blocks_Handler; defined( 'ABSPATH' ) or exit; -if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\SV_WC_Payment_Gateway_Direct' ) ) : +if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_14_0\\SV_WC_Payment_Gateway_Direct' ) ) : /** diff --git a/woocommerce/payment-gateway/class-sv-wc-payment-gateway-helper.php b/woocommerce/payment-gateway/class-sv-wc-payment-gateway-helper.php index f2c06ce8e..6c13c1982 100755 --- a/woocommerce/payment-gateway/class-sv-wc-payment-gateway-helper.php +++ b/woocommerce/payment-gateway/class-sv-wc-payment-gateway-helper.php @@ -22,11 +22,11 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 */ -namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1; +namespace SkyVerge\WooCommerce\PluginFramework\v5_14_0; defined( 'ABSPATH' ) or exit; -if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\SV_WC_Payment_Gateway_Helper' ) ) : +if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_14_0\\SV_WC_Payment_Gateway_Helper' ) ) : /** diff --git a/woocommerce/payment-gateway/class-sv-wc-payment-gateway-hosted.php b/woocommerce/payment-gateway/class-sv-wc-payment-gateway-hosted.php index 73656bb45..1f5f0b9c1 100644 --- a/woocommerce/payment-gateway/class-sv-wc-payment-gateway-hosted.php +++ b/woocommerce/payment-gateway/class-sv-wc-payment-gateway-hosted.php @@ -22,11 +22,11 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 */ -namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1; +namespace SkyVerge\WooCommerce\PluginFramework\v5_14_0; defined( 'ABSPATH' ) or exit; -if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\SV_WC_Payment_Gateway_Hosted' ) ) : +if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_14_0\\SV_WC_Payment_Gateway_Hosted' ) ) : /** diff --git a/woocommerce/payment-gateway/class-sv-wc-payment-gateway-my-payment-methods.php b/woocommerce/payment-gateway/class-sv-wc-payment-gateway-my-payment-methods.php index d43ce2996..55b1fc630 100644 --- a/woocommerce/payment-gateway/class-sv-wc-payment-gateway-my-payment-methods.php +++ b/woocommerce/payment-gateway/class-sv-wc-payment-gateway-my-payment-methods.php @@ -22,11 +22,11 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 */ -namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1; +namespace SkyVerge\WooCommerce\PluginFramework\v5_14_0; defined( 'ABSPATH' ) or exit; -if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\SV_WC_Payment_Gateway_My_Payment_Methods' ) ) : +if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_14_0\\SV_WC_Payment_Gateway_My_Payment_Methods' ) ) : /** @@ -174,9 +174,9 @@ public function maybe_enqueue_styles_scripts() { wp_register_script( 'jquery-tiptip', WC()->plugin_url() . '/assets/js/jquery-tiptip/jquery.tipTip.min.js', [ 'jquery' ], $wc_version ); - wp_enqueue_style( "$handle-v5_13_1", $this->get_plugin()->get_payment_gateway_framework_assets_url() . '/css/frontend/' . $handle . '.min.css', [ 'dashicons' ], $fw_version ); + wp_enqueue_style( "$handle-v5_14_0", $this->get_plugin()->get_payment_gateway_framework_assets_url() . '/css/frontend/' . $handle . '.min.css', [ 'dashicons' ], $fw_version ); - wp_enqueue_script( "$handle-v5_13_1", $this->get_plugin()->get_payment_gateway_framework_assets_url() . '/dist/frontend/' . $handle . '.js', [ 'jquery-tiptip', 'jquery' ], $fw_version ); + wp_enqueue_script( "$handle-v5_14_0", $this->get_plugin()->get_payment_gateway_framework_assets_url() . '/dist/frontend/' . $handle . '.js', [ 'jquery-tiptip', 'jquery' ], $fw_version ); } diff --git a/woocommerce/payment-gateway/class-sv-wc-payment-gateway-payment-form.php b/woocommerce/payment-gateway/class-sv-wc-payment-gateway-payment-form.php index 1d6be21d5..c0c8b1596 100644 --- a/woocommerce/payment-gateway/class-sv-wc-payment-gateway-payment-form.php +++ b/woocommerce/payment-gateway/class-sv-wc-payment-gateway-payment-form.php @@ -22,15 +22,15 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 */ -namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1; +namespace SkyVerge\WooCommerce\PluginFramework\v5_14_0; -use SkyVerge\WooCommerce\PluginFramework\v5_13_1\Blocks\Blocks_Handler; -use SkyVerge\WooCommerce\PluginFramework\v5_13_1\Enums\PaymentFormContext; -use SkyVerge\WooCommerce\PluginFramework\v5_13_1\Payment_Gateway\Blocks\Gateway_Checkout_Block_Integration; +use SkyVerge\WooCommerce\PluginFramework\v5_14_0\Blocks\Blocks_Handler; +use SkyVerge\WooCommerce\PluginFramework\v5_14_0\Enums\PaymentFormContext; +use SkyVerge\WooCommerce\PluginFramework\v5_14_0\Payment_Gateway\Blocks\Gateway_Checkout_Block_Integration; defined( 'ABSPATH' ) or exit; -if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\SV_WC_Payment_Gateway_Payment_Form' ) ) : +if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_14_0\\SV_WC_Payment_Gateway_Payment_Form' ) ) : /** @@ -1180,7 +1180,7 @@ protected function get_js_handler_args() { if ( is_array( $card_types ) && ! empty( $card_types ) ) { - $args['enabled_card_types'] = array_map( [ 'SkyVerge\WooCommerce\PluginFramework\v5_13_1\SV_WC_Payment_Gateway_Helper', 'normalize_card_type' ], $card_types ); + $args['enabled_card_types'] = array_map( [ 'SkyVerge\WooCommerce\PluginFramework\v5_14_0\SV_WC_Payment_Gateway_Helper', 'normalize_card_type' ], $card_types ); } } diff --git a/woocommerce/payment-gateway/class-sv-wc-payment-gateway-plugin.php b/woocommerce/payment-gateway/class-sv-wc-payment-gateway-plugin.php index fea9a3003..509826f54 100644 --- a/woocommerce/payment-gateway/class-sv-wc-payment-gateway-plugin.php +++ b/woocommerce/payment-gateway/class-sv-wc-payment-gateway-plugin.php @@ -22,16 +22,16 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 */ -namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1; +namespace SkyVerge\WooCommerce\PluginFramework\v5_14_0; use Automattic\WooCommerce\Admin\Notes\WC_Admin_Note; use Automattic\WooCommerce\Admin\Notes\WC_Admin_Notes; -use SkyVerge\WooCommerce\PluginFramework\v5_13_1\Payment_Gateway\Blocks\Gateway_Blocks_Handler; -use SkyVerge\WooCommerce\PluginFramework\v5_13_1\Payment_Gateway\External_Checkout\Google_Pay\Google_Pay; +use SkyVerge\WooCommerce\PluginFramework\v5_14_0\Payment_Gateway\Blocks\Gateway_Blocks_Handler; +use SkyVerge\WooCommerce\PluginFramework\v5_14_0\Payment_Gateway\External_Checkout\Google_Pay\Google_Pay; defined( 'ABSPATH' ) or exit; -if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\SV_WC_Payment_Gateway_Plugin' ) ) : +if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_14_0\\SV_WC_Payment_Gateway_Plugin' ) ) : /** diff --git a/woocommerce/payment-gateway/class-sv-wc-payment-gateway-privacy.php b/woocommerce/payment-gateway/class-sv-wc-payment-gateway-privacy.php index 631e503d3..60326796c 100644 --- a/woocommerce/payment-gateway/class-sv-wc-payment-gateway-privacy.php +++ b/woocommerce/payment-gateway/class-sv-wc-payment-gateway-privacy.php @@ -22,11 +22,11 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 */ -namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1; +namespace SkyVerge\WooCommerce\PluginFramework\v5_14_0; defined( 'ABSPATH' ) or exit; -if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\SV_WC_Payment_Gateway_Privacy' ) ) : +if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_14_0\\SV_WC_Payment_Gateway_Privacy' ) ) : /** diff --git a/woocommerce/payment-gateway/class-sv-wc-payment-gateway.php b/woocommerce/payment-gateway/class-sv-wc-payment-gateway.php index 157a6c63d..0d8196298 100755 --- a/woocommerce/payment-gateway/class-sv-wc-payment-gateway.php +++ b/woocommerce/payment-gateway/class-sv-wc-payment-gateway.php @@ -22,16 +22,16 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 */ -namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1; +namespace SkyVerge\WooCommerce\PluginFramework\v5_14_0; use Automattic\WooCommerce\Blocks\Integrations\IntegrationInterface; -use SkyVerge\WooCommerce\PluginFramework\v5_13_1\Blocks\Blocks_Handler; -use SkyVerge\WooCommerce\PluginFramework\v5_13_1\Payment_Gateway\Blocks\Gateway_Checkout_Block_Integration; +use SkyVerge\WooCommerce\PluginFramework\v5_14_0\Blocks\Blocks_Handler; +use SkyVerge\WooCommerce\PluginFramework\v5_14_0\Payment_Gateway\Blocks\Gateway_Checkout_Block_Integration; use stdClass; defined( 'ABSPATH' ) or exit; -if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\SV_WC_Payment_Gateway' ) ) : +if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_14_0\\SV_WC_Payment_Gateway' ) ) : /** @@ -473,7 +473,7 @@ protected function enqueue_payment_form_assets() { } $handle = 'sv-wc-payment-gateway-payment-form'; - $versioned_handle = $handle . '-v5_13_1'; + $versioned_handle = $handle . '-v5_14_0'; // Frontend JS wp_enqueue_script( $versioned_handle, $this->get_plugin()->get_payment_gateway_framework_assets_url() . '/dist/frontend/' . $handle . '.js', array( 'jquery-payment' ), SV_WC_Plugin::VERSION, true ); diff --git a/woocommerce/payment-gateway/exceptions/class-sv-wc-payment-gateway-exception.php b/woocommerce/payment-gateway/exceptions/class-sv-wc-payment-gateway-exception.php index 4ac23a1c4..3b6a12251 100644 --- a/woocommerce/payment-gateway/exceptions/class-sv-wc-payment-gateway-exception.php +++ b/woocommerce/payment-gateway/exceptions/class-sv-wc-payment-gateway-exception.php @@ -22,11 +22,11 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 */ -namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1; +namespace SkyVerge\WooCommerce\PluginFramework\v5_14_0; defined( 'ABSPATH' ) or exit; -if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\SV_WC_Payment_Gateway_Exception' ) ) : +if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_14_0\\SV_WC_Payment_Gateway_Exception' ) ) : /** diff --git a/woocommerce/payment-gateway/integrations/abstract-sv-wc-payment-gateway-integration.php b/woocommerce/payment-gateway/integrations/abstract-sv-wc-payment-gateway-integration.php index 760e1c993..6299eba52 100644 --- a/woocommerce/payment-gateway/integrations/abstract-sv-wc-payment-gateway-integration.php +++ b/woocommerce/payment-gateway/integrations/abstract-sv-wc-payment-gateway-integration.php @@ -22,11 +22,11 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 */ -namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1; +namespace SkyVerge\WooCommerce\PluginFramework\v5_14_0; defined( 'ABSPATH' ) or exit; -if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\SV_WC_Payment_Gateway_Integration' ) ) : +if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_14_0\\SV_WC_Payment_Gateway_Integration' ) ) : /** diff --git a/woocommerce/payment-gateway/integrations/class-sv-wc-payment-gateway-integration-pre-orders.php b/woocommerce/payment-gateway/integrations/class-sv-wc-payment-gateway-integration-pre-orders.php index 18dd77997..720602294 100644 --- a/woocommerce/payment-gateway/integrations/class-sv-wc-payment-gateway-integration-pre-orders.php +++ b/woocommerce/payment-gateway/integrations/class-sv-wc-payment-gateway-integration-pre-orders.php @@ -22,11 +22,11 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 */ -namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1; +namespace SkyVerge\WooCommerce\PluginFramework\v5_14_0; defined( 'ABSPATH' ) or exit; -if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\SV_WC_Payment_Gateway_Integration_Pre_Orders' ) ) : +if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_14_0\\SV_WC_Payment_Gateway_Integration_Pre_Orders' ) ) : /** diff --git a/woocommerce/payment-gateway/integrations/class-sv-wc-payment-gateway-integration-subscriptions.php b/woocommerce/payment-gateway/integrations/class-sv-wc-payment-gateway-integration-subscriptions.php index c4270678f..d39e66060 100644 --- a/woocommerce/payment-gateway/integrations/class-sv-wc-payment-gateway-integration-subscriptions.php +++ b/woocommerce/payment-gateway/integrations/class-sv-wc-payment-gateway-integration-subscriptions.php @@ -22,11 +22,11 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 */ -namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1; +namespace SkyVerge\WooCommerce\PluginFramework\v5_14_0; defined( 'ABSPATH' ) or exit; -if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\SV_WC_Payment_Gateway_Integration_Subscriptions' ) ) : +if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_14_0\\SV_WC_Payment_Gateway_Integration_Subscriptions' ) ) : /** diff --git a/woocommerce/payment-gateway/payment-tokens/class-sv-wc-payment-gateway-payment-token.php b/woocommerce/payment-gateway/payment-tokens/class-sv-wc-payment-gateway-payment-token.php index 7cd01bd18..af396956d 100644 --- a/woocommerce/payment-gateway/payment-tokens/class-sv-wc-payment-gateway-payment-token.php +++ b/woocommerce/payment-gateway/payment-tokens/class-sv-wc-payment-gateway-payment-token.php @@ -22,11 +22,11 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 */ -namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1; +namespace SkyVerge\WooCommerce\PluginFramework\v5_14_0; defined( 'ABSPATH' ) or exit; -if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\SV_WC_Payment_Gateway_Payment_Token' ) ) : +if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_14_0\\SV_WC_Payment_Gateway_Payment_Token' ) ) : /** diff --git a/woocommerce/payment-gateway/payment-tokens/class-sv-wc-payment-gateway-payment-tokens-handler.php b/woocommerce/payment-gateway/payment-tokens/class-sv-wc-payment-gateway-payment-tokens-handler.php index d52ddbc0b..1af5ab9c6 100644 --- a/woocommerce/payment-gateway/payment-tokens/class-sv-wc-payment-gateway-payment-tokens-handler.php +++ b/woocommerce/payment-gateway/payment-tokens/class-sv-wc-payment-gateway-payment-tokens-handler.php @@ -22,11 +22,11 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 */ -namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1; +namespace SkyVerge\WooCommerce\PluginFramework\v5_14_0; defined( 'ABSPATH' ) or exit; -if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\SV_WC_Payment_Gateway_Payment_Tokens_Handler' ) ) : +if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_14_0\\SV_WC_Payment_Gateway_Payment_Tokens_Handler' ) ) : /** diff --git a/woocommerce/payment-gateway/rest-api/class-sv-wc-payment-gateway-plugin-rest-api.php b/woocommerce/payment-gateway/rest-api/class-sv-wc-payment-gateway-plugin-rest-api.php index d71604aff..d33a5e585 100644 --- a/woocommerce/payment-gateway/rest-api/class-sv-wc-payment-gateway-plugin-rest-api.php +++ b/woocommerce/payment-gateway/rest-api/class-sv-wc-payment-gateway-plugin-rest-api.php @@ -22,19 +22,19 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 */ -namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1\Payment_Gateway; +namespace SkyVerge\WooCommerce\PluginFramework\v5_14_0\Payment_Gateway; -use SkyVerge\WooCommerce\PluginFramework\v5_13_1\REST_API as Plugin_REST_API; +use SkyVerge\WooCommerce\PluginFramework\v5_14_0\REST_API as Plugin_REST_API; defined( 'ABSPATH' ) or exit; -if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\Payment_Gateway\\REST_API' ) ) : +if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_14_0\\Payment_Gateway\\REST_API' ) ) : /** * The payment gateway plugin REST API handler class. * - * @see \SkyVerge\WooCommerce\PluginFramework\v5_13_1\REST_API + * @see \SkyVerge\WooCommerce\PluginFramework\v5_14_0\REST_API * * @since 5.2.0 */ @@ -47,7 +47,7 @@ class REST_API extends Plugin_REST_API { * * Plugins can override this to add their own data. * - * @see \SkyVerge\WooCommerce\PluginFramework\v5_13_1\REST_API::get_system_status_data() + * @see \SkyVerge\WooCommerce\PluginFramework\v5_14_0\REST_API::get_system_status_data() * * @since 5.2.0 * diff --git a/woocommerce/rest-api/Controllers/Settings.php b/woocommerce/rest-api/Controllers/Settings.php index 07e0b1c49..50b8abcdf 100644 --- a/woocommerce/rest-api/Controllers/Settings.php +++ b/woocommerce/rest-api/Controllers/Settings.php @@ -22,14 +22,14 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 */ -namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1\REST_API\Controllers; +namespace SkyVerge\WooCommerce\PluginFramework\v5_14_0\REST_API\Controllers; -use SkyVerge\WooCommerce\PluginFramework\v5_13_1\Settings_API\Abstract_Settings; -use SkyVerge\WooCommerce\PluginFramework\v5_13_1\Settings_API\Setting; +use SkyVerge\WooCommerce\PluginFramework\v5_14_0\Settings_API\Abstract_Settings; +use SkyVerge\WooCommerce\PluginFramework\v5_14_0\Settings_API\Setting; defined( 'ABSPATH' ) or exit; -if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\REST_API\\Controllers\\Settings' ) ) : +if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_14_0\\REST_API\\Controllers\\Settings' ) ) : /** diff --git a/woocommerce/rest-api/class-sv-wc-plugin-rest-api.php b/woocommerce/rest-api/class-sv-wc-plugin-rest-api.php index b3f6f0e69..354227c0d 100644 --- a/woocommerce/rest-api/class-sv-wc-plugin-rest-api.php +++ b/woocommerce/rest-api/class-sv-wc-plugin-rest-api.php @@ -22,11 +22,11 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 */ -namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1; +namespace SkyVerge\WooCommerce\PluginFramework\v5_14_0; defined( 'ABSPATH' ) or exit; -if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\REST_API' ) ) : +if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_14_0\\REST_API' ) ) : /** diff --git a/woocommerce/utilities/class-sv-wp-async-request.php b/woocommerce/utilities/class-sv-wp-async-request.php index afac0883f..7032bdbf3 100644 --- a/woocommerce/utilities/class-sv-wp-async-request.php +++ b/woocommerce/utilities/class-sv-wp-async-request.php @@ -23,11 +23,11 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 */ -namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1; +namespace SkyVerge\WooCommerce\PluginFramework\v5_14_0; defined( 'ABSPATH' ) or exit; -if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\SV_WP_Async_Request' ) ) : +if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_14_0\\SV_WP_Async_Request' ) ) : /** diff --git a/woocommerce/utilities/class-sv-wp-background-job-handler.php b/woocommerce/utilities/class-sv-wp-background-job-handler.php index 152816a23..470ea7472 100644 --- a/woocommerce/utilities/class-sv-wp-background-job-handler.php +++ b/woocommerce/utilities/class-sv-wp-background-job-handler.php @@ -23,11 +23,11 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 */ -namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1; +namespace SkyVerge\WooCommerce\PluginFramework\v5_14_0; defined( 'ABSPATH' ) or exit; -if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\SV_WP_Background_Job_Handler' ) ) : +if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_14_0\\SV_WP_Background_Job_Handler' ) ) : /** diff --git a/woocommerce/utilities/class-sv-wp-job-batch-handler.php b/woocommerce/utilities/class-sv-wp-job-batch-handler.php index d1cc71659..f06498fc0 100644 --- a/woocommerce/utilities/class-sv-wp-job-batch-handler.php +++ b/woocommerce/utilities/class-sv-wp-job-batch-handler.php @@ -22,11 +22,11 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 */ - namespace SkyVerge\WooCommerce\PluginFramework\v5_13_1; + namespace SkyVerge\WooCommerce\PluginFramework\v5_14_0; defined( 'ABSPATH' ) or exit; - if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_13_1\\SV_WP_Job_Batch_Handler' ) ) : + if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_14_0\\SV_WP_Job_Batch_Handler' ) ) : /** From 7337b61b7d828b945a6beb424cc4c666277bbfac Mon Sep 17 00:00:00 2001 From: Nabeel Molham Date: Thu, 29 Aug 2024 12:56:02 +1000 Subject: [PATCH 41/62] Merge branch 'release/5.14.0' into chore/setup-autoloading # Conflicts: # tests/unit/Helpers/CountryHelperTest.php # tests/unit/Payment_Gateway/PaymentFormContextCheckerTest.php # woocommerce/Handlers/Country_Helper.php # woocommerce/payment-gateway/Blocks/Gateway_Blocks_Handler.php # woocommerce/payment-gateway/PaymentFormContextChecker.php --- tests/unit/AutoloadingTest.php | 66 +++++++++++++++++----------------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/tests/unit/AutoloadingTest.php b/tests/unit/AutoloadingTest.php index 692243934..f08912df3 100644 --- a/tests/unit/AutoloadingTest.php +++ b/tests/unit/AutoloadingTest.php @@ -1,38 +1,38 @@ \SkyVerge\WooCommerce\PluginFramework\v5_13_1\Country_Helper::class, - PaymentFormContextChecker::class => \SkyVerge\WooCommerce\PluginFramework\v5_13_1\PaymentFormContextChecker::class, + Country_Helper::class => \SkyVerge\WooCommerce\PluginFramework\v5_14_0\Country_Helper::class, + PaymentFormContextChecker::class => \SkyVerge\WooCommerce\PluginFramework\v5_14_0\PaymentFormContextChecker::class, ]; foreach ($aliases as $alias) { From 2d51e6dd19ab4ac9daab44b9ad94b00cc9e67ebc Mon Sep 17 00:00:00 2001 From: Nabeel Molham Date: Thu, 29 Aug 2024 13:01:09 +1000 Subject: [PATCH 42/62] Move Lifcycle class under corresponding namespace --- composer.json | 3 +-- tests/unit/AutoloadingTest.php | 2 ++ woocommerce/{ => Plugin}/Lifecycle.php | 6 ------ 3 files changed, 3 insertions(+), 8 deletions(-) rename woocommerce/{ => Plugin}/Lifecycle.php (99%) diff --git a/composer.json b/composer.json index a83a62d7d..4df375aef 100644 --- a/composer.json +++ b/composer.json @@ -32,8 +32,7 @@ "woocommerce/class-sv-wc-plugin-compatibility.php", "woocommerce/class-sv-wc-plugin-dependencies.php", "woocommerce/class-sv-wc-plugin-exception.php", - "woocommerce/class-sv-wp-admin-message-handler.php", - "woocommerce/Lifecycle.php" + "woocommerce/class-sv-wp-admin-message-handler.php" ], "psr-4": { "SkyVerge\\WooCommerce\\PluginFramework\\v5_14_0\\": "woocommerce/" diff --git a/tests/unit/AutoloadingTest.php b/tests/unit/AutoloadingTest.php index f08912df3..2c34ce64e 100644 --- a/tests/unit/AutoloadingTest.php +++ b/tests/unit/AutoloadingTest.php @@ -17,6 +17,7 @@ use SkyVerge\WooCommerce\PluginFramework\v5_14_0\Payment_Gateway\External_Checkout\Orders; use SkyVerge\WooCommerce\PluginFramework\v5_14_0\Payment_Gateway\Handlers; use SkyVerge\WooCommerce\PluginFramework\v5_14_0\Payment_Gateway\PaymentFormContextChecker; +use SkyVerge\WooCommerce\PluginFramework\v5_14_0\Plugin\Lifecycle; use SkyVerge\WooCommerce\PluginFramework\v5_14_0\REST_API; use SkyVerge\WooCommerce\PluginFramework\v5_14_0\Settings_API; use SkyVerge\WooCommerce\PluginFramework\v5_14_0\SV_WC_Admin_Notice_Handler; @@ -89,6 +90,7 @@ public function providerCanAutoload() : Generator SV_WP_Job_Batch_Handler::class, SV_WC_Admin_Notice_Handler::class, SV_WP_Admin_Message_Handler::class, + Lifecycle::class, ]; foreach ($list as $className) { diff --git a/woocommerce/Lifecycle.php b/woocommerce/Plugin/Lifecycle.php similarity index 99% rename from woocommerce/Lifecycle.php rename to woocommerce/Plugin/Lifecycle.php index f7e9939de..529efd030 100644 --- a/woocommerce/Lifecycle.php +++ b/woocommerce/Plugin/Lifecycle.php @@ -31,9 +31,6 @@ defined( 'ABSPATH' ) or exit; -if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_14_0\\Plugin\\Lifecycle' ) ) : - - /** * Plugin lifecycle handler. * @@ -664,6 +661,3 @@ protected function get_plugin() { } - - -endif; From d2725d9c9aa3d4f759554569678f58e0035174ba Mon Sep 17 00:00:00 2001 From: Nabeel Molham Date: Thu, 29 Aug 2024 13:04:32 +1000 Subject: [PATCH 43/62] Update plugin loader example --- ...ommerce-framework-plugin-loader-sample.php | 24 ++----------------- 1 file changed, 2 insertions(+), 22 deletions(-) diff --git a/woocommerce-framework-plugin-loader-sample.php b/woocommerce-framework-plugin-loader-sample.php index 134db2288..c28610dfc 100644 --- a/woocommerce-framework-plugin-loader-sample.php +++ b/woocommerce-framework-plugin-loader-sample.php @@ -131,13 +131,11 @@ public function init_plugin() { return; } - $this->load_framework(); - - /** If the plugin is structured for PSR-4, do the following: - // autoload plugin and vendor files $loader = require_once( plugin_dir_path( __FILE__ ) . 'vendor/autoload.php' ); + /** If the plugin is structured for PSR-4, do the following: + // register plugin namespace with autoloader $loader->addPsr4( 'SkyVerge\\WooCommerce\\Plugin_Name\\', __DIR__ . '/includes' ); // TODO: plugin namespace here @@ -158,24 +156,6 @@ public function init_plugin() { } - /** - * Loads the base framework classes. - * - * @since 1.0.0 - */ - private function load_framework() { - - if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\' . $this->get_framework_version_namespace() . '\\SV_WC_Plugin' ) ) { - require_once( plugin_dir_path( __FILE__ ) . 'lib/skyverge/woocommerce/class-sv-wc-plugin.php' ); - } - - // TODO: remove this if not a payment gateway - if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\' . $this->get_framework_version_namespace() . '\\SV_WC_Payment_Gateway_Plugin' ) ) { - require_once( plugin_dir_path( __FILE__ ) . 'lib/skyverge/woocommerce/payment-gateway/class-sv-wc-payment-gateway-plugin.php' ); - } - } - - /** * Gets the framework version in namespace form. * From e9cbdf580312ccb16aec993e1770a5ead643fb5c Mon Sep 17 00:00:00 2001 From: Nabeel Molham Date: Thu, 29 Aug 2024 13:07:32 +1000 Subject: [PATCH 44/62] Remove redundant woothemes_queue_update --- woocommerce-framework-plugin-loader-sample.php | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/woocommerce-framework-plugin-loader-sample.php b/woocommerce-framework-plugin-loader-sample.php index c28610dfc..b2d862faf 100644 --- a/woocommerce-framework-plugin-loader-sample.php +++ b/woocommerce-framework-plugin-loader-sample.php @@ -26,19 +26,6 @@ defined( 'ABSPATH' ) or exit; -// Required functions -if ( ! function_exists( 'woothemes_queue_update' ) ) { - require_once( plugin_dir_path( __FILE__ ) . 'woo-includes/woo-functions.php' ); -} - -// Plugin updates -woothemes_queue_update( plugin_basename( __FILE__ ), '00000000000000000000000000000000', '99999' ); // TODO: updater keys - -// WC active check -if ( ! is_woocommerce_active() ) { - return; -} - /** * The plugin loader class. * From 468918502c34a106f321686e64afd74c1adcecd8 Mon Sep 17 00:00:00 2001 From: Nabeel Molham Date: Thu, 29 Aug 2024 17:55:49 +1000 Subject: [PATCH 45/62] Add assert helper method with logging --- woocommerce/class-sv-wc-plugin.php | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/woocommerce/class-sv-wc-plugin.php b/woocommerce/class-sv-wc-plugin.php index 84601dbc6..4d88ff091 100644 --- a/woocommerce/class-sv-wc-plugin.php +++ b/woocommerce/class-sv-wc-plugin.php @@ -26,6 +26,8 @@ use Automattic\WooCommerce\Utilities\FeaturesUtil; use stdClass; +use Throwable; +use WC_Logger_Interface; defined( 'ABSPATH' ) or exit; @@ -67,8 +69,8 @@ abstract class SV_WC_Plugin { /** @var string template path, without trailing slash */ private $template_path; - /** @var \WC_Logger instance */ - private $logger; + /** @var WC_Logger_Interface|null instance */ + private ?WC_Logger_Interface $logger = null; /** @var SV_WP_Admin_Message_Handler instance */ private $message_handler; @@ -548,7 +550,7 @@ private function get_framework_deprecated_hooks() { $deprecated_hooks[ $deprecated_filter ] = [ 'removed' => true, 'replacement' => false, - 'version' => '5.8.1' + 'version' => '5.8.1', ]; } @@ -825,13 +827,22 @@ public function log( $message, $log_id = null ) { $log_id = $this->get_id(); } - if ( ! is_object( $this->logger ) ) { - $this->logger = new \WC_Logger(); - } + $this->logger()->add( $log_id, $message ); + } - $this->logger->add( $log_id, $message ); + protected function logger() : WC_Logger_Interface + { + return $this->logger ??= wc_get_logger(); } + public function assert($assertion) : void + { + try { + assert($assertion); + } catch (Throwable $exception) { + $this->logger()->debug('Assertion failed, backtrace summery: '.wp_debug_backtrace_summary()); + } + } /** * Require and instantiate a class @@ -1446,8 +1457,6 @@ public function is_plugin_active( $plugin_name ) { return $is_active; } - - } From 329227f8d4b63d6b65a948a76d248d0fb71830c9 Mon Sep 17 00:00:00 2001 From: Nabeel Molham Date: Thu, 29 Aug 2024 17:56:09 +1000 Subject: [PATCH 46/62] Replace native assert with plugin's assert method --- .../class-sv-wc-payment-gateway-direct.php | 2 +- .../class-sv-wc-payment-gateway-plugin.php | 8 +++---- .../class-sv-wc-payment-gateway.php | 24 +++++++++---------- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/woocommerce/payment-gateway/class-sv-wc-payment-gateway-direct.php b/woocommerce/payment-gateway/class-sv-wc-payment-gateway-direct.php index 84845b676..f883b6cb2 100644 --- a/woocommerce/payment-gateway/class-sv-wc-payment-gateway-direct.php +++ b/woocommerce/payment-gateway/class-sv-wc-payment-gateway-direct.php @@ -937,7 +937,7 @@ protected function do_transaction( $order ) { */ public function add_payment_method() { - assert( $this->supports_add_payment_method() ); + $this->get_plugin()->assert( $this->supports_add_payment_method() ); $order = $this->get_order_for_add_payment_method(); diff --git a/woocommerce/payment-gateway/class-sv-wc-payment-gateway-plugin.php b/woocommerce/payment-gateway/class-sv-wc-payment-gateway-plugin.php index 509826f54..42d5baff3 100644 --- a/woocommerce/payment-gateway/class-sv-wc-payment-gateway-plugin.php +++ b/woocommerce/payment-gateway/class-sv-wc-payment-gateway-plugin.php @@ -1273,7 +1273,7 @@ public function add_gateway( $gateway_id, $gateway_class_name ) { */ public function get_gateway_class_names() { - assert( ! empty( $this->gateways ) ); + $this->assert( ! empty( $this->gateways ) ); $gateway_class_names = array(); @@ -1295,7 +1295,7 @@ public function get_gateway_class_names() { */ public function get_gateway_class_name( $gateway_id ) { - assert( isset( $this->gateways[ $gateway_id ]['gateway_class_name'] ) ); + $this->assert( isset( $this->gateways[ $gateway_id ]['gateway_class_name'] ) ); return $this->gateways[ $gateway_id ]['gateway_class_name']; } @@ -1311,7 +1311,7 @@ public function get_gateway_class_name( $gateway_id ) { */ public function get_gateways() { - assert( ! empty( $this->gateways ) ); + $this->assert( ! empty( $this->gateways ) ); $gateways = array(); @@ -1385,7 +1385,7 @@ public function has_gateway( $gateway_id ) { */ public function get_gateway_ids() { - assert( ! empty( $this->gateways ) ); + $this->assert( ! empty( $this->gateways ) ); return array_keys( $this->gateways ); } diff --git a/woocommerce/payment-gateway/class-sv-wc-payment-gateway.php b/woocommerce/payment-gateway/class-sv-wc-payment-gateway.php index 0d8196298..8ac88d728 100755 --- a/woocommerce/payment-gateway/class-sv-wc-payment-gateway.php +++ b/woocommerce/payment-gateway/class-sv-wc-payment-gateway.php @@ -943,7 +943,7 @@ public function get_payment_form_instance() { */ public function get_payment_method_defaults() { - assert( $this->supports_payment_form() ); + $this->get_plugin()->assert( $this->supports_payment_form() ); $defaults = array( 'account-number' => '', @@ -3301,7 +3301,7 @@ public function supports_credit_card_partial_capture() { */ protected function add_authorization_charge_form_fields( $form_fields ) { - assert( $this->supports_credit_card_authorization() && $this->supports_credit_card_charge() ); + $this->get_plugin()->assert( $this->supports_credit_card_authorization() && $this->supports_credit_card_charge() ); $form_fields['transaction_type'] = array( 'title' => esc_html__( 'Transaction Type', 'woocommerce-plugin-framework' ), @@ -3381,7 +3381,7 @@ public function get_authorization_time_window() { */ public function perform_credit_card_charge( \WC_Order $order = null ) { - assert( $this->supports_credit_card_charge() ); + $this->get_plugin()->assert( $this->supports_credit_card_charge() ); $perform = self::TRANSACTION_TYPE_CHARGE === $this->transaction_type; @@ -3412,7 +3412,7 @@ public function perform_credit_card_charge( \WC_Order $order = null ) { */ public function perform_credit_card_authorization( \WC_Order $order = null ) { - assert( $this->supports_credit_card_authorization() ); + $this->get_plugin()->assert( $this->supports_credit_card_authorization() ); $perform = self::TRANSACTION_TYPE_AUTHORIZATION === $this->transaction_type && ! $this->perform_credit_card_charge( $order ); @@ -3437,7 +3437,7 @@ public function perform_credit_card_authorization( \WC_Order $order = null ) { */ public function is_partial_capture_enabled() { - assert( $this->supports_credit_card_partial_capture() ); + $this->get_plugin()->assert( $this->supports_credit_card_partial_capture() ); /** * Filters whether partial capture is enabled. @@ -3516,7 +3516,7 @@ public function supports_card_types() { */ public function get_card_types() { - assert( $this->supports_card_types() ); + $this->get_plugin()->assert( $this->supports_card_types() ); return is_array( $this->card_types ) ? $this->card_types : []; } @@ -3532,7 +3532,7 @@ public function get_card_types() { */ protected function add_card_types_form_fields( $form_fields ) { - assert( $this->supports_card_types() ); + $this->get_plugin()->assert( $this->supports_card_types() ); $form_fields['card_types'] = array( 'title' => esc_html__( 'Accepted Card Logos', 'woocommerce-plugin-framework' ), @@ -3562,7 +3562,7 @@ protected function add_card_types_form_fields( $form_fields ) { */ public function get_available_card_types() { - assert( $this->supports_card_types() ); + $this->get_plugin()->assert( $this->supports_card_types() ); // default available card types if ( ! isset( $this->available_card_types ) ) { @@ -3612,7 +3612,7 @@ public function supports_tokenization() { */ public function tokenization_enabled() { - assert( $this->supports_tokenization() ); + $this->get_plugin()->assert( $this->supports_tokenization() ); return 'yes' == $this->tokenization; } @@ -3627,7 +3627,7 @@ public function tokenization_enabled() { */ protected function add_tokenization_form_fields( $form_fields ) { - assert( $this->supports_tokenization() ); + $this->get_plugin()->assert( $this->supports_tokenization() ); $form_fields['tokenization'] = array( /* translators: http://www.cybersource.com/products/payment_security/payment_tokenization/ and https://en.wikipedia.org/wiki/Tokenization_(data_security) */ @@ -4142,7 +4142,7 @@ public function set_supports( $features ) { */ public function supports_check_field( $field_name ) { - assert( $this->is_echeck_gateway() ); + $this->get_plugin()->assert( $this->is_echeck_gateway() ); return is_array( $this->supported_check_fields ) && in_array( $field_name, $this->supported_check_fields ); @@ -4478,7 +4478,7 @@ protected function is_processing_context( string $context ): bool { public function get_api() { // concrete stub method - assert( false ); + $this->get_plugin()->assert( false ); } From 5caffd5553a86dd729479b72909db478c405bf2e Mon Sep 17 00:00:00 2001 From: Nabeel Molham Date: Thu, 29 Aug 2024 18:07:55 +1000 Subject: [PATCH 47/62] Unit test SV_WC_Plugin::logger method --- tests/unit/PluginTest.php | 50 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 tests/unit/PluginTest.php diff --git a/tests/unit/PluginTest.php b/tests/unit/PluginTest.php new file mode 100644 index 000000000..860263913 --- /dev/null +++ b/tests/unit/PluginTest.php @@ -0,0 +1,50 @@ +testObject = Mockery::mock(SV_WC_Plugin::class) + ->shouldAllowMockingProtectedMethods() + ->makePartial(); + } + + /** + * @covers \SkyVerge\WooCommerce\PluginFramework\v5_14_0\SV_WC_Plugin::logger() + * @throws ReflectionException + */ + public function testCanGetLogger() : void + { + WP_Mock::userFunction('wc_get_logger') + ->once() + ->andReturn($logger = Mockery::mock('WC_Logger_Interface')); + + $this->assertSame( + $logger, + $this->invokeInaccessibleMethod($this->testObject, 'logger') + ); + + $this->assertSame( + $logger, + $this->invokeInaccessibleMethod($this->testObject, 'logger') + ); + } +} From 4ed4e05303cb1022767639f3da4c377b5e8d7081 Mon Sep 17 00:00:00 2001 From: Nabeel Molham Date: Thu, 29 Aug 2024 18:11:55 +1000 Subject: [PATCH 48/62] Unit test SV_WC_Plugin::assert method --- tests/unit/PluginTest.php | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/tests/unit/PluginTest.php b/tests/unit/PluginTest.php index 860263913..6cbe720fc 100644 --- a/tests/unit/PluginTest.php +++ b/tests/unit/PluginTest.php @@ -47,4 +47,42 @@ public function testCanGetLogger() : void $this->invokeInaccessibleMethod($this->testObject, 'logger') ); } + + /** + * @covers \SkyVerge\WooCommerce\PluginFramework\v5_14_0\SV_WC_Plugin::assert() + * @throws ReflectionException + */ + public function testCanAssert() : void + { + WP_Mock::userFunction('wp_debug_backtrace_summary')->never(); + + $this->testObject->expects('logger')->never(); + + $this->assertNull( + $this->invokeInaccessibleMethod($this->testObject, 'assert', true) + ); + } + + /** + * @covers \SkyVerge\WooCommerce\PluginFramework\v5_14_0\SV_WC_Plugin::assert() + * @throws ReflectionException + */ + public function testCanCatchFailedAssertion() : void + { + WP_Mock::userFunction('wp_debug_backtrace_summary') + ->once() + ->andReturn('TEST_DEBUG_BACKTRACE_SUMMARY'); + + $this->testObject->expects('logger') + ->once() + ->andReturn($logger = Mockery::mock('WC_Logger_Interface')); + + $logger->expects('debug') + ->once() + ->with('Assertion failed, backtrace summery: TEST_DEBUG_BACKTRACE_SUMMARY'); + + $this->assertNull( + $this->invokeInaccessibleMethod($this->testObject, 'assert', false) + ); + } } From 637dd23d04d192481fa84596c62126205035f327 Mon Sep 17 00:00:00 2001 From: Nabeel Molham Date: Thu, 29 Aug 2024 18:28:55 +1000 Subject: [PATCH 49/62] Enable assert ini setting --- tests/unit/PluginTest.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/unit/PluginTest.php b/tests/unit/PluginTest.php index 6cbe720fc..d710d2413 100644 --- a/tests/unit/PluginTest.php +++ b/tests/unit/PluginTest.php @@ -69,6 +69,9 @@ public function testCanAssert() : void */ public function testCanCatchFailedAssertion() : void { + $initValue = ini_get('zend.assertions'); + ini_set('zend.assertions', 1); + WP_Mock::userFunction('wp_debug_backtrace_summary') ->once() ->andReturn('TEST_DEBUG_BACKTRACE_SUMMARY'); @@ -84,5 +87,7 @@ public function testCanCatchFailedAssertion() : void $this->assertNull( $this->invokeInaccessibleMethod($this->testObject, 'assert', false) ); + + ini_set('zend.assertions', $initValue); } } From 499ba4f5fdb4cbe94c4038532a044de9e0d005d5 Mon Sep 17 00:00:00 2001 From: Nabeel Molham Date: Thu, 29 Aug 2024 18:30:20 +1000 Subject: [PATCH 50/62] Revert "Enable assert ini setting" This reverts commit 637dd23d04d192481fa84596c62126205035f327. --- tests/unit/PluginTest.php | 5 ----- 1 file changed, 5 deletions(-) diff --git a/tests/unit/PluginTest.php b/tests/unit/PluginTest.php index d710d2413..6cbe720fc 100644 --- a/tests/unit/PluginTest.php +++ b/tests/unit/PluginTest.php @@ -69,9 +69,6 @@ public function testCanAssert() : void */ public function testCanCatchFailedAssertion() : void { - $initValue = ini_get('zend.assertions'); - ini_set('zend.assertions', 1); - WP_Mock::userFunction('wp_debug_backtrace_summary') ->once() ->andReturn('TEST_DEBUG_BACKTRACE_SUMMARY'); @@ -87,7 +84,5 @@ public function testCanCatchFailedAssertion() : void $this->assertNull( $this->invokeInaccessibleMethod($this->testObject, 'assert', false) ); - - ini_set('zend.assertions', $initValue); } } From 7acd1fb8da981b37e7aea6c83e3b6d5653574256 Mon Sep 17 00:00:00 2001 From: Nabeel Molham Date: Thu, 29 Aug 2024 18:36:52 +1000 Subject: [PATCH 51/62] Dump CI php ini info --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 22acfd2af..7a7e136d8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -70,4 +70,5 @@ jobs: DB_CONNECTION: sqlite DB_DATABASE: database/database.sqlite run: | + php --ini vendor/bin/phpunit --order-by="random" --coverage-text From c0a54130ace72978a0f111ca72a69e68dec8c96d Mon Sep 17 00:00:00 2001 From: Nabeel Molham Date: Thu, 29 Aug 2024 18:41:03 +1000 Subject: [PATCH 52/62] Dump CI php ini info --- .github/workflows/ci.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7a7e136d8..552f547bf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -65,10 +65,13 @@ jobs: run: | composer check-platform-reqs --no-dev --no-interaction --no-scripts + - name: Setup INI file + run: | + echo $PHP_INI_SCAN_DIR + - name: Execute tests via PHPUnit env: DB_CONNECTION: sqlite DB_DATABASE: database/database.sqlite run: | - php --ini vendor/bin/phpunit --order-by="random" --coverage-text From d7799cf43d81ffeb04844bf3aeb822ce1c6e4fad Mon Sep 17 00:00:00 2001 From: Nabeel Molham Date: Thu, 29 Aug 2024 18:46:25 +1000 Subject: [PATCH 53/62] Configure CI php ini --- .github/workflows/ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 552f547bf..6ffee0103 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -67,7 +67,8 @@ jobs: - name: Setup INI file run: | - echo $PHP_INI_SCAN_DIR + echo "zend.assertions=1" > php.ini + export PHP_INI_SCAN_DIR="pwd" - name: Execute tests via PHPUnit env: From 50433ec405615d7d120f12286df8ec6b2115cd8c Mon Sep 17 00:00:00 2001 From: Nabeel Molham Date: Thu, 29 Aug 2024 18:48:09 +1000 Subject: [PATCH 54/62] Configure CI php ini --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6ffee0103..2256af6fd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -68,7 +68,7 @@ jobs: - name: Setup INI file run: | echo "zend.assertions=1" > php.ini - export PHP_INI_SCAN_DIR="pwd" + export PHP_INI_SCAN_DIR="$(pwd)" - name: Execute tests via PHPUnit env: From 2680e56d081634300c679183b2d4d3bdf433b12f Mon Sep 17 00:00:00 2001 From: Nabeel Molham Date: Thu, 29 Aug 2024 18:51:39 +1000 Subject: [PATCH 55/62] Configure CI php ini --- .github/workflows/ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2256af6fd..1472c63b0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -69,6 +69,8 @@ jobs: run: | echo "zend.assertions=1" > php.ini export PHP_INI_SCAN_DIR="$(pwd)" + echo $PHP_INI_SCAN_DIR + echo ${{ steps.composer-cache.outputs.dir }} - name: Execute tests via PHPUnit env: From 9f13eabb7a7a25b8351c13706d758596a8310e38 Mon Sep 17 00:00:00 2001 From: Nabeel Molham Date: Thu, 29 Aug 2024 19:17:14 +1000 Subject: [PATCH 56/62] Configure CI php ini --- .github/workflows/ci.yml | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1472c63b0..bbd71251a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -65,16 +65,12 @@ jobs: run: | composer check-platform-reqs --no-dev --no-interaction --no-scripts - - name: Setup INI file - run: | - echo "zend.assertions=1" > php.ini - export PHP_INI_SCAN_DIR="$(pwd)" - echo $PHP_INI_SCAN_DIR - echo ${{ steps.composer-cache.outputs.dir }} - - name: Execute tests via PHPUnit env: DB_CONNECTION: sqlite DB_DATABASE: database/database.sqlite run: | + echo "zend.assertions=1" > php.ini + export PHP_INI_SCAN_DIR="$(pwd)" + echo $PHP_INI_SCAN_DIR vendor/bin/phpunit --order-by="random" --coverage-text From 6a666bcd2dda82a062b700bd3875f046a27d9c97 Mon Sep 17 00:00:00 2001 From: Nabeel Molham Date: Thu, 29 Aug 2024 19:20:50 +1000 Subject: [PATCH 57/62] Configure CI php ini --- .github/workflows/ci.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bbd71251a..3764895fd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -65,12 +65,14 @@ jobs: run: | composer check-platform-reqs --no-dev --no-interaction --no-scripts + - name: Setup INI file + run: | + echo "zend.assertions=1" > php.ini + echo $PHP_INI_SCAN_DIR + - name: Execute tests via PHPUnit env: DB_CONNECTION: sqlite DB_DATABASE: database/database.sqlite run: | - echo "zend.assertions=1" > php.ini - export PHP_INI_SCAN_DIR="$(pwd)" - echo $PHP_INI_SCAN_DIR vendor/bin/phpunit --order-by="random" --coverage-text From d652bc9354acbf724e2d9f0cf259a52f35d7a108 Mon Sep 17 00:00:00 2001 From: Nabeel Molham Date: Thu, 29 Aug 2024 19:22:47 +1000 Subject: [PATCH 58/62] Configure CI php ini --- .github/workflows/ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3764895fd..0dde8d88e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -67,7 +67,8 @@ jobs: - name: Setup INI file run: | - echo "zend.assertions=1" > php.ini + echo "zend.assertions=1" > repo.ini + export PHP_INI_SCAN_DIR="$(pwd)" echo $PHP_INI_SCAN_DIR - name: Execute tests via PHPUnit From 3f4bef7b28f4cd16d9a8e4176de49ea6ed881e18 Mon Sep 17 00:00:00 2001 From: Ashley Gibson Date: Thu, 29 Aug 2024 10:42:49 +0100 Subject: [PATCH 59/62] Set up php.ini --- .github/workflows/ci.yml | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0dde8d88e..490f4559b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -45,6 +45,15 @@ jobs: sudo update-alternatives --set phpize /usr/bin/phpize$PHP_VERSION sudo update-alternatives --set php-config /usr/bin/php-config$PHP_VERSION + - name: Setup INI file + run: | + PHP_INI_LOCATION="$(php -r 'echo php_ini_loaded_file();')" + if [[ -z "$PHP_INI_LOCATION" || ! -f "$PHP_INI_LOCATION" ]]; then + echo 'Unable to determine php.ini location' + exit 1 + fi + echo "zend.assertions=1" >> "$PHP_INI_LOCATION" + - name: Get Composer Cache Directory id: composer-cache run: | @@ -65,12 +74,6 @@ jobs: run: | composer check-platform-reqs --no-dev --no-interaction --no-scripts - - name: Setup INI file - run: | - echo "zend.assertions=1" > repo.ini - export PHP_INI_SCAN_DIR="$(pwd)" - echo $PHP_INI_SCAN_DIR - - name: Execute tests via PHPUnit env: DB_CONNECTION: sqlite From 5168c9bbc7f5f7bc9fc5ddfd4b1e116d8bb9858d Mon Sep 17 00:00:00 2001 From: Ashley Gibson Date: Thu, 29 Aug 2024 10:43:16 +0100 Subject: [PATCH 60/62] Output and append --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 490f4559b..06e744a59 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -52,7 +52,7 @@ jobs: echo 'Unable to determine php.ini location' exit 1 fi - echo "zend.assertions=1" >> "$PHP_INI_LOCATION" + echo "zend.assertions=1" | sudo tee -a "$PHP_INI_LOCATION" - name: Get Composer Cache Directory id: composer-cache From 68da0a5d9a8544b68b72db28c9e42b8b52cf5ee3 Mon Sep 17 00:00:00 2001 From: Ashley Gibson Date: Thu, 29 Aug 2024 12:09:48 +0100 Subject: [PATCH 61/62] Only set up alias if it doesn't already exist --- woocommerce/class-sv-wc-plugin.php | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/woocommerce/class-sv-wc-plugin.php b/woocommerce/class-sv-wc-plugin.php index b85bb05ea..8e2cea0c9 100644 --- a/woocommerce/class-sv-wc-plugin.php +++ b/woocommerce/class-sv-wc-plugin.php @@ -460,15 +460,21 @@ private function includes() { */ protected function setupClassAliases() : void { - class_alias( - Country_Helper::class, - '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_14_0\\Country_Helper' - ); - - class_alias( - PaymentFormContextChecker::class, - '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_14_0\\PaymentFormContextChecker' - ); + $countryHelperAlias = '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_14_0\\Country_Helper'; + if (! class_exists($countryHelperAlias)) { + class_alias( + Country_Helper::class, + $countryHelperAlias + ); + } + + $paymentFormContextCheckerAlias = '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_14_0\\PaymentFormContextChecker'; + if (! class_exists($paymentFormContextCheckerAlias)) { + class_alias( + PaymentFormContextChecker::class, + $paymentFormContextCheckerAlias + ); + } } From e826a4a32e7b33f6b40ba3d6a1aee2ad18d7ac1a Mon Sep 17 00:00:00 2001 From: Ashley Gibson Date: Thu, 29 Aug 2024 14:59:15 +0100 Subject: [PATCH 62/62] Update changelog --- woocommerce/changelog.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/woocommerce/changelog.txt b/woocommerce/changelog.txt index 7f76abbbb..fbba24331 100644 --- a/woocommerce/changelog.txt +++ b/woocommerce/changelog.txt @@ -5,6 +5,7 @@ * Feature - Add a trait to get an instance (non-singular) of a class: `CanGetNewInstanceTrait` * Feature - Add a trait to convert an object into an array: `CanConvertToArrayTrait` * Feature - Add a new `ArrayHelper` class for array-related utility methods +* Dev - Add support for autoloading. Plugins now need to require the `vendor/autoload.php` file if not already. 2024.08.21 - version 5.13.0 * Feature - Add a trait for enum-like classes