-
Notifications
You must be signed in to change notification settings - Fork 69
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
Multiple UPE - SEPA tokens appear in list of credit card tokens #4530
Comments
It looks like this might require re-implementing this PR. A lot of that code still exists in WCPay but I think much of it was removed when SEPA was introduced as a payment method within the UPE. |
Whenever saved payment methods appear on screen, WC Core essentially applies the This function works by collecting currently stored WC Tokens and collecting Stripe payment methods saved to the current customer. Note that the request to do the latter takes two parameters: Then we compare the two lists. If there are tokens stored by Stripe not yet present in WC, we create a new token and mark them as found. The remaining tokens, no longer known by Stripe, are removed. This is essentially how we save new payment methods in WooCommerce with the UPE: we save them to Stripe and then create new WC Tokens on the fly when this function is called. More on that later... This basic functionality should remain, however, instead of looping through all the payment method types in the main gateway, we now need to use the So that's what I think we need to do to gather saved payment methods, but there's one last missing piece when it comes to creating them that I referred to earlier: we need to create a valid WC Token to store the saved payment methods in WooCommerce. Now when we save a payment method via Stripe, essentially one of three things will happen: for the card payment method, a reusable card payment method is created; for the SEPA payment method, a reusable SEPA payment method is created; for any other reusable payment method, the payment method is converted and stored as a reusable SEPA payment method. So from our perspective, we will need two types of WC Tokens: card tokens (which exist by default) and SEPA tokens, which exists here and, I believe, was used in #1540. The catch here is that for this third category of payment method types (reusable, yet non-card and non-SEPA), after Stripe has converted these payment methods to reusable payment methods, from Stripe's perspective they are now fully-fledged SEPA payment methods and their payment method type is now SEPA--rather than the original payment method type. This means that when we make requests to Stripe for saved SEPA payment methods, the response will include these converted payment methods. This is a problem, because we would like to keep these saved payment methods separate--for example, only returning originally SEPA payment methods to the SEPA gateway and originally Bancontact payment methods (even though they will be SEPA tokens) to the Bancontact payment gateway. This is a solvable problem, even though the solution is a little unwieldy. Stripe does leave a few clues as to the original payment method type, but unfortunately they are a little buried in the response. I would encourage you to check out how we implemented this functionality on the Stripe gateway--specifically this function--because we managed to figure out how to handle most of these unfortunate oddities. Essentially, there are expandable fields on the API response that we can use to find the original payment method type (more information from Stripe here on expanding fields in their API response). We also add some meta onto our saved WC SEPA Tokens, so that we can reverse this process more easily. There's a lot of information in this comment and there's probably a fair bit that I haven't included, so I'd highly recommend following the implementation on the Stripe Gateway--using your own judgement to take what's required--as a reference to help you resolving this issue. Let me know if there's anything else in between that I might be able to help flesh out in the meantime. Cheers! |
Describe the bug
#4427 allows payment methods to be added via the Add Payment Method page. The payment methods that are currently available to be saved for future use are CC and SEPA. Prior to #4427, all stored tokens appeared under the single WC Payments gateway, as that was the only place they could be listed. Now that each UPE payment method is it's own gateway, saved SEPA payment methods should appear under the SEPA gateway rather than the CC gateway.
To Reproduce
git checkout poc/upe-instances-multiplied
Actual behavior
Screenshots
Acceptance Criteria
poc/upe-instances-multiplied
, notdevelop
.The text was updated successfully, but these errors were encountered: