From 90e6c1f5ac5e0edf383fcdc950c47049fb53a566 Mon Sep 17 00:00:00 2001 From: Wesley Rosa Date: Mon, 20 Jan 2025 12:13:37 -0300 Subject: [PATCH 1/5] Fix fingerprint set error on legacy checkout --- .../class-wc-stripe-payment-tokens.php | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/includes/payment-tokens/class-wc-stripe-payment-tokens.php b/includes/payment-tokens/class-wc-stripe-payment-tokens.php index ba44bbed8..31a2d504f 100644 --- a/includes/payment-tokens/class-wc-stripe-payment-tokens.php +++ b/includes/payment-tokens/class-wc-stripe-payment-tokens.php @@ -21,12 +21,12 @@ class WC_Stripe_Payment_Tokens { * The values are the related gateway ID we use for them in the extension. */ const UPE_REUSABLE_GATEWAYS_BY_PAYMENT_METHOD = [ - WC_Stripe_UPE_Payment_Method_CC::STRIPE_ID => WC_Stripe_UPE_Payment_Gateway::ID, - WC_Stripe_UPE_Payment_Method_Link::STRIPE_ID => WC_Stripe_UPE_Payment_Gateway::ID, - WC_Stripe_UPE_Payment_Method_Bancontact::STRIPE_ID => WC_Stripe_UPE_Payment_Gateway::ID . '_' . WC_Stripe_UPE_Payment_Method_Bancontact::STRIPE_ID, - WC_Stripe_UPE_Payment_Method_Ideal::STRIPE_ID => WC_Stripe_UPE_Payment_Gateway::ID . '_' . WC_Stripe_UPE_Payment_Method_Ideal::STRIPE_ID, - WC_Stripe_UPE_Payment_Method_Sepa::STRIPE_ID => WC_Stripe_UPE_Payment_Gateway::ID . '_' . WC_Stripe_UPE_Payment_Method_Sepa::STRIPE_ID, - WC_Stripe_UPE_Payment_Method_Sofort::STRIPE_ID => WC_Stripe_UPE_Payment_Gateway::ID . '_' . WC_Stripe_UPE_Payment_Method_Sofort::STRIPE_ID, + WC_Stripe_UPE_Payment_Method_CC::STRIPE_ID => WC_Stripe_UPE_Payment_Gateway::ID, + WC_Stripe_UPE_Payment_Method_Link::STRIPE_ID => WC_Stripe_UPE_Payment_Gateway::ID, + WC_Stripe_UPE_Payment_Method_Bancontact::STRIPE_ID => WC_Stripe_UPE_Payment_Gateway::ID . '_' . WC_Stripe_UPE_Payment_Method_Bancontact::STRIPE_ID, + WC_Stripe_UPE_Payment_Method_Ideal::STRIPE_ID => WC_Stripe_UPE_Payment_Gateway::ID . '_' . WC_Stripe_UPE_Payment_Method_Ideal::STRIPE_ID, + WC_Stripe_UPE_Payment_Method_Sepa::STRIPE_ID => WC_Stripe_UPE_Payment_Gateway::ID . '_' . WC_Stripe_UPE_Payment_Method_Sepa::STRIPE_ID, + WC_Stripe_UPE_Payment_Method_Sofort::STRIPE_ID => WC_Stripe_UPE_Payment_Gateway::ID . '_' . WC_Stripe_UPE_Payment_Method_Sofort::STRIPE_ID, WC_Stripe_UPE_Payment_Method_Cash_App_Pay::STRIPE_ID => WC_Stripe_UPE_Payment_Gateway::ID . '_' . WC_Stripe_UPE_Payment_Method_Cash_App_Pay::STRIPE_ID, ]; @@ -185,7 +185,10 @@ public function woocommerce_get_customer_payment_tokens_legacy( $tokens, $custom $token->set_expiry_year( $source->card->exp_year ); } - $token->set_fingerprint( $source->fingerprint ); + if ( isset( $source->fingerprint ) ) { + $token->set_fingerprint( $source->fingerprint ); + } + $token->set_user_id( $customer_id ); $token->save(); $tokens[ $token->get_id() ] = $token; From 5725bcca6ae5196ff292a8cd77102e2e2cca5827 Mon Sep 17 00:00:00 2001 From: Wesley Rosa Date: Mon, 20 Jan 2025 12:17:33 -0300 Subject: [PATCH 2/5] Changelog and readme entries --- changelog.txt | 1 + readme.txt | 1 + 2 files changed, 2 insertions(+) diff --git a/changelog.txt b/changelog.txt index 1bea82292..97b1742fc 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,6 +1,7 @@ *** Changelog *** = 9.2.0 - xxxx-xx-xx = +* Fix - Fixes an error with the fingerprint property setting when using the legacy checkout. * Fix - Fixes order attribution data for the Express Checkout Element when using the Blocks API to process. * Tweak - Process ECE orders using the Blocks API. * Fix - Fixes incorrect error message for card failures due insufficient funds on the shortcode checkout page (legacy). diff --git a/readme.txt b/readme.txt index fd47cbb38..4d5baa556 100644 --- a/readme.txt +++ b/readme.txt @@ -111,6 +111,7 @@ If you get stuck, you can ask for help in the [Plugin Forum](https://wordpress.o == Changelog == = 9.2.0 - xxxx-xx-xx = +* Fix - Fixes an error with the fingerprint property setting when using the legacy checkout. * Fix - Fixes order attribution data for the Express Checkout Element when using the Blocks API to process. * Tweak - Process ECE orders using the Blocks API. * Fix - Fixes incorrect error message for card failures due insufficient funds on the shortcode checkout page (legacy). From a83bbbabfbb3c16bcbd6b6a5cf26fc257afcb977 Mon Sep 17 00:00:00 2001 From: Wesley Rosa Date: Mon, 20 Jan 2025 12:25:39 -0300 Subject: [PATCH 3/5] Moving fix inside credit card confition + change expected tructure --- includes/payment-tokens/class-wc-stripe-payment-tokens.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/includes/payment-tokens/class-wc-stripe-payment-tokens.php b/includes/payment-tokens/class-wc-stripe-payment-tokens.php index 31a2d504f..68028037b 100644 --- a/includes/payment-tokens/class-wc-stripe-payment-tokens.php +++ b/includes/payment-tokens/class-wc-stripe-payment-tokens.php @@ -183,10 +183,9 @@ public function woocommerce_get_customer_payment_tokens_legacy( $tokens, $custom $token->set_last4( $source->card->last4 ); $token->set_expiry_month( $source->card->exp_month ); $token->set_expiry_year( $source->card->exp_year ); - } - - if ( isset( $source->fingerprint ) ) { - $token->set_fingerprint( $source->fingerprint ); + if ( isset( $source->card->fingerprint ) ) { + $token->set_fingerprint( $source->card->fingerprint ); + } } $token->set_user_id( $customer_id ); From 3c47807c721a623a7c432b37502135b21397baef Mon Sep 17 00:00:00 2001 From: Wesley Rosa Date: Mon, 20 Jan 2025 12:27:47 -0300 Subject: [PATCH 4/5] Fixing the same issue for Sepa tokens --- includes/payment-tokens/class-wc-stripe-payment-tokens.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/includes/payment-tokens/class-wc-stripe-payment-tokens.php b/includes/payment-tokens/class-wc-stripe-payment-tokens.php index 68028037b..15a49d900 100644 --- a/includes/payment-tokens/class-wc-stripe-payment-tokens.php +++ b/includes/payment-tokens/class-wc-stripe-payment-tokens.php @@ -223,7 +223,9 @@ public function woocommerce_get_customer_payment_tokens_legacy( $tokens, $custom $token->set_gateway_id( WC_Gateway_Stripe_Sepa::ID ); $token->set_last4( $source->sepa_debit->last4 ); $token->set_user_id( $customer_id ); - $token->set_fingerprint( $source->fingerprint ); + if ( isset( $source->sepa_debit->fingerprint ) ) { + $token->set_fingerprint( $source->sepa_debit->fingerprint ); + } $token->save(); $tokens[ $token->get_id() ] = $token; } else { From f384cf3e6dffb80bb4526b2488b26e324e29a95d Mon Sep 17 00:00:00 2001 From: Wesley Rosa Date: Mon, 20 Jan 2025 17:07:04 -0300 Subject: [PATCH 5/5] Revert automatic lint updates --- .../class-wc-stripe-payment-tokens.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/includes/payment-tokens/class-wc-stripe-payment-tokens.php b/includes/payment-tokens/class-wc-stripe-payment-tokens.php index 15a49d900..9732f72ee 100644 --- a/includes/payment-tokens/class-wc-stripe-payment-tokens.php +++ b/includes/payment-tokens/class-wc-stripe-payment-tokens.php @@ -21,12 +21,12 @@ class WC_Stripe_Payment_Tokens { * The values are the related gateway ID we use for them in the extension. */ const UPE_REUSABLE_GATEWAYS_BY_PAYMENT_METHOD = [ - WC_Stripe_UPE_Payment_Method_CC::STRIPE_ID => WC_Stripe_UPE_Payment_Gateway::ID, - WC_Stripe_UPE_Payment_Method_Link::STRIPE_ID => WC_Stripe_UPE_Payment_Gateway::ID, - WC_Stripe_UPE_Payment_Method_Bancontact::STRIPE_ID => WC_Stripe_UPE_Payment_Gateway::ID . '_' . WC_Stripe_UPE_Payment_Method_Bancontact::STRIPE_ID, - WC_Stripe_UPE_Payment_Method_Ideal::STRIPE_ID => WC_Stripe_UPE_Payment_Gateway::ID . '_' . WC_Stripe_UPE_Payment_Method_Ideal::STRIPE_ID, - WC_Stripe_UPE_Payment_Method_Sepa::STRIPE_ID => WC_Stripe_UPE_Payment_Gateway::ID . '_' . WC_Stripe_UPE_Payment_Method_Sepa::STRIPE_ID, - WC_Stripe_UPE_Payment_Method_Sofort::STRIPE_ID => WC_Stripe_UPE_Payment_Gateway::ID . '_' . WC_Stripe_UPE_Payment_Method_Sofort::STRIPE_ID, + WC_Stripe_UPE_Payment_Method_CC::STRIPE_ID => WC_Stripe_UPE_Payment_Gateway::ID, + WC_Stripe_UPE_Payment_Method_Link::STRIPE_ID => WC_Stripe_UPE_Payment_Gateway::ID, + WC_Stripe_UPE_Payment_Method_Bancontact::STRIPE_ID => WC_Stripe_UPE_Payment_Gateway::ID . '_' . WC_Stripe_UPE_Payment_Method_Bancontact::STRIPE_ID, + WC_Stripe_UPE_Payment_Method_Ideal::STRIPE_ID => WC_Stripe_UPE_Payment_Gateway::ID . '_' . WC_Stripe_UPE_Payment_Method_Ideal::STRIPE_ID, + WC_Stripe_UPE_Payment_Method_Sepa::STRIPE_ID => WC_Stripe_UPE_Payment_Gateway::ID . '_' . WC_Stripe_UPE_Payment_Method_Sepa::STRIPE_ID, + WC_Stripe_UPE_Payment_Method_Sofort::STRIPE_ID => WC_Stripe_UPE_Payment_Gateway::ID . '_' . WC_Stripe_UPE_Payment_Method_Sofort::STRIPE_ID, WC_Stripe_UPE_Payment_Method_Cash_App_Pay::STRIPE_ID => WC_Stripe_UPE_Payment_Gateway::ID . '_' . WC_Stripe_UPE_Payment_Method_Cash_App_Pay::STRIPE_ID, ];