-
Notifications
You must be signed in to change notification settings - Fork 210
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
base: develop
Are you sure you want to change the base?
Conversation
Setting an estimate of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When I was testing this with ACH, it didn't work as expected so I dug in a bit more. What was happening was that the two updated calls to get_duplicate_token
was using us_bank_account
which wasn't finding any existing tokens. I looked into the tokens and their gateway ID is stripe_us_bank_account
. I see we have a good reference for those IDs in the WC_Stripe_Payment_Tokens
class as a const. There are a couple examples of that being used as a static, so I assume we can do the same here.
One other thing I'd note that is probably beyond the scope of this PR, but wanted your opinion since you're more familiar with this area now. I noticed we have a private WC_Stripe_Payment_Tokens::add_token_to_user
. I was wondering if it would be useful to combine this logic into one place in the future? It seems there is very similar flows in at least three places when counting the two changes you made here.
@bborman22 sorry about that 🤦♂️. I had implemented and tested the fix with reference to Since we were using
Good call! I agree we should try to combine the logic from Related to this issue we also have #4041 where |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This tested well for ACH now as the gateway ID look up was successful, but it did cause a regression with credit cards now, in that I can save the same CC multiple times. I believe this is again due to the gateway IDs not matching up. Currently CC gateway ID (in my testing at least) was just stripe
while this new approach passes in the ID of stripe_card
. This was with a newly saved CC payment method so I'm not sure if that's related? Is there any opportunity here to do a "refresh" on tokens and save them with stripe_card
gateway ID? I'd hate to carve out an exception here for naming?
This PR fixes an issue where duplicate payment tokens were being created for non-card payment methods due to an incorrect payment gateway ID being used. Previously, tokenization worked correctly only for card payments but failed for other reusable payment methods like ACH or ACSS (in progress).
Changes proposed in this Pull Request:
Testing instructions
Test 1: Reproducing the issue (on
develop
)develop
.Test 2: Verify the Fix (on this branch)
Test 3: Ensure No Regressions (Card payments)
Changelog entry
Changelog Entry Comment
Comment
Post merge