Skip to content

Commit

Permalink
Fix token save
Browse files Browse the repository at this point in the history
  • Loading branch information
asumaran committed Jan 29, 2025
1 parent 5f6de5f commit 8ae932a
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class WC_Stripe_UPE_Payment_Gateway extends WC_Gateway_Stripe {
WC_Stripe_UPE_Payment_Method_Link::class,
WC_Stripe_UPE_Payment_Method_Wechat_Pay::class,
WC_Stripe_UPE_Payment_Method_Cash_App_Pay::class,
WC_Stripe_UPE_Payment_Method_Bacs::class,
WC_Stripe_UPE_Payment_Method_Bacs_Debit::class,
];

/**
Expand Down Expand Up @@ -163,7 +163,7 @@ public function __construct() {
continue;
}

if ( WC_Stripe_UPE_Payment_Method_Bacs::class === $payment_method_class && ! WC_Stripe_Feature_Flags::is_bacs_lpm_enabled() ) {
if ( WC_Stripe_UPE_Payment_Method_Bacs_Debit::class === $payment_method_class && ! WC_Stripe_Feature_Flags::is_bacs_lpm_enabled() ) {
continue;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/**
* The Bacs Direct Debit Payment Method class extending UPE base class.
*/
class WC_Stripe_UPE_Payment_Method_Bacs extends WC_Stripe_UPE_Payment_Method {
class WC_Stripe_UPE_Payment_Method_Bacs_Debit extends WC_Stripe_UPE_Payment_Method {
/**
* The Stripe ID for the payment method.
*/
Expand Down Expand Up @@ -55,7 +55,7 @@ public function get_retrievable_type() {
}

public function create_payment_token_for_user( $user_id, $payment_method ) {
$token = new WC_Payment_Token_Bacs();
$token = new WC_Payment_Token_Bacs_Debit();
$token->set_token( $payment_method->id );
$token->set_gateway_id( $this->id );
$token->set_last4( $payment_method->bacs_debit->last4 );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

// phpcs:disable WordPress.Files.FileName

class WC_Payment_Token_Bacs extends WC_Payment_Token implements WC_Stripe_Payment_Method_Comparison_Interface {
class WC_Payment_Token_Bacs_Debit extends WC_Payment_Token implements WC_Stripe_Payment_Method_Comparison_Interface {
use WC_Stripe_Fingerprint_Trait;

protected $type = WC_Stripe_Payment_Methods::BACS_DEBIT;
Expand Down
7 changes: 3 additions & 4 deletions includes/payment-tokens/class-wc-stripe-payment-tokens.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class WC_Stripe_Payment_Tokens {
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,
WC_Stripe_UPE_Payment_Method_Bacs::STRIPE_ID => WC_Stripe_UPE_Payment_Gateway::ID . '_' . WC_Stripe_UPE_Payment_Method_Bacs::STRIPE_ID,
WC_Stripe_UPE_Payment_Method_Bacs_Debit::STRIPE_ID => WC_Stripe_UPE_Payment_Gateway::ID . '_' . WC_Stripe_UPE_Payment_Method_Bacs_Debit::STRIPE_ID,
];

/**
Expand Down Expand Up @@ -526,9 +526,8 @@ private function add_token_to_user( $payment_method, WC_Stripe_Customer $custome
$token->set_last4( $payment_method->card->last4 );
$token->set_fingerprint( $payment_method->card->fingerprint );
break;

case WC_Stripe_UPE_Payment_Method_Bacs::STRIPE_ID:
$token = new WC_Payment_Token_Bacs();
case WC_Stripe_UPE_Payment_Method_Bacs_Debit::STRIPE_ID:
$token = new WC_Payment_Token_Bacs_Debit();
$token->set_token( $payment_method->id );
$token->set_last4( $payment_method->bacs_debit->last4 );
$token->set_fingerprint( $payment_method->bacs_debit->fingerprint );
Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/helpers/class-wc-helper-order.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public static function create_order( $customer_id = 1, $product = null, $order_p

// Set payment gateway.
$payment_gateways = WC()->payment_gateways->payment_gateways();
$order->set_payment_method( $payment_gateways['bacs'] );
$order->set_payment_method( $payment_gateways['bacs_debit'] );

// Set totals.
$order->set_shipping_total( 10 );
Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/test-class-wc-stripe-upe-payment-method.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ private function reset_payment_method_mocks( $exclude_methods = [] ) {

foreach ( WC_Stripe_UPE_Payment_Gateway::UPE_AVAILABLE_METHODS as $payment_method_class ) {
// Bacs is under flag, remove when is enabled by default.
if ( WC_Stripe_UPE_Payment_Method_Bacs::class === $payment_method_class ) {
if ( WC_Stripe_UPE_Payment_Method_Bacs_Debit::class === $payment_method_class ) {
continue;
}

Expand Down
2 changes: 1 addition & 1 deletion woocommerce-gateway-stripe.php
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ public function init() {
require_once __DIR__ . '/includes/payment-methods/class-wc-stripe-upe-payment-method.php';
require_once __DIR__ . '/includes/payment-methods/class-wc-stripe-upe-payment-method-cc.php';
require_once __DIR__ . '/includes/payment-methods/class-wc-stripe-upe-payment-method-alipay.php';
require_once __DIR__ . '/includes/payment-methods/class-wc-stripe-upe-payment-method-bacs.php';
require_once __DIR__ . '/includes/payment-methods/class-wc-stripe-upe-payment-method-bacs-debit.php';
require_once __DIR__ . '/includes/payment-methods/class-wc-stripe-upe-payment-method-giropay.php';
require_once __DIR__ . '/includes/payment-methods/class-wc-stripe-upe-payment-method-ideal.php';
require_once __DIR__ . '/includes/payment-methods/class-wc-stripe-upe-payment-method-klarna.php';
Expand Down

0 comments on commit 8ae932a

Please sign in to comment.