#uiguig377

1 messages ยท Page 1 of 1 (latest)

minor gulchBOT
steel plover
#

there're test cards here which you can use - https://stripe.com/docs/testing

If you click on the PaymentMethods tabs, you can use those ids to attach those payment methods to your customers

hearty spoke
#

Thanks for that, but I need the whole process to be automated (these are not manual tests, they are automated tests)

steel plover
#

i'm a bit confused, can you explain a test scenario as an example which you're trying to automate?

hearty spoke
#

Sure, thanks for taking a look ๐Ÿ™‚

#

My app works by attaching Payment Methods to its Customers. This is done using setup intents.
The app also lets users list and manage their payment methods.
I need to write server-side tests for the API of these features. So my test needs to :

  • Create a customer (this is OK)
  • Attach 2 payment methods to the customer (1 card and 1 SEPA mandate)
  • Test the API endpoints that list the methods and remove them
minor gulchBOT
oblique jolt
#

What particular issue are you running into in that flow?

hearty spoke
#

Since I only have a backend (no client) I don't know how to finalize the setup intents ๐Ÿ™‚

oblique jolt
#

You can't really, depending on which test cards you use. A lot of them require 3DS/authentication, which mimics real-world scenario, where your customer needs to verify the action in your front-end application

hearty spoke
#

I understand

#

then is it possible to attach arbitrary PMs to customers in this context ?
It would really make sense to be able to test such things

#

(they have to work ๐Ÿ˜… )

oblique jolt
#

Well using the attach endpoint/method isn't really recommended as it doesn't support facilitating 3DS/auth flows (it'll just error). That's why we built Setup Intents

#

So it depends on which APIs you're describing when you say 'attach arbitrary PMs to customers in this context'

hearty spoke
#

Actually, anything that gives me data in response to
stripe.PaymentMethod.list(customer=org.stripe_customer_id)
would do, this is just for testing.
Another option I see is stubbing replies, but this would mean work to re-stub every time we upgrade the API level ...

oblique jolt
hearty spoke
oblique jolt
#

Yes, that will work for your testing scenario

hearty spoke
#

ok, thanks !
I was discouraged by the notice "To attach a new PaymentMethod to a customer for future payments, we recommend you use a SetupIntent or a PaymentIntent with setup_future_usage."
Maybe it would make sense to add that it can be used as a shortcut for testing.
Anyways thanks for your time and help ! ๐Ÿ™‚

oblique jolt
#

I was discouraged by the notice "To attach a new PaymentMethod to a customer for future payments, we recommend you use a SetupIntent or a PaymentIntent with setup_future_usage."
Yup, as explained that's the real life recommend approach. The APIs you're using don't work in the real life scenarios you're describing

#

But for the purposes of attaching a PM to return an object in a list, its fine