stripity_stripe v2.7.0 Stripe View Source

A HTTP client for Stripe.



You need to set your API key in your application configuration. Typically this is done in config/config.exs or a similar file. For example:

config :stripity_stripe, api_key: "sk_test_abc123456789qwerty"

You can also utilize System.get_env/1 to retrieve the API key from an environment variable, but remember that this can cause issues if you use a release tool like exrm or Distillery.

config :stripity_stripe, api_key: System.get_env("STRIPE_API_KEY")

Shared Options

Almost all of the requests that can be sent accept the following options:

HTTP Connection Pool

Stripity Stripe is set up to use an HTTP connection pool by default. This means that it will reuse already opened HTTP connections in order to minimize the overhead of establishing connections. The pool is directly supervised by Stripity Stripe. Two configuration options are available to tune how this pool works: :timeout and :max_connections.

:timeout is the amount of time that a connection will be allowed to remain open but idle (no data passing over it) before it is closed and cleaned up. This defaults to 5 seconds.

:max_connections is the maximum number of connections that can be open at any time. This defaults to 10.

Both these settings are located under the :pool_options key in your application configuration:

config :stripity_stripe, :pool_options,
  timeout: 5_000,
  max_connections: 10

If you prefer, you can also turn pooling off completely using the :use_connection_pool setting:

config :stripity_stripe, use_connection_pool: false

Link to this section Summary


Callback for the application

Link to this section Types

Link to this type

date_query() View Source
date_query() :: %{
  optional(:gt) => timestamp(),
  optional(:gte) => timestamp(),
  optional(:lt) => timestamp(),
  optional(:lte) => timestamp()

Link to this type

integer_query() View Source
integer_query() :: %{
  optional(:gt) => integer(),
  optional(:gte) => integer(),
  optional(:lt) => integer(),
  optional(:lte) => integer()

Link to this type

timestamp() View Source
timestamp() :: pos_integer()

Link to this section Functions

Link to this function

start(start_type, args) View Source
start(Application.start_type(), any()) ::
  {:error, any()} | {:ok, pid()} | {:ok, pid(), any()}

Callback for the application

Start the supervision tree including the supervised HTTP connection pool (if it's being used) when the VM loads the application pool.

Note that we are taking advantage of the BEAM application standard in order to start the pool when the application is started. While we do start a supervisor, the supervisor is only to comply with the expectations of the BEAM application standard. It is not given any children to supervise.