Ensure payment method before saving payment token

This commit is contained in:
Emili Castells Guasch 2023-11-02 16:44:05 +01:00
parent 19236d24c1
commit 489675c921

View file

@ -29,6 +29,7 @@ use WC_Subscription;
use WooCommerce\PayPalCommerce\ApiClient\Exception\RuntimeException;
use WooCommerce\PayPalCommerce\Subscription\Helper\SubscriptionHelper;
use WooCommerce\PayPalCommerce\Vaulting\PaymentTokenRepository;
use WooCommerce\PayPalCommerce\WcGateway\Gateway\CardButtonGateway;
use WooCommerce\PayPalCommerce\WcGateway\Gateway\PayPalGateway;
use WooCommerce\PayPalCommerce\WcGateway\Gateway\CreditCardGateway;
use WooCommerce\PayPalCommerce\Vendor\Interop\Container\ServiceProviderInterface;
@ -80,6 +81,14 @@ class SubscriptionModule implements ModuleInterface {
add_action(
'woocommerce_subscription_payment_complete',
function ( $subscription ) use ( $c ) {
if (
$subscription->get_payment_method() !== PayPalGateway::ID
|| $subscription->get_payment_method() !== CreditCardGateway::ID
|| $subscription->get_payment_method() !== CardButtonGateway::ID
) {
return;
}
$paypal_subscription_id = $subscription->get_meta( 'ppcp_subscription' ) ?? '';
if ( $paypal_subscription_id ) {
return;