stripe-samples / checkout-single-subscription

Learn how to combine Checkout and Billing for fast subscription pages

Home Page:https://checkout.stripe.dev/?mode=subscription

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Checkout page attaches Payment Method to customer even if card data is incorrect.

ukito-pl opened this issue · comments

Bug report

Describe the bug

Checkout page in 'subscription' mode saves payment methods even when payment is not sucessfull (declined card for example).
This may not be a bug in a strict sense but it is a major inconvience, because if user enters wrong card data by mistake it will be later seen in his payment methods without any indication that it is wrong card.

After inspecting events generated by stripe I can see that there is no setup_intent.* events present in logs. So it seems like Checkout in subscription mode doesn't use SetupIntent API to create payment methods as is recommended in docs (https://stripe.com/docs/api/payment_methods/attach). When I used SetupIntent API to manually add a payment method to a customer it is not created if card data is incorrect, which is desirable behaviour.

I understand that it may be a design decision to make it work that way, but it is unituitive from customer's view point.

To Reproduce

  1. Create customer
  2. Create Checkout Session in subscription mode with added customer field and payment_method_types set to ['card']
  3. Go to Checkout page
  4. Enter wrong card data ( for example 4000000000000002 from test cards list: https://stripe.com/docs/testing#cards-responses)
  5. Enter correct card (for example 4242424242424242 from test cards list)
  6. Go to dashboard or customer portal to see that coresponding customer has failed payment method attached to his account.

Expected behavior

I expected that Checkout page wouldn't add payment methods to customer if first subscription payment has failed.

Screenshots

System information

Additional context

Hey @ukito-pl Thanks for reaching out.

This is more of a feature request of Checkout rather than anything related to this sample. Please reach out to support.stripe.com/contact so that we can correctly record your feature request. Thanks!