diff --git a/modules/ppcp-wc-gateway/src/Gateway/CreditCardGateway.php b/modules/ppcp-wc-gateway/src/Gateway/CreditCardGateway.php index aaa92abdb..66f370124 100644 --- a/modules/ppcp-wc-gateway/src/Gateway/CreditCardGateway.php +++ b/modules/ppcp-wc-gateway/src/Gateway/CreditCardGateway.php @@ -400,18 +400,25 @@ class CreditCardGateway extends \WC_Payment_Gateway_CC { * If customer is changing subscription payment. */ if ( - // phpcs:ignore WordPress.Security.NonceVerification.Missing + // phpcs:disable WordPress.Security.NonceVerification.Missing isset( $_POST['woocommerce_change_payment'] ) && $this->subscription_helper->has_subscription( $wc_order->get_id() ) && $this->subscription_helper->is_subscription_change_payment() - && $saved_credit_card ) { - $payment_token = WC_Payment_Tokens::get($saved_credit_card); - if($payment_token) { - $wc_order->add_payment_token($payment_token); - $wc_order->save(); + $saved_credit_card = wc_clean( wp_unslash( $_POST['wc-ppcp-credit-card-gateway-payment-token'] ?? '' ) ); + if ( ! $saved_credit_card ) { + $saved_credit_card = wc_clean( wp_unslash( $_POST['saved_credit_card'] ?? '' ) ); + // phpcs:enable WordPress.Security.NonceVerification.Missing + } - return $this->handle_payment_success( $wc_order ); + if ( $saved_credit_card ) { + $payment_token = WC_Payment_Tokens::get( $saved_credit_card ); + if ( $payment_token ) { + $wc_order->add_payment_token( $payment_token ); + $wc_order->save(); + + return $this->handle_payment_success( $wc_order ); + } } wc_add_notice( __( 'Could not change payment.', 'woocommerce-paypal-payments' ), 'error' ); diff --git a/modules/ppcp-wc-subscriptions/src/WcSubscriptionsModule.php b/modules/ppcp-wc-subscriptions/src/WcSubscriptionsModule.php index 6049e3823..c8f0f99a6 100644 --- a/modules/ppcp-wc-subscriptions/src/WcSubscriptionsModule.php +++ b/modules/ppcp-wc-subscriptions/src/WcSubscriptionsModule.php @@ -117,10 +117,6 @@ class WcSubscriptionsModule implements ModuleInterface { * @psalm-suppress MissingClosureParamType */ function ( $description, $id ) use ( $c ) { - if ( $c->has( 'save-payment-methods.eligible' ) && $c->get( 'save-payment-methods.eligible' ) ) { - return $description; - } - $payment_token_repository = $c->get( 'vaulting.repository.payment-token' ); $settings = $c->get( 'wcgateway.settings' ); $subscription_helper = $c->get( 'wc-subscriptions.helper' );