diff --git a/modules/ppcp-api-client/src/Endpoint/PaymentTokenEndpoint.php b/modules/ppcp-api-client/src/Endpoint/PaymentTokenEndpoint.php index 3e0b3b0b4..ad1b1327f 100644 --- a/modules/ppcp-api-client/src/Endpoint/PaymentTokenEndpoint.php +++ b/modules/ppcp-api-client/src/Endpoint/PaymentTokenEndpoint.php @@ -208,7 +208,15 @@ class PaymentTokenEndpoint { return wp_remote_retrieve_response_code( $response ) === 204; } - public function delete_token_by_id(string $token_id): bool { + /** + * Deletes payment token by the given id. + * + * @param string $token_id Token id. + * @return bool + * + * @throws RuntimeException If something goes wrong while deleting the token. + */ + public function delete_token_by_id( string $token_id ): bool { $bearer = $this->bearer->bearer(); $url = trailingslashit( $this->host ) . 'v2/vault/payment-tokens/' . $token_id; @@ -226,7 +234,7 @@ class PaymentTokenEndpoint { $error = new RuntimeException( __( 'Could not delete payment token.', 'woocommerce-paypal-payments' ) ); - $this->logger->warning($error->getMessage()); + $this->logger->warning( $error->getMessage() ); throw $error; } diff --git a/modules/ppcp-vaulting/src/PaymentTokenPayPal.php b/modules/ppcp-vaulting/src/PaymentTokenPayPal.php index 257eef757..561239108 100644 --- a/modules/ppcp-vaulting/src/PaymentTokenPayPal.php +++ b/modules/ppcp-vaulting/src/PaymentTokenPayPal.php @@ -4,12 +4,16 @@ * * @package WooCommerce\PayPalCommerce\Vaulting */ + declare(strict_types=1); namespace WooCommerce\PayPalCommerce\Vaulting; use WC_Payment_Token; +/** + * Class PaymentTokenPayPal + */ class PaymentTokenPayPal extends WC_Payment_Token { /** * Token Type String. diff --git a/modules/ppcp-vaulting/src/VaultingModule.php b/modules/ppcp-vaulting/src/VaultingModule.php index 1cbf6a863..015b4d33f 100644 --- a/modules/ppcp-vaulting/src/VaultingModule.php +++ b/modules/ppcp-vaulting/src/VaultingModule.php @@ -140,13 +140,13 @@ class VaultingModule implements ModuleInterface { return; } - $wpnonce = wc_clean( wp_unslash( $_REQUEST['_wpnonce'] ?? '' ) ); + $wpnonce = wc_clean( wp_unslash( $_REQUEST['_wpnonce'] ?? '' ) ); $token_id_string = (string) $token_id; - $action = 'delete-payment-method-' . $token_id_string; + $action = 'delete-payment-method-' . $token_id_string; if ( $token->get_user_id() !== get_current_user_id() - || ! isset( $wpnonce ) || ! is_string($wpnonce) - || wp_verify_nonce( $wpnonce, $action) === false + || ! isset( $wpnonce ) || ! is_string( $wpnonce ) + || wp_verify_nonce( $wpnonce, $action ) === false ) { wc_add_notice( __( 'Invalid payment method.', 'woocommerce-paypal-payments' ), 'error' ); wp_safe_redirect( wc_get_account_endpoint_url( 'payment-methods' ) ); diff --git a/modules/ppcp-wc-gateway/src/Gateway/PayPalGateway.php b/modules/ppcp-wc-gateway/src/Gateway/PayPalGateway.php index c2d20e1f7..7106bbf4f 100644 --- a/modules/ppcp-wc-gateway/src/Gateway/PayPalGateway.php +++ b/modules/ppcp-wc-gateway/src/Gateway/PayPalGateway.php @@ -223,7 +223,7 @@ class PayPalGateway extends \WC_Payment_Gateway { 'subscription_payment_method_change_customer', 'subscription_payment_method_change_admin', 'multiple_subscriptions', - 'tokenization' + 'tokenization', ); } diff --git a/modules/ppcp-webhooks/services.php b/modules/ppcp-webhooks/services.php index 2507a4e47..f12ff83bb 100644 --- a/modules/ppcp-webhooks/services.php +++ b/modules/ppcp-webhooks/services.php @@ -74,7 +74,7 @@ return array( $prefix = $container->get( 'api.prefix' ); $order_endpoint = $container->get( 'api.endpoint.order' ); $authorized_payments_processor = $container->get( 'wcgateway.processor.authorized-payments' ); - $payment_token_paypal = $container->get('vaulting.payment-token-paypal'); + $payment_token_paypal = $container->get( 'vaulting.payment-token-paypal' ); return array( new CheckoutOrderApproved( $logger, $prefix, $order_endpoint ),