mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 13:44:42 +08:00
Add change subscription payment for vault v3
This commit is contained in:
parent
09d6ccc92d
commit
16eebecc5a
2 changed files with 14 additions and 11 deletions
|
@ -400,19 +400,26 @@ class CreditCardGateway extends \WC_Payment_Gateway_CC {
|
||||||
* If customer is changing subscription payment.
|
* If customer is changing subscription payment.
|
||||||
*/
|
*/
|
||||||
if (
|
if (
|
||||||
// phpcs:ignore WordPress.Security.NonceVerification.Missing
|
// phpcs:disable WordPress.Security.NonceVerification.Missing
|
||||||
isset( $_POST['woocommerce_change_payment'] )
|
isset( $_POST['woocommerce_change_payment'] )
|
||||||
&& $this->subscription_helper->has_subscription( $wc_order->get_id() )
|
&& $this->subscription_helper->has_subscription( $wc_order->get_id() )
|
||||||
&& $this->subscription_helper->is_subscription_change_payment()
|
&& $this->subscription_helper->is_subscription_change_payment()
|
||||||
&& $saved_credit_card
|
|
||||||
) {
|
) {
|
||||||
$payment_token = WC_Payment_Tokens::get($saved_credit_card);
|
$saved_credit_card = wc_clean( wp_unslash( $_POST['wc-ppcp-credit-card-gateway-payment-token'] ?? '' ) );
|
||||||
if($payment_token) {
|
if ( ! $saved_credit_card ) {
|
||||||
$wc_order->add_payment_token($payment_token);
|
$saved_credit_card = wc_clean( wp_unslash( $_POST['saved_credit_card'] ?? '' ) );
|
||||||
|
// phpcs:enable WordPress.Security.NonceVerification.Missing
|
||||||
|
}
|
||||||
|
|
||||||
|
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();
|
$wc_order->save();
|
||||||
|
|
||||||
return $this->handle_payment_success( $wc_order );
|
return $this->handle_payment_success( $wc_order );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
wc_add_notice( __( 'Could not change payment.', 'woocommerce-paypal-payments' ), 'error' );
|
wc_add_notice( __( 'Could not change payment.', 'woocommerce-paypal-payments' ), 'error' );
|
||||||
|
|
||||||
|
|
|
@ -117,10 +117,6 @@ class WcSubscriptionsModule implements ModuleInterface {
|
||||||
* @psalm-suppress MissingClosureParamType
|
* @psalm-suppress MissingClosureParamType
|
||||||
*/
|
*/
|
||||||
function ( $description, $id ) use ( $c ) {
|
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' );
|
$payment_token_repository = $c->get( 'vaulting.repository.payment-token' );
|
||||||
$settings = $c->get( 'wcgateway.settings' );
|
$settings = $c->get( 'wcgateway.settings' );
|
||||||
$subscription_helper = $c->get( 'wc-subscriptions.helper' );
|
$subscription_helper = $c->get( 'wc-subscriptions.helper' );
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue