#inxilpro - checkout tests

1 messages · Page 1 of 1 (latest)

cobalt wedge
#

Hi there one moment

#

Yeah the recommended way to test things is to use mocks

golden mountain
#

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.created
  • coupon.created
  • coupon.updated
  • charge.succeeded
  • payment_method.attached
  • checkout.session.completed
  • customer.updated
  • customer.discount.created
  • customer.discount.deleted
  • invoice.created
  • invoice.finalized
  • customer.subscription.created
  • invoice.updated
  • customer.subscription.updated
  • invoice.paid
  • invoice.payment_succeeded
  • payment_intent.created
  • payment_intent.succeeded
  • invoice.upcoming
  • invoice.created
cobalt wedge
#

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?

golden mountain
#

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.

cobalt wedge
#

Gotcha. Checkout is constantly evolving so yeah I do recommend manual testing with a test card when making a change like that.

golden mountain
#

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.

cobalt wedge
#

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

golden mountain
#

Thanks.

#

It looks like stripe-cli kind of does this with the trigger checkout.session.completed function

sturdy cedar
#

👋 stepping in for codename_duchess as they need to step away

#

Is there anything else I can help with here?