Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
*** Changelog ***

= 9.10.0 - xxxx-xx-xx =
* Fix - Minor fixes and code improvements for the saved payment methods comparison logic
* Dev - Upgrades Node to v20
* Add - Allow the purchase of free trials using the Express Payment methods when the product does not require shipping
* Update - Changes the documentation page URL for the Optimized Checkout feature to https://woocommerce.com/document/stripe/admin-experience/optimized-checkout-suite/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,7 @@ public function get_retrievable_type() {
public function create_payment_token_for_user( $user_id, $payment_method ) {
$token = new WC_Payment_Token_CashApp();

$gateway_id = $this->is_oc_enabled() ? 'stripe' : $this->id;

$token->set_gateway_id( $gateway_id );
$token->set_gateway_id( WC_Stripe_Payment_Tokens::UPE_REUSABLE_GATEWAYS_BY_PAYMENT_METHOD[ self::STRIPE_ID ] );
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's the first fix here.

$token->set_token( $payment_method->id );
$token->set_user_id( $user_id );

Expand Down
9 changes: 4 additions & 5 deletions includes/payment-tokens/class-wc-stripe-ach-payment-token.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,12 +161,11 @@ public function set_last4( $last4 ) {
* @inheritDoc
*/
public function is_equal_payment_method( $payment_method ): bool {
if (
WC_Stripe_Payment_Methods::ACH === $payment_method->type
&& ( $payment_method->{WC_Stripe_Payment_Methods::ACH}->fingerprint ?? null ) === $this->get_fingerprint() ) {
return true;
if ( WC_Stripe_Payment_Methods::ACH !== $payment_method->type ) {
return false;
}

return false;
// ACH uses the `us_bank_account` property
return ( $payment_method->us_bank_account->fingerprint ?? null ) === $this->get_fingerprint();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,11 @@ class WC_Payment_Token_ACSS extends WC_Payment_Token implements WC_Stripe_Paymen
* @return bool
*/
public function is_equal_payment_method( $payment_method ): bool {
if ( WC_Stripe_Payment_Methods::ACSS_DEBIT === $payment_method->type
&& ( $payment_method->acss_debit->fingerprint ?? null ) === $this->get_fingerprint() ) {
return true;
if ( WC_Stripe_Payment_Methods::ACSS_DEBIT !== $payment_method->type ) {
return false;
}

return false;
return ( $payment_method->acss_debit->fingerprint ?? null ) === $this->get_fingerprint();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,10 @@ public function set_email( $email ) {
* @inheritDoc
*/
public function is_equal_payment_method( $payment_method ): bool {
if ( WC_Stripe_Payment_Methods::AMAZON_PAY === $payment_method->type
&& ( $payment_method->billing_details->email ?? null ) === $this->get_email() ) {
return true;
if ( WC_Stripe_Payment_Methods::AMAZON_PAY !== $payment_method->type ) {
return false;
}

return false;
return ( $payment_method->billing_details->email ?? null ) === $this->get_email();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,11 @@ class WC_Payment_Token_Bacs_Debit extends WC_Payment_Token implements WC_Stripe_
* @return bool
*/
public function is_equal_payment_method( $payment_method ): bool {
if ( WC_Stripe_Payment_Methods::BACS_DEBIT === $payment_method->type
&& ( $payment_method->bacs_debit->fingerprint ?? null ) === $this->get_fingerprint() ) {
return true;
if ( WC_Stripe_Payment_Methods::BACS_DEBIT !== $payment_method->type ) {
return false;
}

return false;
return ( $payment_method->bacs_debit->fingerprint ?? null ) === $this->get_fingerprint();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,11 @@ public function set_last4( $last4 ) {
* @inheritDoc
*/
public function is_equal_payment_method( $payment_method ): bool {
if (
WC_Stripe_Payment_Methods::BECS_DEBIT === $payment_method->type
&& ( $payment_method->{WC_Stripe_Payment_Methods::BECS_DEBIT}->fingerprint ?? null ) === $this->get_fingerprint() ) {
return true;
if ( WC_Stripe_Payment_Methods::BECS_DEBIT !== $payment_method->type ) {
return false;
}

return false;
// Becs Debit uses the au_becs_debit property.
return ( $payment_method->au_becs_debit->fingerprint ?? null ) === $this->get_fingerprint();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,11 @@ public function get_cashtag() {
* @inheritDoc
*/
public function is_equal_payment_method( $payment_method ): bool {
if ( WC_Stripe_Payment_Methods::CASHAPP_PAY === $this->get_type()
&& ( $payment_method->cashapp->cashtag ?? null ) === $this->get_cashtag() ) {
return true;
if ( WC_Stripe_Payment_Methods::CASHAPP_PAY !== $payment_method->type ) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And that's the second fix.

return false;
}

return false;
return ( $payment_method->cashapp->cashtag ?? null ) === $this->get_cashtag();
}

/**
Expand Down
7 changes: 3 additions & 4 deletions includes/payment-tokens/class-wc-stripe-cc-payment-token.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,10 @@ public function __construct( $token = '' ) {
* @inheritDoc
*/
public function is_equal_payment_method( $payment_method ): bool {
if ( WC_Stripe_Payment_Methods::CARD === $payment_method->type
&& ( $payment_method->card->fingerprint ?? null ) === $this->get_fingerprint() ) {
return true;
if ( WC_Stripe_Payment_Methods::CARD !== $payment_method->type ) {
return false;
}

return false;
return ( $payment_method->card->fingerprint ?? null ) === $this->get_fingerprint();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,10 @@ public function set_email( $email ) {
* @inheritDoc
*/
public function is_equal_payment_method( $payment_method ): bool {
if ( WC_Stripe_Payment_Methods::LINK === $payment_method->type
&& ( $payment_method->link->email ?? null ) === $this->get_email() ) {
return true;
if ( WC_Stripe_Payment_Methods::LINK !== $payment_method->type ) {
return false;
}

return false;
return ( $payment_method->link->email ?? null ) === $this->get_email();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,10 @@ public function get_payment_method_type( $context = 'view' ) {
* @inheritDoc
*/
public function is_equal_payment_method( $payment_method ): bool {
if ( WC_Stripe_Payment_Methods::SEPA_DEBIT === $payment_method->type
&& ( $payment_method->sepa_debit->fingerprint ?? null ) === $this->get_fingerprint() ) {
return true;
if ( WC_Stripe_Payment_Methods::SEPA_DEBIT !== $payment_method->type ) {
return false;
}

return false;
return ( $payment_method->sepa_debit->fingerprint ?? null ) === $this->get_fingerprint();
}
}
1 change: 1 addition & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ If you get stuck, you can ask for help in the [Plugin Forum](https://wordpress.o
== Changelog ==

= 9.10.0 - xxxx-xx-xx =
* Fix - Minor fixes and code improvements for the saved payment methods comparison logic
* Dev - Upgrades Node to v20
* Add - Allow the purchase of free trials using the Express Payment methods when the product does not require shipping
* Update - Changes the documentation page URL for the Optimized Checkout feature to https://woocommerce.com/document/stripe/admin-experience/optimized-checkout-suite/
Expand Down
Loading