Package com.stripe

Class StripeClient.StripeClientBuilder

java.lang.Object
com.stripe.StripeClient.StripeClientBuilder
Enclosing class:
StripeClient

public static final class StripeClient.StripeClientBuilder extends Object
  • Constructor Details

    • StripeClientBuilder

      public StripeClientBuilder()
      Constructs a request options builder with the global parameters (API key and client ID) as default values.
  • Method Details

    • getAuthenticator

      public Authenticator getAuthenticator()
    • setAuthenticator

      public StripeClient.StripeClientBuilder setAuthenticator(Authenticator authenticator)
      Sets the authenticator used to authorize requests. Use this for custom authentication strategies. For standard API key authentication, prefer setApiKey(String).

      This shares a backing field with setApiKey(String) — calling one overwrites the other.

      Parameters:
      authenticator - the authenticator to use
    • setApiKey

      public StripeClient.StripeClientBuilder setApiKey(String apiKey)
      Sets the API key for bearer token authentication. This is a convenience method equivalent to calling setAuthenticator(new BearerTokenAuthenticator(apiKey)).

      This shares a backing field with setAuthenticator(Authenticator) — calling one overwrites the other.

      Parameters:
      apiKey - the API key; if null, clears the authenticator
    • clearApiKey

      public StripeClient.StripeClientBuilder clearApiKey()
    • getClientId

      public String getClientId()
    • setClientId

      public StripeClient.StripeClientBuilder setClientId(String clientId)
      Set the client id, used for OAuth with Stripe Connect.
      Parameters:
      clientId - client ID
    • getConnectTimeout

      public int getConnectTimeout()
    • setConnectTimeout

      public StripeClient.StripeClientBuilder setConnectTimeout(int timeout)
      Sets the timeout value that will be used for making new connections to the Stripe API (in milliseconds).
      Parameters:
      timeout - timeout value in milliseconds
    • getReadTimeout

      public int getReadTimeout()
    • setReadTimeout

      public StripeClient.StripeClientBuilder setReadTimeout(int timeout)
      Sets the timeout value that will be used when reading data from an established connection to the Stripe API (in milliseconds).

      Note that this value should be set conservatively because some API requests can take time and a short timeout increases the likelihood of causing a problem in the backend.

      Parameters:
      timeout - timeout value in milliseconds
    • getMaxNetworkRetries

      public int getMaxNetworkRetries()
    • setMaxNetworkRetries

      public StripeClient.StripeClientBuilder setMaxNetworkRetries(int maxNetworkRetries)
      Sets the maximum number of times the request will be retried in the event of a failure.
      Parameters:
      maxNetworkRetries - the number of times to retry the request
    • getConnectionProxy

      public Proxy getConnectionProxy()
    • setConnectionProxy

      public StripeClient.StripeClientBuilder setConnectionProxy(Proxy connectionProxy)
      Set proxy to tunnel all Stripe connections.
      Parameters:
      connectionProxy - proxy host and port setting
    • getProxyCredential

      public PasswordAuthentication getProxyCredential()
    • setProxyCredential

      public StripeClient.StripeClientBuilder setProxyCredential(PasswordAuthentication proxyCredential)
      Provide credential for proxy authorization if required.
      Parameters:
      proxyCredential - proxy required userName and password
    • setApiBase

      public StripeClient.StripeClientBuilder setApiBase(String address)
      Set the base URL for the Stripe API. By default this is "https://api.stripe.com".

      This only affects requests made with a BaseAddress of API. Use setFilesBase(java.lang.String), setConnectBase(java.lang.String) or setMeterEventsBase(java.lang.String) to interpect requests with other bases.

    • getApiBase

      public String getApiBase()
    • setFilesBase

      public StripeClient.StripeClientBuilder setFilesBase(String address)
      Set the base URL for the Stripe Files API. By default this is "https://files.stripe.com".

      This only affects requests made with a BaseAddress of FILES.

    • getFilesBase

      public String getFilesBase()
    • setConnectBase

      public StripeClient.StripeClientBuilder setConnectBase(String address)
      Set the base URL for the Stripe Connect API. By default this is "https://connect.stripe.com".

      This only affects requests made with a BaseAddress of CONNECT.

    • getConnectBase

      public String getConnectBase()
    • setMeterEventsBase

      public StripeClient.StripeClientBuilder setMeterEventsBase(String address)
      Set the base URL for the Stripe Meter Events API. By default this is "https://events.stripe.com".

      This only affects requests made with a BaseAddress of EVENTMES.

    • getMeterEventsBase

      public String getMeterEventsBase()
    • setStripeAccount

      public StripeClient.StripeClientBuilder setStripeAccount(String account)
    • getStripeAccount

      public String getStripeAccount()
    • setStripeContext

      public StripeClient.StripeClientBuilder setStripeContext(String context)
    • setStripeContext

      public StripeClient.StripeClientBuilder setStripeContext(StripeContext context)
    • getStripeContext

      public String getStripeContext()
    • setHttpClient

      public StripeClient.StripeClientBuilder setHttpClient(HttpClient httpClient)
      Sets the HTTP client to use for making requests to the Stripe API. If not set, a default HttpURLConnectionClient will be created.

      This is useful for providing a custom HTTP client implementation, e.g. for testing or for using a different HTTP library.

      Parameters:
      httpClient - the HTTP client to use
    • build

      public StripeClient build()
      Constructs a StripeResponseGetterOptions with the specified values.