Skip to content

Commit

Permalink
Revert stripity-stripe => stripe-elixir (#774)
Browse files Browse the repository at this point in the history
  • Loading branch information
snewcomer authored Dec 13, 2022
1 parent 2ae9378 commit 217c9c1
Show file tree
Hide file tree
Showing 10 changed files with 45 additions and 45 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ erl_crash.dump
*.ez

# Ignore package tarball (built via "mix hex.build").
stripe_elixir-*.tar
stripity_stripe-*.tar

# Temporary files, for example, from tests.
/tmp/
Expand Down
40 changes: 20 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ An Elixir library for working with [Stripe](https://stripe.com/).

Below is a list of which Stripe API version recent releases of Stripe Elixir. It only indicates the API version being called, not necessarily its compatibility. See the [Stripe API Upgrades page](https://stripe.com/docs/upgrades) for more details.

Starting with stripe_elixir version 2.5.0, you can specify the Stripe API Version to use for a specific request by including the `:api_version` option. Note that while this will use a specific Stripe API Version to make the request, the library will still expect a response matching its corresponding default Stripe API Version. See the [Shared Options documentation](https://hexdocs.pm/stripity_stripe/2.17.2/Stripe.html#module-shared-options) for more details.
Starting with stripity_stripe version 2.5.0, you can specify the Stripe API Version to use for a specific request by including the `:api_version` option. Note that while this will use a specific Stripe API Version to make the request, the library will still expect a response matching its corresponding default Stripe API Version. See the [Shared Options documentation](https://hexdocs.pm/stripity_stripe/2.17.2/Stripe.html#module-shared-options) for more details.

| `:stripe_elixir` | Stripe API Version |
| `:stripity_stripe` | Stripe API Version |
| ------------------ | ------------------ |
| `2.0.x` | `2018-02-28` |
| `2.1.0 - 2.2.0` | `2018-05-21` |
Expand All @@ -32,13 +32,13 @@ Starting with stripe_elixir version 2.5.0, you can specify the Stripe API Versio
Install the dependency by version:

```elixir
{:stripe_elixir, "~> 2.0"}
{:stripity_stripe, "~> 2.0"}
```

Or by commit reference:

```elixir
{:stripe_elixir, git: "https://github.com/beam-community/stripe-elixir", ref: "8c091d4278d29a917bacef7bb2f0606317fcc025"}
{:stripity_stripe, git: "https://github.com/code-corps/stripity_stripe", ref: "8c091d4278d29a917bacef7bb2f0606317fcc025"}
```

Next, add to your applications:
Expand All @@ -47,7 +47,7 @@ _Not necessary if using elixir >= 1.4_

```elixir
defp application do
[applications: [:stripe_elixir]]
[applications: [:stripity_stripe]]
end
```

Expand All @@ -58,39 +58,39 @@ To make API calls, it is necessary to configure your Stripe secret key.
```elixir
import Config

config :stripe_elixir, api_key: System.get_env("STRIPE_SECRET")
config :stripity_stripe, api_key: System.get_env("STRIPE_SECRET")
# OR
config :stripe_elixir, api_key: "YOUR SECRET KEY"
config :stripity_stripe, api_key: "YOUR SECRET KEY"
```

It's possible to use a function or a tuple to resolve the secret:

```elixir
config :stripe_elixir, api_key: {MyApp.Secrets, :stripe_secret, []}
config :stripity_stripe, api_key: {MyApp.Secrets, :stripe_secret, []}
# OR
config :stripe_elixir, api_key: fn -> System.get_env("STRIPE_SECRET") end
config :stripity_stripe, api_key: fn -> System.get_env("STRIPE_SECRET") end
```

Moreover, if you are using Poison instead of Jason, you can configure the library to use Poison like so:

```elixir
config :stripe_elixir, json_library: Poison
config :stripity_stripe, json_library: Poison
```

### Timeout

To set timeouts, pass opts for the http client. The default one is Hackney.

```elixir
config :stripe_elixir, hackney_opts: [{:connect_timeout, 1000}, {:recv_timeout, 5000}]
config :stripity_stripe, hackney_opts: [{:connect_timeout, 1000}, {:recv_timeout, 5000}]
```

### Request Retries

To set retries, you can pass the number of attempts and range of backoff (time between attempting the request again) in milliseconds.

```elixir
config :stripe_elixir, :retries, [max_attempts: 3, base_backoff: 500, max_backoff: 2_000]
config :stripity_stripe, :retries, [max_attempts: 3, base_backoff: 500, max_backoff: 2_000]
```

## Examples
Expand Down Expand Up @@ -164,7 +164,7 @@ Now you can charge the customer using a `PaymentIntent` from [Stripe](https://st

## Note: Object Expansion

Some Stripe API endpoints support returning related objects via the object expansion query parameter. To take advantage of this feature, stripe_elixir accepts
Some Stripe API endpoints support returning related objects via the object expansion query parameter. To take advantage of this feature, stripity_stripe accepts
a list of strings to be passed into `opts` under the `:expand` key indicating which objects should be expanded.

For example, calling `Charge.retrieve("ch_123")` would return a charge without expanding any objects.
Expand Down Expand Up @@ -231,7 +231,7 @@ To configure your test environment to use the local stripe-mock server, you may
need to set the `api_base_url` field in your config:

```
config :stripe_elixir,
config :stripity_stripe,
api_key: "sk_test_thisisaboguskey",
api_base_url: "http://localhost:12111/v1/"
```
Expand All @@ -250,14 +250,14 @@ Works with API version 2015-10-16
Install the dependency:

```elixir
{:stripe_elixir, "~> 1.6"}
{:stripity_stripe, "~> 1.6"}
```

Next, add to your applications:

```elixir
defp application do
[applications: [:stripe_elixir]]
[applications: [:stripity_stripe]]
end
```

Expand All @@ -268,8 +268,8 @@ To make API calls, it is necessary to configure your Stripe secret key (and opti
```elixir
import Config

config :stripe_elixir, secret_key: "YOUR SECRET KEY"
config :stripe_elixir, platform_client_id: "YOUR CONNECT PLATFORM CLIENT ID"
config :stripity_stripe, secret_key: "YOUR SECRET KEY"
config :stripity_stripe, platform_client_id: "YOUR CONNECT PLATFORM CLIENT ID"
```

## Testing
Expand Down Expand Up @@ -325,7 +325,7 @@ Stripe Connect allows you to provide your customers with an easy onboarding to t
First, you need to register your platform on Stripe Connect to obtain a `client_id`. In your account settings, there's a "Connect" tab, select it. Then fill the information to activate your connect platform settings. The select he `client_id` (notice there's one for dev and one for prod), stash this `client_id` in the config file under

```elixir
config :stripe_elixir, platform_client_id: "ac_???"
config :stripity_stripe, platform_client_id: "ac_???"
```

or in an env var named `STRIPE_PLATFORM_CLIENT_ID`.
Expand Down Expand Up @@ -412,4 +412,4 @@ As I began digging things up with these other libraries it became rather apparen

## Update

As of October 18th, Rob has graciously handed over the reins to the teams at [Code Corps](https://www.codecorps.org/) and [Strumber](https://strumber.com/). To address the concerns Rob mentioned above and update the high level api to work with all of the Stripe API Endpoints, they have since worked to release stripe_elixir 2.0, which is now the actively developed line of releases.
As of October 18th, Rob has graciously handed over the reins to the teams at [Code Corps](https://www.codecorps.org/) and [Strumber](https://strumber.com/). To address the concerns Rob mentioned above and update the high level api to work with all of the Stripe API Endpoints, they have since worked to release stripity_stripe 2.0, which is now the actively developed line of releases.
8 changes: 4 additions & 4 deletions lib/stripe.ex
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ defmodule Stripe do
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 :stripe_elixir, api_key: "sk_test_abc123456789qwerty"
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 :stripe_elixir, api_key: System.get_env("STRIPE_API_KEY")
config :stripity_stripe, api_key: System.get_env("STRIPE_API_KEY")
### Shared Options
Expand Down Expand Up @@ -52,14 +52,14 @@ defmodule Stripe do
Both these settings are located under the `:pool_options` key in
your application configuration:
config :stripe_elixir, :pool_options,
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 :stripe_elixir, use_connection_pool: false
config :stripity_stripe, use_connection_pool: false
"""
use Application
Expand Down
4 changes: 2 additions & 2 deletions lib/stripe/api.ex
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ defmodule Stripe.API do

@doc """
In config.exs your implicit or explicit configuration is:
config :stripe_elixir,
config :stripity_stripe,
json_library: Poison # defaults to Jason but can be configured to Poison
"""
@spec json_library() :: module
Expand Down Expand Up @@ -431,7 +431,7 @@ defmodule Stripe.API do
@spec retry_response?(http_success | http_failure) :: boolean
# 409 conflict
defp retry_response?({:error, 409, _headers, _body}), do: true
# https://github.com/beam-community/stripe_elixir/issues/686
# https://github.com/beam-community/stripity_stripe/issues/686
defp retry_response?({:error, 429, _headers, _body}), do: true
# Destination refused the connection, the connection was reset, or a
# variety of other connection failures. This could occur from a single
Expand Down
2 changes: 1 addition & 1 deletion lib/stripe/config.ex
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ defmodule Stripe.Config do
def resolve(key, default \\ nil)

def resolve(key, default) when is_atom(key) do
Application.get_env(:stripe_elixir, key, default)
Application.get_env(:stripity_stripe, key, default)
|> expand_value()
end

Expand Down
6 changes: 3 additions & 3 deletions mix.exs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
defmodule Stripe.Mixfile do
use Mix.Project

@source_url "https://github.com/beam-community/stripe-elixir"
@source_url "https://github.com/code-corps/stripity_stripe"
@version "2.17.2"

def project do
[
app: :stripe_elixir,
app: :stripity_stripe,
version: @version,
elixir: "~> 1.10",
deps: deps(),
Expand All @@ -21,7 +21,7 @@ defmodule Stripe.Mixfile do
],
dialyzer: [
plt_add_apps: [:mix],
plt_file: {:no_warn, "priv/plts/stripe_elixir.plt"}
plt_file: {:no_warn, "priv/plts/stripity_stripe.plt"}
],
test_coverage: [tool: ExCoveralls]
]
Expand Down
6 changes: 3 additions & 3 deletions test/stripe/api_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ defmodule Stripe.APITest do
end
end

Application.put_env(:stripe_elixir, :http_module, HackneyMock)
Application.put_env(:stripity_stripe, :http_module, HackneyMock)

{:ok, body} = Stripe.API.oauth_request(:post, "deauthorize", %{})
assert body["Authorization"] == "Bearer sk_test_123"
Expand Down Expand Up @@ -141,13 +141,13 @@ defmodule Stripe.APITest do
end
end

Application.put_env(:stripe_elixir, :http_module, HackneyMock)
Application.put_env(:stripity_stripe, :http_module, HackneyMock)

{:ok, request_opts} = Stripe.API.request(%{}, :get, "/", %{}, [])
refute Map.has_key?(request_opts, "connect_timeout")
refute Map.has_key?(request_opts, "recv_timeout")

Application.put_env(:stripe_elixir, :hackney_opts, [
Application.put_env(:stripity_stripe, :hackney_opts, [
{:connect_timeout, 1000},
{:recv_timeout, 5000}
])
Expand Down
10 changes: 5 additions & 5 deletions test/stripe/config_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@ defmodule Stripe.ConfigTest do
end

test "returns the requested configuration value" do
Application.put_env(:stripe_elixir, :__test, "test-test")
Application.put_env(:stripity_stripe, :__test, "test-test")
assert(Stripe.Config.resolve(:__test) == "test-test")
end

test "evaluates functions" do
Application.put_env(:stripe_elixir, :__test, fn -> "test-test" end)
Application.put_env(:stripity_stripe, :__test, fn -> "test-test" end)
assert(Stripe.Config.resolve(:__test) == "test-test")
end

test "applies tuples" do
Application.put_env(
:stripe_elixir,
:stripity_stripe,
:__test,
{ValueExpansionTestModule, :value, []}
)
Expand All @@ -29,7 +29,7 @@ defmodule Stripe.ConfigTest do

test "if no value exists for the given key it uses the default value" do
Application.put_env(
:stripe_elixir,
:stripity_stripe,
:__test,
{ValueExpansionTestModule, :value, []}
)
Expand All @@ -39,7 +39,7 @@ defmodule Stripe.ConfigTest do

test "raises if the key isn't an atom" do
Application.put_env(
:stripe_elixir,
:stripity_stripe,
:__test,
{ValueExpansionTestModule, :value, []}
)
Expand Down
4 changes: 2 additions & 2 deletions test/support/stripe_case.ex
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ defmodule Stripe.StripeCase do
end

def stripe_base_url() do
Application.get_env(:stripe_elixir, :api_base_url)
Application.get_env(:stripity_stripe, :api_base_url)
end

defp assert_stripe_request_headers(nil, _), do: nil
Expand Down Expand Up @@ -82,7 +82,7 @@ defmodule Stripe.StripeCase do
stripe_base_url: 0
]

Application.put_env(:stripe_elixir, :http_module, HackneyMock)
Application.put_env(:stripity_stripe, :http_module, HackneyMock)
end
end
end
8 changes: 4 additions & 4 deletions test/test_helper.exs
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ end
api_base_url = System.get_env("STRIPE_API_BASE_URL") || "http://localhost:12111/v1/"
api_upload_url = System.get_env("STRIPE_API_UPLOAD_URL") || "http://localhost:12112/v1/"

Application.put_env(:stripe_elixir, :api_base_url, api_base_url)
Application.put_env(:stripe_elixir, :api_upload_url, api_upload_url)
Application.put_env(:stripe_elixir, :api_key, "sk_test_123")
Application.put_env(:stripe_elixir, :log_level, :debug)
Application.put_env(:stripity_stripe, :api_base_url, api_base_url)
Application.put_env(:stripity_stripe, :api_upload_url, api_upload_url)
Application.put_env(:stripity_stripe, :api_key, "sk_test_123")
Application.put_env(:stripity_stripe, :log_level, :debug)

Mox.defmock(Stripe.Connect.OAuthMock, for: Stripe.Connect.OAuth)
Mox.defmock(Stripe.APIMock, for: Stripe.API)
Expand Down

0 comments on commit 217c9c1

Please sign in to comment.