From e0dd215d92d9b51fa9fc043d148d1ea3c56d87ce Mon Sep 17 00:00:00 2001 From: Pedro Silva Date: Mon, 19 Feb 2024 14:48:02 +0000 Subject: [PATCH] Fix lint Revert authentication --- .../src/Authentication/UserIdToken.php | 21 +++++---------- modules/ppcp-applepay/extensions.php | 4 +-- modules/ppcp-axo/extensions.php | 10 +++---- modules/ppcp-axo/services.php | 26 ++++++++++++++----- modules/ppcp-axo/src/Assets/AxoManager.php | 2 +- modules/ppcp-axo/src/AxoModule.php | 2 +- modules/ppcp-axo/src/Gateway/AxoGateway.php | 19 +++++--------- 7 files changed, 41 insertions(+), 43 deletions(-) diff --git a/modules/ppcp-api-client/src/Authentication/UserIdToken.php b/modules/ppcp-api-client/src/Authentication/UserIdToken.php index 887440208..d848228d7 100644 --- a/modules/ppcp-api-client/src/Authentication/UserIdToken.php +++ b/modules/ppcp-api-client/src/Authentication/UserIdToken.php @@ -74,25 +74,18 @@ class UserIdToken { $url = trailingslashit( $this->host ) . 'v1/oauth2/token?grant_type=client_credentials&response_type=id_token&intent=sdk_init'; if ( $target_customer_id ) { -// $url = add_query_arg( -// array( -// 'target_customer_id' => $target_customer_id, -// ), -// $url -// ); + $url = add_query_arg( + array( + 'target_customer_id' => $target_customer_id, + ), + $url + ); } - // TODO fix this to use Bearer instead of Basic auth: - $settings = PPCP::container()->get( 'wcgateway.settings' ); - $key = $settings->has( 'client_id' ) && $settings->get( 'client_id' ) ? $settings->get( 'client_id' ) : null; - $secret = $settings->has( 'client_secret' ) && $settings->get( 'client_secret' ) ? $settings->get( 'client_secret' ) : null; - $args = array( 'method' => 'POST', 'headers' => array( -// 'Authorization' => 'Bearer ' . $bearer->token(), - 'Authorization' => 'Basic ' . base64_encode( "$key:$secret" ), - + 'Authorization' => 'Bearer ' . $bearer->token(), 'Content-Type' => 'application/x-www-form-urlencoded', ), ); diff --git a/modules/ppcp-applepay/extensions.php b/modules/ppcp-applepay/extensions.php index df5007e8e..857fd7575 100644 --- a/modules/ppcp-applepay/extensions.php +++ b/modules/ppcp-applepay/extensions.php @@ -131,8 +131,8 @@ return array( $fields, 'allow_card_button_gateway', array( - 'spacer' => array( - 'title' => __( '', 'woocommerce-paypal-payments' ), + 'spacer' => array( + 'title' => '', 'type' => 'ppcp-text', 'text' => '', 'class' => array(), diff --git a/modules/ppcp-axo/extensions.php b/modules/ppcp-axo/extensions.php index be05e604e..ae2e4580e 100644 --- a/modules/ppcp-axo/extensions.php +++ b/modules/ppcp-axo/extensions.php @@ -35,7 +35,7 @@ return array( $fields, 'vault_enabled', array( - 'axo_enabled' => array( + 'axo_enabled' => array( 'title' => __( 'Fastlane', 'woocommerce-paypal-payments' ), 'type' => 'checkbox', 'label' => __( 'Enable Fastlane Checkout', 'woocommerce-paypal-payments' ) @@ -67,7 +67,7 @@ return array( ), ), ), - 'axo_gateway_title' => array( + 'axo_gateway_title' => array( 'title' => __( 'Gateway Title', 'woocommerce-paypal-payments' ), 'type' => 'text', 'classes' => array( 'ppcp-field-indent' ), @@ -86,7 +86,7 @@ return array( 'requirements' => array(), 'gateway' => 'paypal', ), - 'axo_email_widget' => array( + 'axo_email_widget' => array( 'title' => __( 'Email Widget', 'woocommerce-paypal-payments' ), 'type' => 'select', 'desc_tip' => true, @@ -103,7 +103,7 @@ return array( 'gateway' => 'paypal', 'requirements' => array(), ), - 'axo_address_widget' => array( + 'axo_address_widget' => array( 'title' => __( 'Address Widget', 'woocommerce-paypal-payments' ), 'type' => 'select', 'desc_tip' => true, @@ -120,7 +120,7 @@ return array( 'gateway' => 'paypal', 'requirements' => array(), ), - 'axo_payment_widget' => array( + 'axo_payment_widget' => array( 'title' => __( 'Payment Widget', 'woocommerce-paypal-payments' ), 'type' => 'select', 'desc_tip' => true, diff --git a/modules/ppcp-axo/services.php b/modules/ppcp-axo/services.php index 21daccdd1..c2338128d 100644 --- a/modules/ppcp-axo/services.php +++ b/modules/ppcp-axo/services.php @@ -15,7 +15,7 @@ use WooCommerce\PayPalCommerce\Vendor\Psr\Container\ContainerInterface; return array( - 'axo.url' => static function ( ContainerInterface $container ): string { + 'axo.url' => static function ( ContainerInterface $container ): string { $path = realpath( __FILE__ ); if ( false === $path ) { return ''; @@ -26,7 +26,7 @@ return array( ); }, - 'axo.manager' => static function ( ContainerInterface $container ): AxoManager { + 'axo.manager' => static function ( ContainerInterface $container ): AxoManager { return new AxoManager( $container->get( 'axo.url' ), $container->get( 'ppcp.asset-version' ), @@ -39,7 +39,7 @@ return array( ); }, - 'axo.gateway' => static function ( ContainerInterface $container ): AxoGateway { + 'axo.gateway' => static function ( ContainerInterface $container ): AxoGateway { return new AxoGateway( $container->get( 'wcgateway.settings' ), $container->get( 'wcgateway.url' ), @@ -49,10 +49,22 @@ return array( 'axo.card_icons' => static function ( ContainerInterface $container ): array { return array( - array('title' => 'Visa', 'file' => 'visa-dark.svg'), - array('title' => 'MasterCard', 'file' => 'mastercard-dark.svg'), - array('title' => 'American Express', 'file' => 'amex.svg'), - array('title' => 'Discover', 'file' => 'discover.svg'), + array( + 'title' => 'Visa', + 'file' => 'visa-dark.svg', + ), + array( + 'title' => 'MasterCard', + 'file' => 'mastercard-dark.svg', + ), + array( + 'title' => 'American Express', + 'file' => 'amex.svg', + ), + array( + 'title' => 'Discover', + 'file' => 'discover.svg', + ), ); }, diff --git a/modules/ppcp-axo/src/Assets/AxoManager.php b/modules/ppcp-axo/src/Assets/AxoManager.php index 26e920461..4a92208c6 100644 --- a/modules/ppcp-axo/src/Assets/AxoManager.php +++ b/modules/ppcp-axo/src/Assets/AxoManager.php @@ -159,7 +159,7 @@ class AxoManager { 'email' => $email_widget ?: 'render', 'address' => $address_widget ?: 'render', 'payment' => $payment_widget ?: 'render', - ) + ), ); } diff --git a/modules/ppcp-axo/src/AxoModule.php b/modules/ppcp-axo/src/AxoModule.php index 3656d8b98..3b07dcf62 100644 --- a/modules/ppcp-axo/src/AxoModule.php +++ b/modules/ppcp-axo/src/AxoModule.php @@ -38,7 +38,7 @@ class AxoModule implements ModuleInterface { add_filter( 'woocommerce_payment_gateways', function ( $methods ) use ( $c ): array { - $methods[] = $c->get('axo.gateway'); + $methods[] = $c->get( 'axo.gateway' ); return $methods; }, 1, diff --git a/modules/ppcp-axo/src/Gateway/AxoGateway.php b/modules/ppcp-axo/src/Gateway/AxoGateway.php index 53d438103..143cc12f2 100644 --- a/modules/ppcp-axo/src/Gateway/AxoGateway.php +++ b/modules/ppcp-axo/src/Gateway/AxoGateway.php @@ -44,6 +44,8 @@ class AxoGateway extends WC_Payment_Gateway { * AXOGateway constructor. * * @param ContainerInterface $ppcp_settings The settings. + * @param string $wcgateway_module_url The WcGateway module URL. + * @param array $card_icons The card icons. */ public function __construct( ContainerInterface $ppcp_settings, @@ -66,7 +68,7 @@ class AxoGateway extends WC_Payment_Gateway { ? $this->ppcp_settings->get( 'axo_gateway_title' ) : $this->get_option( 'title', $this->method_title ); - $this->description = $this->get_option( 'description', __( '', 'woocommerce-paypal-payments' ) ); + $this->description = $this->get_option( 'description', '' ); $this->init_form_fields(); $this->init_settings(); @@ -78,15 +80,6 @@ class AxoGateway extends WC_Payment_Gateway { 'process_admin_options', ) ); - -// $this->order_endpoint = $order_endpoint; -// $this->purchase_unit_factory = $purchase_unit_factory; -// $this->shipping_preference_factory = $shipping_preference_factory; -// $this->module_url = $module_url; -// $this->logger = $logger; - -// $this->icon = esc_url( $this->module_url ) . 'assets/images/axo.svg'; // TODO -// $this->environment = $environment; } /** @@ -94,7 +87,7 @@ class AxoGateway extends WC_Payment_Gateway { */ public function init_form_fields() { $this->form_fields = array( - 'enabled' => array( + 'enabled' => array( 'title' => __( 'Enable/Disable', 'woocommerce-paypal-payments' ), 'type' => 'checkbox', 'label' => __( 'AXO', 'woocommerce-paypal-payments' ), @@ -112,7 +105,7 @@ class AxoGateway extends WC_Payment_Gateway { * @return array */ public function process_payment( $order_id ) { - $wc_order = wc_get_order( $order_id ); + $wc_order = wc_get_order( $order_id ); // TODO ... @@ -139,7 +132,7 @@ class AxoGateway extends WC_Payment_Gateway { } $images = array(); - foreach ($this->card_icons as $card) { + foreach ( $this->card_icons as $card ) { $images[] = '