#hugues9308
1 messages · Page 1 of 1 (latest)
Hello! We'll be with you shortly. Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.
- hugues9308, 17 hours ago, 13 messages
- hugues9308, 1 day ago, 25 messages
- hugues9308, 1 day ago, 6 messages
Hi there 👋 I've not tried to point our SDK to stripe-mock directly before, and am not entirely certain that is possibe. If it is though, I see that there is a variable here that seems to contain the base URL for our API:
https://github.com/stripe/stripe-java/blob/fe60750ed3e284311056d4ad9912e1a294b6f0ff/src/main/java/com/stripe/Stripe.java#L14
I'd suggest trying to adjust that, and see if it does what you're hoping.
Am I right assuming that the stripe-java API uses stripe-mock internally for testing the API?
I'm not sure I'm grasping the question. Like you're wondering how we test stripe-java as we're developing it?
Yes, here's the link: https://github.com/stripe/stripe-mock
Gotcha, I'm not exactly sure how our teams do their internal testing, but I don't think they use stripe-mock. Maybe something similar though.
Is there someone who knows better about this matter?
Sorry, we're not going to be going into detail about how we test things internally in this thread. Did adjusting the URL accomplish what you were hoping?
All I'm interested is finding a way to test our application with a mock of stripe and stripe-mock seemed a good solution. I'm not really interested on how you do your tests internally. I was hoping that you could refer me to a document showing how to do stripe-java API calls and have them processed by stripe-mock. All I got was the stripe-mock's README and, although it says that it can be done, it doesn't explain how to do it.
The variable I provided a permalink to seems to be the variable that contains the base URL that stripe-java uses to know where to make API requests to. My thinking was that once you stood up stripe-mock and had an address for it, that you could update the LIVE_API_BASE variable to point to your instance of stripe-mock.
Though, I just remembered that stripe-mock is stateless, so sending all of your requests to it may lead to unexpected scenarios.
I know that stripe-mock is quite limited. At least, I expect it to confirm the validity of the requests made to the stripe-java API. As for Stipe::LIVE_API_BASE , can you refer me to any example overriding its value? I think that what you're suggesting makes sense. It's just that I'm not sure if it's the preferred way of redirecting Stripe requests.
Ah, it looks like there is a way to override that on what seems to be a per-request basis, via setBaseUrl
https://stripe.dev/stripe-java/com/stripe/net/RequestOptions.RequestOptionsBuilder.html#setBaseUrl(java.lang.String)
It also looks like you can set it in your overall stripe-java library settings. It looks like this is a publicly string directly on the Stripe object, like the apiKey
https://git.corp.stripe.com/stripe-private-oss-forks/stripe-java/blob/2eb4a9c0/src/main/java/com/stripe/Stripe.java#L14
So I think you can just do
Stripe.apiKey = "sk_test_1234";
Stripe.apiBase = "localhost://4242"