When saving APMs in develop and switching to Split PE, they get duplicated.
This would be the scenario when users upgrade to 8.0.0.
We need to handle this migration gracefully:
The tokens must not appear as duplicated for the shopper in 8.0.0.
The old tokens must not be removed from the database, so merchants could roll back to < 8.0.0 if needed without the shoppers losing their saved payment methods.
To Reproduce
Creating the tokens in an older version
Check out develop
Select EUR as the store currency
Under the Stripe settings, enable UPE and enable SEPA
As a shopper, go to the checkout page
Select "Use a new payment method"
Select SEPA
Enter AT611904300234573201 and check off "Save payment information to my account for future purchases"
Place the order
Go to My Account > Payment methods
Notice there's a token for the SEPA payment method, all good
Upgrading to 8.0.0
Check out add/deferred-intent
Reload the My Account > Payment methods page
Notice that the tokens for SEPA got duplicated
Go to the shortcode checkout page
Notice the SEPA payment methods exist under both the Credit Card and the SEPA gateways
Expected behavior
The APMs must not appear duplicated for the merchant or the shopper.
Additional context
Butwhy
When retrieving the tokens for a user, we check them with the payment methods saved in Stripe. The payment methods in Stripe are our source of truth. Local payment methods will get created or deleted according to those. This is handled by WC_Stripe_Payment_Tokens::woocommerce_get_customer_upe_payment_tokens().
In previous versions, all APMs were saved under the stripe gateway. Since 8.0.0, each APM has its own gateway instead.
The APM tokens saved in previous versions will belong to the stripe gateway.
When retrieving the SEPA payment methods from Stripe, 8.0.0 we'll expect them to exist under the stripe_sepa_debit gateway. We'll create them because these wouldn't exist, thus the duplication.
Describe the bug
When saving APMs in
develop
and switching to Split PE, they get duplicated. This would be the scenario when users upgrade to 8.0.0.We need to handle this migration gracefully:
To Reproduce
Creating the tokens in an older version
develop
AT611904300234573201
and check off "Save payment information to my account for future purchases"Upgrading to 8.0.0
add/deferred-intent
Expected behavior The APMs must not appear duplicated for the merchant or the shopper.
Additional context
Butwhy
WC_Stripe_Payment_Tokens::woocommerce_get_customer_upe_payment_tokens()
.stripe
gateway. Since 8.0.0, each APM has its own gateway instead.stripe
gateway.stripe_sepa_debit
gateway. We'll create them because these wouldn't exist, thus the duplication.