-
Notifications
You must be signed in to change notification settings - Fork 210
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix creation of duplicate tokens (#3635)
* Fix creation of duplicate tokens * Fix creation of duplicate tokens * Fix duplicate tokens bug when updateing existing ones * Changelog and readme entries * Removing duplicate method * Reverting unnecessary change * Fix duplicate tokens for the block checkout * Readme and changelog updates * Readme and changelog updates * Not updating tokens if the new order is a subscription * Block existing token update if any subscription is using it * Replacing token update block with new method * Removing subscription limitation * Comparing fingerprint instead of card details + new fingerprint trait + moving tokens to a new folder * Fix CC token class overitte * Adding specific unit tests * Adding specific unit tests * Removing unnecessary trait usage * Fix tests * Adding specific unit tests * Adding specific unit tests * Fix tests * New trait to simplify duplicate comparison logic * Renaming trait + including it * Specific unit tests * Renaming the search method to get * Transforming trait into interface * Fix tests --------- Co-authored-by: Diego Curbelo <[email protected]>
- Loading branch information
1 parent
0a93ce6
commit 060fa87
Showing
20 changed files
with
641 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
includes/payment-tokens/class-wc-stripe-cc-payment-token.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
/** | ||
* WooCommerce Stripe Credit Card Payment Token | ||
* | ||
* Representation of a payment token for Credit Card. | ||
* | ||
* @package WooCommerce_Stripe | ||
* @since 9.9.0 | ||
*/ | ||
|
||
// phpcs:disable WordPress.Files.FileName | ||
|
||
// Exit if accessed directly | ||
defined( 'ABSPATH' ) || exit; | ||
|
||
class WC_Stripe_Payment_Token_CC extends WC_Payment_Token_CC implements WC_Stripe_Payment_Method_Comparison_Interface { | ||
|
||
use WC_Stripe_Fingerprint_Trait; | ||
|
||
/** | ||
* Constructor. | ||
* | ||
* @inheritDoc | ||
*/ | ||
public function __construct( $token = '' ) { | ||
// Add fingerprint to extra data to be persisted. | ||
$this->extra_data['fingerprint'] = ''; | ||
|
||
parent::__construct( $token ); | ||
} | ||
|
||
/** | ||
* Checks if the payment method token is equal a provided payment method. | ||
* | ||
* @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; | ||
} | ||
|
||
return false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.