#Yang MR - redirectToCheckout
1 messages · Page 1 of 1 (latest)
Hi there. One moment while I catch up here
Hi yeah: https://stripe.com/docs/js/checkout/redirect_to_checkout. But using that isn't the current recommended way to use Stripe Checkout. We currently recommend creating the session on the server, then only doing a redirect client side upon retrieving the URL: https://stripe.com/docs/payments/accept-a-payment?platform=web&ui=checkout
I'm doing E2E testing so I don't have much agency over such a change
If stripe.redirectToCheckout() is indeed used, how does the process of getting a URL and redirecting work?
It just calls stripe to create a checkout session and redirects to the session url provided
How does the process work though? Does it send a POST request to a specific URL?
And I presume that the function redirects locally based on the URL returned from the Stripe API?
What are you trying to do here?
Intercept the POST return to prevent it from actually redirecting since that breaks the test
With automated testing flows, we highly discourage calling the Stripe API as those calls unnecessarily put load on the API and contribute to rate limits. Instead, we recommend stubbing out or mocking calls where necessary
How do you mean by stubbing calls?
It's a standard automated testing practice. I recommend googling
Yes, but which calls? Those to the API? If so, then the rest of the stuff like the webhook can't exactly be tested
I'm talking about automated testing
Many calls made to the Stripe API in small amounts of time
Not talking about testing webhooks
For the automated testing there would be very few API calls made
My point is, how do you test the webhooks without making API calls?