Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix duplicate token retrieval by using the correct payment method ID #4038

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
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
@@ -7,6 +7,7 @@
* Tweak - Updates the Single Payment Element setting copy. Now it is labeled "Smart Checkout".
* Update - Enable/disable Amazon Pay by adding/removing it from the enabled payment methods list.
* Add - Add ACSS payment tokenization.
* Fix - Fix duplicate token retrieval for reusable payment methods other than card.

= 9.3.0 - 2025-03-13 =
* Dev - Adds a new README.md file to the plugin with specific development-focused instructions.
Original file line number Diff line number Diff line change
@@ -2455,7 +2455,7 @@ protected function handle_saving_payment_method( WC_Order $order, $payment_metho
}

// Searches for an existing duplicate token to update.
$found_token = WC_Stripe_Payment_Tokens::get_duplicate_token( $payment_method_object, $customer->get_user_id(), $this->id );
$found_token = WC_Stripe_Payment_Tokens::get_duplicate_token( $payment_method_object, $customer->get_user_id(), $payment_method_instance->id );

if ( $found_token ) {
// Update the token with the new payment method ID.
@@ -2613,7 +2613,7 @@ public function add_payment_method() {
$customer->clear_cache();

// Check if a token with the same payment method details exist. If so, just updates the payment method ID and return.
$found_token = WC_Stripe_Payment_Tokens::get_duplicate_token( $payment_method_object, $user->ID, $this->id );
$found_token = WC_Stripe_Payment_Tokens::get_duplicate_token( $payment_method_object, $user->ID, $payment_method->id );

// If we have a token found, update it and return.
if ( $found_token ) {
1 change: 1 addition & 0 deletions readme.txt
Original file line number Diff line number Diff line change
@@ -117,5 +117,6 @@ If you get stuck, you can ask for help in the [Plugin Forum](https://wordpress.o
* Tweak - Updates the Single Payment Element setting copy. Now it is labeled "Smart Checkout".
* Update - Enable/disable Amazon Pay by adding/removing it from the enabled payment methods list.
* Add - Add ACSS payment tokenization.
* Fix - Fix duplicate token retrieval for reusable payment methods other than card.

[See changelog for all versions](https://raw.githubusercontent.com/woocommerce/woocommerce-gateway-stripe/trunk/changelog.txt).

Unchanged files with check annotations Beta

import { test, expect } from '@playwright/test';

Check failure on line 1 in tests/e2e/tests/checkout/shortcode/normal-card.spec.js

GitHub Actions / Default WP=latest, WC=latest, PHP=7.4

[default] › checkout/shortcode/normal-card.spec.js:12:5 › customer can checkout with a normal credit card @smoke

1) [default] › checkout/shortcode/normal-card.spec.js:12:5 › customer can checkout with a normal credit card @smoke Test timeout of 90000ms exceeded.
import config from 'config';
import { payments } from '../../../utils';
);
await fillCreditCardDetailsShortcode( page, config.get( 'cards.basic' ) );
await page.locator( 'text=Place order' ).dispatchEvent( 'click' );
await page.waitForNavigation();

Check failure on line 23 in tests/e2e/tests/checkout/shortcode/normal-card.spec.js

GitHub Actions / Default WP=latest, WC=latest, PHP=7.4

[default] › checkout/shortcode/normal-card.spec.js:12:5 › customer can checkout with a normal credit card @smoke

1) [default] › checkout/shortcode/normal-card.spec.js:12:5 › customer can checkout with a normal credit card @smoke Error: page.waitForNavigation: Test timeout of 90000ms exceeded. =========================== logs =========================== waiting for navigation until "load" ============================================================ 21 | await fillCreditCardDetailsShortcode( page, config.get( 'cards.basic' ) ); 22 | await page.locator( 'text=Place order' ).dispatchEvent( 'click' ); > 23 | await page.waitForNavigation(); | ^ 24 | 25 | await expect( page.locator( 'h1.entry-title' ) ).toHaveText( 26 | 'Order received' at /home/runner/work/woocommerce-gateway-stripe/woocommerce-gateway-stripe/tests/e2e/tests/checkout/shortcode/normal-card.spec.js:23:13
await expect( page.locator( 'h1.entry-title' ) ).toHaveText(
'Order received'