Fix phpcd

This commit is contained in:
emilicastells 2022-12-08 14:18:03 +01:00
parent b161b8cfb5
commit e3dc563a6f
No known key found for this signature in database
GPG key ID: 1520C07081754570
5 changed files with 20 additions and 8 deletions

View file

@ -208,7 +208,15 @@ class PaymentTokenEndpoint {
return wp_remote_retrieve_response_code( $response ) === 204; 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(); $bearer = $this->bearer->bearer();
$url = trailingslashit( $this->host ) . 'v2/vault/payment-tokens/' . $token_id; $url = trailingslashit( $this->host ) . 'v2/vault/payment-tokens/' . $token_id;
@ -226,7 +234,7 @@ class PaymentTokenEndpoint {
$error = new RuntimeException( $error = new RuntimeException(
__( 'Could not delete payment token.', 'woocommerce-paypal-payments' ) __( 'Could not delete payment token.', 'woocommerce-paypal-payments' )
); );
$this->logger->warning($error->getMessage()); $this->logger->warning( $error->getMessage() );
throw $error; throw $error;
} }

View file

@ -4,12 +4,16 @@
* *
* @package WooCommerce\PayPalCommerce\Vaulting * @package WooCommerce\PayPalCommerce\Vaulting
*/ */
declare(strict_types=1); declare(strict_types=1);
namespace WooCommerce\PayPalCommerce\Vaulting; namespace WooCommerce\PayPalCommerce\Vaulting;
use WC_Payment_Token; use WC_Payment_Token;
/**
* Class PaymentTokenPayPal
*/
class PaymentTokenPayPal extends WC_Payment_Token { class PaymentTokenPayPal extends WC_Payment_Token {
/** /**
* Token Type String. * Token Type String.

View file

@ -140,13 +140,13 @@ class VaultingModule implements ModuleInterface {
return; return;
} }
$wpnonce = wc_clean( wp_unslash( $_REQUEST['_wpnonce'] ?? '' ) ); $wpnonce = wc_clean( wp_unslash( $_REQUEST['_wpnonce'] ?? '' ) );
$token_id_string = (string) $token_id; $token_id_string = (string) $token_id;
$action = 'delete-payment-method-' . $token_id_string; $action = 'delete-payment-method-' . $token_id_string;
if ( if (
$token->get_user_id() !== get_current_user_id() $token->get_user_id() !== get_current_user_id()
|| ! isset( $wpnonce ) || ! is_string($wpnonce) || ! isset( $wpnonce ) || ! is_string( $wpnonce )
|| wp_verify_nonce( $wpnonce, $action) === false || wp_verify_nonce( $wpnonce, $action ) === false
) { ) {
wc_add_notice( __( 'Invalid payment method.', 'woocommerce-paypal-payments' ), 'error' ); wc_add_notice( __( 'Invalid payment method.', 'woocommerce-paypal-payments' ), 'error' );
wp_safe_redirect( wc_get_account_endpoint_url( 'payment-methods' ) ); wp_safe_redirect( wc_get_account_endpoint_url( 'payment-methods' ) );

View file

@ -223,7 +223,7 @@ class PayPalGateway extends \WC_Payment_Gateway {
'subscription_payment_method_change_customer', 'subscription_payment_method_change_customer',
'subscription_payment_method_change_admin', 'subscription_payment_method_change_admin',
'multiple_subscriptions', 'multiple_subscriptions',
'tokenization' 'tokenization',
); );
} }

View file

@ -74,7 +74,7 @@ return array(
$prefix = $container->get( 'api.prefix' ); $prefix = $container->get( 'api.prefix' );
$order_endpoint = $container->get( 'api.endpoint.order' ); $order_endpoint = $container->get( 'api.endpoint.order' );
$authorized_payments_processor = $container->get( 'wcgateway.processor.authorized-payments' ); $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( return array(
new CheckoutOrderApproved( $logger, $prefix, $order_endpoint ), new CheckoutOrderApproved( $logger, $prefix, $order_endpoint ),