Skip to content

Commit ebd0b54

Browse files
authored
Fix WC_Payment_Gateway being accessed too early (#4099)
* Fiex WC_Payment_Gateway being accessed too early * Fix doc * Upgrade deps
1 parent 3a2e968 commit ebd0b54

File tree

5 files changed

+23
-33
lines changed

5 files changed

+23
-33
lines changed

composer.lock

Lines changed: 6 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pay-with-flex.php

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/**
33
* Plugin Name: Flex HSA/FSA Payments
44
* Description: Accept HSA/FSA payments directly in the checkout flow.
5-
* Version: 3.1.9
5+
* Version: 3.1.10
66
* Plugin URI: https://wordpress.org/plugins/pay-with-flex/
77
* Author: Flex
88
* Author URI: https://withflex.com/
@@ -18,6 +18,7 @@
1818

1919
namespace Flex;
2020

21+
use Automattic\WooCommerce\Blocks\Payments\PaymentMethodRegistry;
2122
use Automattic\WooCommerce\Enums\ProductType;
2223
use Flex\Controller\OrderController;
2324
use Flex\Controller\WebhookController;
@@ -820,23 +821,29 @@ function add_option_wc_flex_settings( string $option, mixed $value ): void {
820821
);
821822

822823
/**
823-
* Add the Payment Gateway.
824+
* Register the Payment Gateway.
824825
*
825826
* @param string[] $methods An array of Payment method classes.
826827
*/
828+
function wc_payment_gateways( array $methods = array() ): array {
829+
return array( ...$methods, PaymentGateway::class );
830+
}
827831
add_filter(
828832
hook_name: 'woocommerce_payment_gateways',
829-
callback: array( PaymentGateway::class, 'wc_payment_gateways' ),
833+
callback: __NAMESPACE__ . '\wc_payment_gateways',
830834
);
831835

832836
/**
833-
* Add the Payment Method.
837+
* Register the payment method.
834838
*
835-
* @param string[] $methods An array of Payment method classes.
839+
* @param PaymentMethodRegistry $payment_method_registry The WooCommerce payment method registry.
836840
*/
841+
function wc_blocks_payment_method_type_registration( PaymentMethodRegistry $payment_method_registry ) {
842+
$payment_method_registry->register( new PaymentMethod() );
843+
}
837844
add_filter(
838845
hook_name: 'woocommerce_blocks_payment_method_type_registration',
839-
callback: array( PaymentMethod::class, 'wc_blocks_payment_method_type_registration' ),
846+
callback: __NAMESPACE__ . '\wc_blocks_payment_method_type_registration',
840847
);
841848

842849
/**

readme.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Contributors: withflex, davidbarratt
33
Tags: hsa, fsa, payments, woocommerce
44
Requires at least: 6.8
55
Tested up to: 6.8
6-
Stable tag: 3.1.9
6+
Stable tag: 3.1.10
77
Requires PHP: 8.1
88
License: GPLv3 or later
99
License URI: https://www.gnu.org/licenses/gpl-3.0.html
@@ -55,6 +55,9 @@ Flex makes this process simple by offering asynchronous telehealth visits direct
5555

5656
== Changelog ==
5757

58+
= 3.1.10 =
59+
* Fixed an error where WC_Payment_Gateway was accessed too early.
60+
5861
= 3.1.9 =
5962
* Fixed version inconsistency between the plugin file and the readme.
6063

src/PaymentGateway.php

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -90,15 +90,6 @@ public function init() {
9090
$this->init_form_fields();
9191
}
9292

93-
/**
94-
* Register this class as a Payment Gateway.
95-
*
96-
* @param string[] $methods An array of Payment method classes.
97-
*/
98-
public static function wc_payment_gateways( array $methods = array() ): array {
99-
return array( ...$methods, self::class );
100-
}
101-
10293
/**
10394
* {@inheritdoc}
10495
*

src/PaymentMethod.php

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
namespace Flex;
1111

1212
use Automattic\WooCommerce\Blocks\Payments\Integrations\AbstractPaymentMethodType;
13-
use Automattic\WooCommerce\Blocks\Payments\PaymentMethodRegistry;
1413

1514
/**
1615
* Flex Payment Method.
@@ -24,15 +23,6 @@ class PaymentMethod extends AbstractPaymentMethodType {
2423
*/
2524
protected $name = 'flex';
2625

27-
/**
28-
* Register the payment method.
29-
*
30-
* @param PaymentMethodRegistry $payment_method_registry The WooCommerce payment method registry.
31-
*/
32-
public static function wc_blocks_payment_method_type_registration( PaymentMethodRegistry $payment_method_registry ) {
33-
$payment_method_registry->register( new self() );
34-
}
35-
3626
/**
3727
* {@inheritdoc}
3828
*/

0 commit comments

Comments
 (0)