Skip to content

Commit

Permalink
Remove hooks from customer service constructor (#9992)
Browse files Browse the repository at this point in the history
  • Loading branch information
zmaglica authored Dec 19, 2024
1 parent f1a21c8 commit 7b6e7ef
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: dev

Remove hooks from customer and token services to dedicated methods
4 changes: 0 additions & 4 deletions dev/phpcs/WCPay/ruleset.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@

<exclude-pattern>*/includes/class-wc-payments-order-success-page.php</exclude-pattern>

<!-- https://github.com/Automattic/woocommerce-payments/issues/7264 -->
<exclude-pattern>*/includes/class-wc-payments-customer-service.php</exclude-pattern>
<exclude-pattern>*/includes/class-wc-payments-token-service.php</exclude-pattern>

<!-- https://github.com/Automattic/woocommerce-payments/issues/7265 -->
<exclude-pattern>*/includes/class-wc-payments-webhook-reliability-service.php</exclude-pattern>
</rule>
Expand Down
5 changes: 5 additions & 0 deletions includes/class-wc-payments-customer-service.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,12 @@ public function __construct(
$this->database_cache = $database_cache;
$this->session_service = $session_service;
$this->order_service = $order_service;
}

/**
* Initialize hooks
*/
public function init_hooks() {
/*
* Adds the WooCommerce Payments customer ID found in the user session
* to the WordPress user as metadata.
Expand Down
5 changes: 5 additions & 0 deletions includes/class-wc-payments-token-service.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,12 @@ class WC_Payments_Token_Service {
public function __construct( WC_Payments_API_Client $payments_api_client, WC_Payments_Customer_Service $customer_service ) {
$this->payments_api_client = $payments_api_client;
$this->customer_service = $customer_service;
}

/**
* Initializes hooks.
*/
public function init_hooks() {
add_action( 'woocommerce_payment_token_deleted', [ $this, 'woocommerce_payment_token_deleted' ], 10, 2 );
add_action( 'woocommerce_payment_token_set_default', [ $this, 'woocommerce_payment_token_set_default' ], 10, 2 );
add_filter( 'woocommerce_get_customer_payment_tokens', [ $this, 'woocommerce_get_customer_payment_tokens' ], 10, 3 );
Expand Down
2 changes: 2 additions & 0 deletions includes/class-wc-payments.php
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,8 @@ public static function init() {
self::$onboarding_service->init_hooks();
self::$incentives_service->init_hooks();
self::$compatibility_service->init_hooks();
self::$customer_service->init_hooks();
self::$token_service->init_hooks();

$payment_method_classes = [
CC_Payment_Method::class,
Expand Down

0 comments on commit 7b6e7ef

Please sign in to comment.