Skip to content

Commit

Permalink
Merge pull request #1 from code-corps/master
Browse files Browse the repository at this point in the history
Sync with Source
  • Loading branch information
jcartwright authored Jul 30, 2019
2 parents 7c54802 + ced9aba commit a65097d
Show file tree
Hide file tree
Showing 54 changed files with 3,194 additions and 217 deletions.
6 changes: 4 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
language: elixir
dist: trusty
elixir:
- 1.5
- 1.6
- 1.7
- 1.8
otp_release:
Expand Down Expand Up @@ -30,6 +28,10 @@ before_install:
fi
- export PATH=$PATH:$PWD/stripe-mock/stripe-mock_${STRIPE_MOCK_VERSION}/
script:
- |
if [ "$TRAVIS_ELIXIR_VERSION" == "1.8" ]; then
mix format --dry-run --check-formatted;
fi
- mix coveralls.travis
- MIX_ENV=dev mix dialyzer --halt-exit-status
after_script:
Expand Down
45 changes: 45 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,50 @@
# Latest

## 2.4.0

- [Issues/add missing fields](https://github.com/code-corps/stripity_stripe/pull/511)
- [Support upcoming invoices with subscription only](https://github.com/code-corps/stripity_stripe/pull/515)
- [Warn when unknown objects are processed](https://github.com/code-corps/stripity_stripe/pull/514)
- [Add missing invoice endpoints](https://github.com/code-corps/stripity_stripe/pull/513)
- [Add support for sending invoices](https://github.com/code-corps/stripity_stripe/pull/510)
- [Update Stripe version](https://github.com/code-corps/stripity_stripe/pull/483)
- [Use Jason over Poison](https://github.com/code-corps/stripity_stripe/pull/509)
- [Set minimum elixir version to 1.7](https://github.com/code-corps/stripity_stripe/pull/504)

## 2.3.0

- [Add support for Subscription Schedules](https://github.com/code-corps/stripity_stripe/pull/480)
- [Add Stripe Issuing](https://github.com/code-corps/stripity_stripe/pull/493)
- [Add CreditNote api calls](https://github.com/code-corps/stripity_stripe/pull/492)
- [Add tax_rate struct and api calls](https://github.com/code-corps/stripity_stripe/pull/491)
- [Format mix.exs to pass CI](https://github.com/code-corps/stripity_stripe/pull/498)
- [Reorganize docs](https://github.com/code-corps/stripity_stripe/pull/496)
- [Add PaymentMethods module, with struct, list/2, attach/2, detach/2](https://github.com/code-corps/stripity_stripe/pull/495)

## 2.2.3

- [Configurable json serializer - You can now use Jason instead of Poison](https://github.com/code-corps/stripity_stripe/pull/446)
- [Support for voiding invoices](https://github.com/code-corps/stripity_stripe/pull/444)
- [Use singular time units in System.system_time/1](https://github.com/code-corps/stripity_stripe/pull/450)
- [Expanded configuration options](https://github.com/code-corps/stripity_stripe/pull/447)
- [Add invoice settings to customer/invoice objects](https://github.com/code-corps/stripity_stripe/pull/451)
- [Upgrade to 2018-11-08 Stripe API](https://github.com/code-corps/stripity_stripe/pull/439)
- [Fixed bug in `Usage.retrieve`](https://github.com/code-corps/stripity_stripe/pull/433)
- [Add elixir 1.8 to test matrix](https://github.com/code-corps/stripity_stripe/pull/449)
- [Add authorization header api key to deauthorization endpoint]((https://github.com/code-corps/stripity_stripe/pull/465)
- [Add support for idempotent post requests](https://github.com/code-corps/stripity_stripe/pull/461)
- [Support new Checkout flow](https://github.com/code-corps/stripity_stripe/pull/466)
- [Add `receipt_url` to the return Charge data](https://github.com/code-corps/stripity_stripe/pull/467)
- [Fixed some bugs in `Review` struct fields](https://github.com/code-corps/stripity_stripe/pull/468)
- [Add basic support for payment intents](https://github.com/code-corps/stripity_stripe/pull/470)
- [Make `client_secret` optional](https://github.com/code-corps/stripity_stripe/pull/473)
- [Update hackney requirement to 1.15](https://github.com/code-corps/stripity_stripe/pull/475)
- [Upgrade to ex doc 0.20](https://github.com/code-corps/stripity_stripe/pull/486)
- [Upgrade stripe mock to 0.55](https://github.com/code-corps/stripity_stripe/pull/485)
- [Remove unused Bypass dependency](https://github.com/code-corps/stripity_stripe/pull/88)
- [Implement `assert_stripe_requested/3` test helper](https://github.com/code-corps/stripity_stripe/pull/487)
- Misc documentation improvements

## 2.2.2

- [Upgrade stripe-mock 0.38](https://github.com/code-corps/stripity_stripe/pull/436)
Expand Down
21 changes: 17 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,16 @@ The old `1.x.x` line of releases has been kept and is being published separately

The actively developed line of releases is `2.x.x` and is contained within the `master` branch. New features are being added to this line of releases, so to develop this library further, create pull requests against the master branch.

Below is a list of which Stripe API version recent releases of Stripity Stripe use. 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.

`:stripity_stripe` | Stripe API Version
------------ | -------------
`2.0.x` | `2018-02-28`
`2.1.x - 2.2.x` | `2018-05-21`
`master` | `2018-11-08`
`2.1.0 - 2.2.0` | `2018-05-21`
`2.2.2` | `2018-08-23`
`2.2.3 - 2.3.0` | `2018-11-08`
`2.4.0` | `2019-05-16`
`master` | `2019-05-16`

# Documentation

Expand Down Expand Up @@ -74,10 +79,18 @@ config :stripity_stripe, api_key: {MyApp.Secrets, :stripe_secret, []}
config :stripity_stripe, api_key: fn -> System.get_env("STRIPE_SECRET") end
```

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

```ex
config :stripity_stripe, json_library: Poison
```

### Timeout

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

```ex
config :stripity_stripe, json_library: Jason
config :stripity_stripe, hackney_opts: [{:connect_timeout, 1000}, {:recv_timeout, 5000}])
```

## Note: Object Expansion
Expand Down
17 changes: 14 additions & 3 deletions lib/stripe/api.ex
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@ defmodule Stripe.API do
@typep http_failure :: {:error, term}

@pool_name __MODULE__
@api_version "2018-11-08; checkout_sessions_beta=v1"
@api_version "2019-05-16; checkout_sessions_beta=v1"

@doc """
In config.exs your implicit or expicit configuration is:
config :stripity_stripe,
json_library: Jason # defaults to Poison but can be configured to Jason
json_library: Poison # defaults to Jason but can be configured to Poison
"""
@spec json_library() :: module
def json_library() do
Config.resolve(:json_library, Poison)
Config.resolve(:json_library, Jason)
end

def supervisor_children do
Expand Down Expand Up @@ -135,6 +135,15 @@ defmodule Stripe.API do
end
end

@spec add_options_from_config(list) :: list
defp add_options_from_config(opts) do
if is_list(Stripe.Config.resolve(:hackney_opts)) do
opts ++ Stripe.Config.resolve(:hackney_opts)
else
opts
end
end

@doc """
A low level utility function to make a direct request to the Stripe API
Expand Down Expand Up @@ -233,6 +242,7 @@ defmodule Stripe.API do
[]
|> add_default_options()
|> add_pool_option()
|> add_options_from_config()

http_module().request(method, req_url, req_headers, req_body, req_opts)
|> handle_response()
Expand All @@ -255,6 +265,7 @@ defmodule Stripe.API do
opts
|> add_default_options()
|> add_pool_option()
|> add_options_from_config()

http_module().request(method, req_url, req_headers, body, req_opts)
|> handle_response()
Expand Down
Loading

0 comments on commit a65097d

Please sign in to comment.