Open a-danae opened 1 year ago
Hi, This issue has gone 150 days (5 months) without any activity. This means it is time for a check-in to make sure it is still relevant. If you are still experiencing this issue with the latest version, you can help the project by responding to confirm the problem and by providing any updated reproduction steps. Thanks for helping out.
This issue has gone 180 days (6 months) without any activity.
Describe the bug (Probably not a bug but a UX that could be improved)
A payment method can be attached to the Stripe customer but not show up in the Payment methods page right away under certain circumstances.
To Reproduce Steps to reproduce the behavior:
eturn '';
early in WC_Stripe_Payment_Gateway::get_source_objectExpected behavior
I'd expect the payment method to show up under My account -> Payment methods if it was attached to the Stripe customer and can be used during checkout.
Screenshots If applicable, add screenshots to help explain your problem.
Additional context
Spotted by @mattallan in https://github.com/woocommerce/woocommerce-gateway-stripe/pull/2659#pullrequestreview-1544583474.
The payment method gets attached to the Stripe customer before WC_Stripe_Payment_Gateway::add_payment_method() is called. It happens in: -> WC_Stripe_Intent_Controller's wc_ajax_wc_stripe_create_setup_intent action -> WC_Stripe_Intent_Controller's::create_setup_intent() -> WC_Stripe_Customer::attach_source() -> WC_Stripe_API::attach_payment_method_to_customer()
The payment method is attached to the Stripe customer, but the token isn't stored in the DB, so it doesn't show up in My account -> Payment methods. The customer's payment methods are retrieved when visiting the checkout page, and I assume they get stored in the DB then.
So, the -> WC_Stripe_Payment_Gateway::add_payment_method -> WC_Stripe_Customer::add_source method saves the payment token to the DB. The payment method was already attached to the Stripe customer at this point.