#mfoley_api
1 messages ยท Page 1 of 1 (latest)
๐ Welcome to your new thread!
โฒ๏ธ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.
โฑ๏ธ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.
๐ This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1286706171813560413
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
Hi there ๐ if you're wanting to test your flows we typically recommend not hitting our API for that, as it'll eat into the more restrictive rate limits of testmode requests:
https://docs.stripe.com/rate-limits#rate-limiter
For those cases we recommend mocking hitting the Stripe API. You're welcome to hit the API during your development process to see exactly how we respond.
We are planning to mock responses from the Stripe API to make sure our code processes responses correctly. However, we still want to ensure Stripe is returning the correct objects by hitting the API.
However, I understand if this is against best practices/impossible
Basically we want to do integration tests against the Stripe API, and we feel it is impossible to do proper integration tests without hitting the Stripe API
Then you'll need to be very mindful of how many requests you make to the API in testmode. Where I've seen it cause problems in the past is when people hit the API as part of their automatic test suite that is triggered by their cicd pipeline, that causes them to constantly hit the API and wreaks havoc on their rate limits.
We would like to implement integration tests as part of our CI, but I can see how rate limits would be a concern.
As an example my coworker gave me: Using restricted API keys we are not able to make certain calls or portions of responses are missing due to permissions, impact being things will work in unit tests as we don't use the api keys and just won't work at all in prod
Is there a way to test for a case like this currently?
I would think that would be encountered and handled during your development cycles.
Yes, we can test manually against the API during development, but we want to ensure things don't break on us after the fact, or as an unintended consequence of changes we make after the initial implementation
The sort of thing integration tests in a CI pipeline would be useful for
Hi, I'm taking over and catching.
As my teammate suggested you would want to mock our API, however, since you have 25 read operations and 25 write operations in Test mode, you can make API calls to test these.
You just need to ensure that you do not exceed these rate limits, otherwise, hitting the API under the limits whould work fine.
Ok! My question then, if hitting the API for real is possible (within rate limits) would be how to "clean up" the environment after a CI run. It seems there is no way to "programmatically" clear out the data from test mode https://stackoverflow.com/questions/34429622/how-can-i-clear-test-data-in-stripe-via-the-api
Yes, in test mode using your Test API key, you could.
Also, you can delete test data: https://dashboard.stripe.com/test/developers
Can you try this?
We know we can delete test data via the UI. What I am asking, though, is if it is possible to wipe all test mode data from an account via the CLI or API. This would be needed to clean up the environment after, say, running integration tests via the CLI
If our use case of hitting the API in integration tests in a CI pipeline is "technically" possible, but heavily against the best practices you guys recommend, please let us know
That funcitonality is only possible via the Dashboard.
Hi, I am with @tranquil ingot , What we are looking for specifically is how to clean up the test data in test mode (or sandboxes)? We would like the CI to create/cleanup what is needed after itself without human itervention.
Rate limits are not a concern it is easy enough to throttle the client on our end.
You can hit the API in test mode to test, that is why we have a rate limit.
Ah, that is not possible. That function is limited to the Dashboard.
Awesome, thanks for confirming!
Happy to help!
As a follow up question, would it be possible to use sandboxes (https://docs.stripe.com/sandboxes) for our integration tests? Your docs aren't clear whether we can create and delete sandboxes via the CLI or API.
That is a Beta feature, and you would want to talk to our support team instead at https://support.stripe.com/contact.
Ok, thanks!
Do you guys know when the Sandboxes feature will be out of Beta? It seems that it could be well suited for our testing needs in the future.
I do not