stripe/stripe-java

v23 StripeClient builder doesn't use global defaults for baseUrls

stevenhurd opened this issue · 1 comments

Describe the bug

Not sure if this is intentional of not but when I use the Stripe client builder as described in the Migration Guide and just provide an API key, it doesn't seem to set default baseUrls for the Stripe endpoints and I get an exception like:

no protocol: null/v1/accounts
java.net.MalformedURLException: no protocol: null/v1/accounts
	at java.base/java.net.URL.<init>(URL.java:674)
	at java.base/java.net.URL.<init>(URL.java:569)
	at java.base/java.net.URL.<init>(URL.java:516)
	at com.stripe.net.StripeRequest.buildURL(StripeRequest.java:112)
	at com.stripe.net.StripeRequest.<init>(StripeRequest.java:73)
	at com.stripe.net.LiveStripeResponseGetter.request(LiveStripeResponseGetter.java:59)

Using prior global configuration (i.e. Stripe.java), the default live baseUrls were just standard and there was no need to specify them in client code.

Instead, I need to declare my Stripe client like:

StripeClient.builder()
    .setApiBase(Stripe.LIVE_API_BASE)
    .setApiKey(stripeApiKey)
    .build()

To Reproduce

  1. Build a client with just an API key and no other configuration
  2. Attempt invoke the Stripe APIs

Expected behavior

The new StripeClient builder should inherit reasonable defaults for things like API baseUrls rather than forcing clients to provide everything.

Code snippets

No response

OS

macOs

Java version

Java 17

stripe-java version

v23.1.0

API version

2023-08-16

Additional context

No response

The fix is released in 23.1.1