woocommerce / woocommerce-gateway-stripe

The official Stripe Payment Gateway for WooCommerce
https://wordpress.org/plugins/woocommerce-gateway-stripe/
236 stars 206 forks source link

Allow saved credit cards with a source ID (`src_`) to be used/displayed with the new checkout experience #3513

Closed mattallan closed 1 month ago

mattallan commented 1 month ago

Fixes #3498

Changes proposed in this Pull Request:

As part of updating/migrating SEPA tokens over to pm_ IDs, we also worked on a change (see https://github.com/woocommerce/woocommerce-gateway-stripe/pull/3241) that removed support for displaying and storing any legacy src_ tokens. This fix was introduced because payment method requests with SEPA src_ tokens would failed.

From Stripe's docs on sources (https://docs.stripe.com/sources), they do however still support source tokens for card payments and so we should continue to support them in our extension.

image

While investigating https://github.com/woocommerce/woocommerce-gateway-stripe/issues/3498, we found that Google Pay and Apple Pay were still create valid credit card payment methods beginning with src_ and so our changes to remove/hide all saved cards with sources unexpectedly impacted customers that purchased using our Payment Request buttons.

The changes in this PR brings back support for displaying and storing payment methods starting with src_ but only for credit cards.

Proposed changes:

[!NOTE] In @james-allan 's PR https://github.com/woocommerce/woocommerce-gateway-stripe/pull/3510, he's updating our Payment Request buttons implementation so that any new saved cards will be created as pm_ IDs.

In this PR, I'm fixing the issue for stores with existing customers with these saved legacy tokens.

Testing instructions

For the purpose of testing, I removed all my existing saved cards via the My Account > Payment methods page.

  1. Enable WooCommerce Subscriptions and create a simple subscription product
  2. Enable New Checkout experience and Apple Pay/Google Pay payment method
  3. Make sure you're not using the new ECE feature (_wcstripe_feature_ece is set to 'no' in wp-options)
  4. While on trunk, go to My Account > payment methods and confirm you have no saved payment methods
  5. Purchase a subscription product using Google Pay or Apple Pay
  6. From the stripe dashboard, navigate to the latest transaction and notice the payment method is a src token: image
  7. Navigate to My Account > Payment methods and notice there's no saved card.image
  8. Look in wp_woocommerce_payment_tokens table and notice there's no saved stripe tokens.
  9. Checkout this branch
  10. Refresh the My Account > Payment methods page to pull the latest saved methods from Stripe.
  11. Confirm you now have a saved credit card.
  12. Check the wp_woocommerce_payment_tokens table again and confirm you now see the saved src_ token with type 'CC'.

Post merge