Fix phpcs

This commit is contained in:
Emili Castells Guasch 2024-03-11 09:25:33 +01:00
parent 81826fbd61
commit 3801a8f838
3 changed files with 14 additions and 11 deletions

View file

@ -132,6 +132,8 @@ class CaptureCardPayment {
* Creates PayPal order from the given card vault id. * Creates PayPal order from the given card vault id.
* *
* @param string $vault_id Vault id. * @param string $vault_id Vault id.
* @param string $custom_id Custom id.
* @param string $invoice_id Invoice id.
* @return stdClass * @return stdClass
* @throws RuntimeException When request fails. * @throws RuntimeException When request fails.
*/ */

View file

@ -131,7 +131,7 @@ return array(
$vaulted_credit_card_handler, $vaulted_credit_card_handler,
$container->get( 'onboarding.environment' ), $container->get( 'onboarding.environment' ),
$container->get( 'api.endpoint.order' ), $container->get( 'api.endpoint.order' ),
$container->get('save-payment-methods.endpoint.capture-card-payment'), $container->get( 'save-payment-methods.endpoint.capture-card-payment' ),
$container->get( 'api.prefix' ), $container->get( 'api.prefix' ),
$logger $logger
); );

View file

@ -411,14 +411,15 @@ class CreditCardGateway extends \WC_Payment_Gateway_CC {
); );
} }
// phpcs:ignore WordPress.Security.NonceVerification.Missing
$card_payment_token_id = wc_clean( wp_unslash( $_POST['wc-ppcp-credit-card-gateway-payment-token'] ?? '' ) ); $card_payment_token_id = wc_clean( wp_unslash( $_POST['wc-ppcp-credit-card-gateway-payment-token'] ?? '' ) );
if($card_payment_token_id) { if ( $card_payment_token_id ) {
$tokens = WC_Payment_Tokens::get_customer_tokens( get_current_user_id() ); $tokens = WC_Payment_Tokens::get_customer_tokens( get_current_user_id() );
foreach ( $tokens as $token ) { foreach ( $tokens as $token ) {
if ( $token->get_id() === (int) $card_payment_token_id ) { if ( $token->get_id() === (int) $card_payment_token_id ) {
$custom_id = $wc_order->get_order_number(); $custom_id = $wc_order->get_order_number();
$invoice_id = $this->prefix . $wc_order->get_order_number(); $invoice_id = $this->prefix . $wc_order->get_order_number();
$create_order = $this->capture_card_payment->create_order($token->get_token(), $custom_id, $invoice_id); $create_order = $this->capture_card_payment->create_order( $token->get_token(), $custom_id, $invoice_id );
$order = $this->order_endpoint->order( $create_order->id ); $order = $this->order_endpoint->order( $create_order->id );
$wc_order->update_meta_data( PayPalGateway::INTENT_META_KEY, $order->intent() ); $wc_order->update_meta_data( PayPalGateway::INTENT_META_KEY, $order->intent() );