Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove hooks from customer service constructor #9992

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading