#uiguig377
1 messages ยท Page 1 of 1 (latest)
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
Thanks for that, but I need the whole process to be automated (these are not manual tests, they are automated tests)
i'm a bit confused, can you explain a test scenario as an example which you're trying to automate?
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
What particular issue are you running into in that flow?
Since I only have a backend (no client) I don't know how to finalize the setup intents ๐
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
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 ๐ )
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'
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 ...
If that's all you want to test, then just use the attach endpoint a 4242 PM object.
yes this is all I want to test ! sorry if that wasn't clear.
So , the workflow is :
- Create PM object from 4242 test card or any other method
- attach it to customer
Am I correct ?
Yes, that will work for your testing scenario
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 ! ๐
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