#inxilpro - checkout tests
1 messages · Page 1 of 1 (latest)
Hi there one moment
Yeah the recommended way to test things is to use mocks
We have this library that may help your usecase: https://github.com/stripe/stripe-mock
But stripe-mock doesn't have a way to mock a Checkout session, does it?
The problem is that finalizing a Checkout session triggers about 20 events, and right now, the only way to know what those events are is by recording the results of a manual test.
And I would imagine that how checkout works will probably change over time
Which means that if I hard-code a bunch of mocks now, that test won't represent reality if checkout ever changes
That one POST to /v1/payment_pages/{id} triggers all of these events:
customer.createdcoupon.createdcoupon.updatedcharge.succeededpayment_method.attachedcheckout.session.completedcustomer.updatedcustomer.discount.createdcustomer.discount.deletedinvoice.createdinvoice.finalizedcustomer.subscription.createdinvoice.updatedcustomer.subscription.updatedinvoice.paidinvoice.payment_succeededpayment_intent.createdpayment_intent.succeededinvoice.upcominginvoice.created
Yeah Stripe mock is mostly just used for generating proper api responses for calls
Unfortunately there's not a good way to automate that checkout flow in tests other than the approach you outlined
Is there a reason you need all these events?
I would like my test to be as close to production as possible. That way, if we add listeners for one of those events in the future, our tests would pick up any new bugs we introduce.
Gotcha. Checkout is constantly evolving so yeah I do recommend manual testing with a test card when making a change like that.
Right now I really only care about customer.subscription.updated and invoice.payment_succeeded, but if I eventually add code that triggers on invoice.paid, my existing test won't catch any issues with that.
Hm, OK.
Well, I'd love to put in a feature request for /v1/test_helpers/checkout/sessions/:id/complete or something similar that I could pass a payment method to to simulate completing a session.
Sure thing. I'll pass this along to the Checkout team. There won't be any guarantees though on implementation/time frame due to prioritization