Ensure no wc payment token is created if user id does not exist

This commit is contained in:
Emili Castells Guasch 2024-03-21 16:49:03 +01:00
parent 56a6c4ce32
commit 93514a798a

View file

@ -132,6 +132,10 @@ class WooCommercePaymentTokens {
string $email
): int {
if ( $customer_id === 0 ) {
return 0;
}
$wc_tokens = WC_Payment_Tokens::get_customer_tokens( $customer_id, PayPalGateway::ID );
if ( $this->payment_token_helper->token_exist( $wc_tokens, $token, PaymentTokenVenmo::class ) ) {
return 0;
@ -178,6 +182,10 @@ class WooCommercePaymentTokens {
string $token
): int {
if ( $customer_id === 0 ) {
return 0;
}
$wc_tokens = WC_Payment_Tokens::get_customer_tokens( $customer_id, PayPalGateway::ID );
if ( $this->payment_token_helper->token_exist( $wc_tokens, $token, PaymentTokenApplePay::class ) ) {
return 0;
@ -216,6 +224,10 @@ class WooCommercePaymentTokens {
* @return int
*/
public function create_payment_token_card( int $customer_id, stdClass $payment_token ): int {
if ( $customer_id === 0 ) {
return 0;
}
$wc_tokens = WC_Payment_Tokens::get_customer_tokens( $customer_id, CreditCardGateway::ID );
if ( $this->payment_token_helper->token_exist( $wc_tokens, $payment_token->id ) ) {
return 0;