Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to the upstream v2.10.0 #19

Open
wants to merge 57 commits into
base: jalexander/v2.8.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
3445348
Add missing params to Stripe.Customer.create typespecs (#569)
cblage Jan 11, 2020
52b5111
Stripe API 2019-12-03 Remove deprecated Customer tax_info
kerryjj Feb 14, 2020
8471d24
Add compare to CHANGELOG for 2.8
snewcomer Apr 4, 2020
44609b2
add metadata to checkout session
abeinstein Apr 24, 2020
7af91b5
remove unnecessary test
abeinstein Apr 24, 2020
4784d86
Update README to suggest the latest version
Mar 31, 2020
f3b46be
Corrected mis-placed parens
cgorshing Mar 23, 2020
b391aec
Update README.md
alexfreska May 3, 2020
df8f166
Make subscription_data keys for Checkout optional
michaeljones Apr 23, 2020
c961419
Add new fields in the subscription data API
michaeljones Apr 27, 2020
e551a72
Update invoice.ex
Apr 13, 2020
0722d13
Update invoice.ex
May 6, 2020
a366cc0
Replace `@deprecated` with `Stripe.Util.log_deprecation/1`
sannek May 6, 2020
cce34d6
Add optional `customer` to session create params
simoncocking May 14, 2020
6c783ec
Update various stripe objects with missing fields, remove deprecated …
pwcsquared May 27, 2020
760cc93
Add support for BillingPortal.Session (#604)
moomerman Jun 1, 2020
8f7f687
Added Terminal functionality (#605)
willstumpf Jun 2, 2020
0fd7091
changed params for subscription to accept default payment method (#592)
PabloG6 Jun 2, 2020
25f2e97
Add price to Subscription (#609)
ianko Jun 15, 2020
594e4a8
Allow creating refunds by payment intent or charge. (#610)
markglenn Jun 17, 2020
8e6621e
makes `:previous_attributes` in `Event.event_data` optional (#612)
samm81 Jun 19, 2020
297eff3
Fix multiple Stripe-Version headers when creating ephemeral key (#613)
jayjun Jun 29, 2020
76e57df
VERSION BUMP 2.9.0 (#614)
snewcomer Jun 29, 2020
d7396a2
support extra params for subscription cancellation (#618)
robuye Jul 20, 2020
c58fc5b
Update subscription.ex (#620)
richthedev Aug 24, 2020
2e5ddf1
Add webhook endpoint to core resources (#621)
SteveParrington Aug 24, 2020
6385762
Update link to Stripe docs (#622)
amcvitty Sep 4, 2020
98c0f30
Fix return of the ephemeral key creation (#624)
eduardoscottini Sep 16, 2020
7217e48
Add :metadata to Stripe.Session.create/2 (#615)
dmarkow Sep 16, 2020
541d709
Add payment_method to confirm payment intent (#625)
markglenn Oct 19, 2020
1f3a7fd
Add default_tax_rate to typespecs for Subscription and Invoice (#631)
John-Goff Nov 3, 2020
c8b775e
Add payment_intent to Stripe.Charge.params type (#635)
chazsconi Nov 24, 2020
12bb620
Add quick example of test config for stripe-mock (#637)
dotdotdotpaul Dec 8, 2020
3da3c02
Add promotion_code to Discount (#638)
tomkonidas Dec 11, 2020
a80d10c
Remove duplicate doc tag causing a compile warning (#639)
Dec 18, 2020
bd39a45
Adding endpoint for checkout session line items. (#633)
tylerwray Dec 29, 2020
50f2c13
Fix typespec for Stripe.Invoice.pay/3 (#643)
jonleighton Jan 15, 2021
3e534b9
Add promotion codes (#641)
ascandella Jan 15, 2021
71e6602
Allow passing pause_collection params to Subscription.update (#649)
ascandella Jan 30, 2021
1e4f6e8
Add Country/State to TaxRate (#647)
tomkonidas Jan 30, 2021
151caf3
Add source_type to parameter types for transfers/create (#645)
mcasper Jan 30, 2021
8cdaa00
Support :status param in typespec for Stripe.Invoice.list/2 (#644)
jonleighton Jan 30, 2021
0dbfaa3
Add credit note preview (#648)
antonioleonardo Jan 31, 2021
97a1523
Update typespec for Stripe.Customer (#650)
jsmestad Feb 17, 2021
95adde4
Added applies_to and expansion to Coupon (#653)
connormorrison1 Mar 6, 2021
dcea931
Allow api_version to be set from config (#656)
stoyle Mar 6, 2021
1e71a8e
Oauth integration improvements (#657)
chubarovNick Mar 6, 2021
deea319
Add mode to Session Create Params typespec (#660)
nthock Mar 16, 2021
93bc8be
Remove :customer from typespec in CustomerBalanceTransaction.create (…
ascandella May 10, 2021
67022bc
Add Account Capabilities (#667)
dhl1337 May 11, 2021
9a68614
fix(deprecation): :crypto.hmac -> :crypto.mac, Bitwise.^^^ -> Bitwise…
seantanly May 24, 2021
52b87e1
updates from upstream
jalexander Nov 20, 2024
4453123
Merge branch 'jalexander/v2.8.0' into jalexander/v2.10.0
jalexander Nov 21, 2024
d347261
fix issue in customer
jalexander Nov 21, 2024
74dad0c
add properties back to customer
jalexander Nov 21, 2024
710d58b
updates after testing
jalexander Nov 21, 2024
2ffdec7
updates after testing
jalexander Nov 21, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ tags
# elixir LS files

/.elixir_ls
/.devcontainer
# IntelliJ IDEA files

/.idea
*.iml
priv/plts/*
/cover
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ matrix:
sudo: false
env:
global:
- STRIPE_MOCK_VERSION=0.70.0
- STRIPE_MOCK_VERSION=0.95.0
- MIX_ENV=test STRIPE_SECRET_KEY=non_empty_secret_key_string
cache:
directories:
Expand Down
713 changes: 531 additions & 182 deletions CHANGELOG.md

Large diffs are not rendered by default.

17 changes: 13 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Starting with stripity_stripe version 2.5.0, you can specify the Stripe API Vers
Install the dependency by version:

```ex
{:stripity_stripe, "~> 2.0.0"}
{:stripity_stripe, "~> 2.0"}
```

Or by commit reference (still awaiting hex publish rights so this is your best best for now):
Expand Down Expand Up @@ -92,7 +92,7 @@ config :stripity_stripe, json_library: Poison
To set timeouts, pass opts for the http client. The default one is Hackney.

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

### Request Retries
Expand Down Expand Up @@ -127,7 +127,7 @@ stripe.confirmCardSetup(setupIntentId, {
}
})
.then(result => {
const setupIntentId = result.setupIntent.id,
const setupIntentId = result.setupIntent.id
const paymentMethodId = result.setupIntent.payment_method

// send the paymentMethodId and optionally (if needed) the setupIntentId
Expand All @@ -150,7 +150,7 @@ new_customer = %{
email: email,
}

{:ok, stripe_customer} = Stripe.Customer.create(customer)
{:ok, stripe_customer} = Stripe.Customer.create(new_customer)
```

Attach the payment method to the customer.
Expand Down Expand Up @@ -215,6 +215,15 @@ To run the tests you'll need to install [`stripe-mock`](https://github.com/strip

Start `stripe-mock` before running the tests with `mix test`.

To configure your test environment to use the local stripe-mock server, you'll
need to set the `api_base_url` field in your config:

```
config :stripity_stripe,
api_key: "sk_test_thisisaboguskey",
api_base_url: "http://localhost:12111/v1/"
```

# Documentation for 1.x.x

<details><summary>Click to expand</summary>
Expand Down
8 changes: 7 additions & 1 deletion lib/stripe/api.ex
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ defmodule Stripe.API do
Config.resolve(:api_key, "")
end

@spec get_api_version() :: String.t()
defp get_api_version() do
Config.resolve(:api_version, @api_version)
end

@spec use_pool?() :: boolean
defp use_pool?() do
Config.resolve(:use_connection_pool)
Expand Down Expand Up @@ -178,7 +183,8 @@ defmodule Stripe.API do
end

@spec add_api_version(headers, String.t() | nil) :: headers
defp add_api_version(existing_headers, nil), do: add_api_version(existing_headers, @api_version)
defp add_api_version(existing_headers, nil),
do: add_api_version(existing_headers, get_api_version())

defp add_api_version(existing_headers, api_version) do
Map.merge(existing_headers, %{
Expand Down
50 changes: 50 additions & 0 deletions lib/stripe/billing_portal/session.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
defmodule Stripe.BillingPortal.Session do
@moduledoc """
Work with Stripe Billing (aka Self-serve) Portal Session objects.

You can:

- Create a session

Stripe API reference: https://stripe.com/docs/api/customer_portal
"""

use Stripe.Entity
import Stripe.Request

@type t :: %__MODULE__{
:id => Stripe.id(),
:object => String.t(),
:created => Stripe.timestamp(),
:customer => Stripe.id() | Stripe.Customer.t(),
:livemode => boolean(),
:return_url => String.t(),
:url => String.t()
}

@type create_params :: %{
:customer => String.t(),
optional(:return_url) => String.t()
}

defstruct [
:id,
:object,
:created,
:customer,
:livemode,
:return_url,
:url
]

@plural_endpoint "billing_portal/sessions"

@spec create(create_params, Stripe.options()) :: {:ok, t} | {:error, Stripe.Error.t()}
def create(params, opts \\ []) do
new_request(opts)
|> put_endpoint(@plural_endpoint)
|> put_params(params)
|> put_method(:post)
|> make_request()
end
end
60 changes: 40 additions & 20 deletions lib/stripe/checkout/session.ex
Original file line number Diff line number Diff line change
Expand Up @@ -47,41 +47,56 @@ defmodule Stripe.Session do

@type subscription_data :: %{
:items => list(item),
:metadata => Stripe.Types.metadata(),
:trial_end => integer(),
:trial_period_days => integer()
optional(:application_fee_percent) => float(),
optional(:coupon) => String.t(),
optional(:default_tax_rates) => list(String.t()),
optional(:metadata) => Stripe.Types.metadata(),
optional(:trial_end) => integer(),
optional(:trial_from_plan) => boolean(),
optional(:trial_period_days) => integer()
}

@type create_params :: %{
:cancel_url => String.t(),
:payment_method_types => list(String.t()),
:success_url => String.t(),
optional(:mode) => String.t(),
optional(:client_reference_id) => String.t(),
optional(:customer) => String.t(),
optional(:customer_email) => String.t(),
optional(:line_items) => list(line_item),
optional(:locale) => String.t(),
optional(:metadata) => Stripe.Types.metadata(),
optional(:payment_intent_data) => payment_intent_data,
optional(:subscription_data) => subscription_data
}

@type t :: %__MODULE__{
:id => Stripe.id(),
:object => String.t(),
:billing_address_collection => String.t(),
:cancel_url => boolean(),
:client_reference_id => String.t(),
:customer => Stripe.id() | Stripe.Customer.t() | nil,
:customer_email => String.t(),
:display_items => list(line_item),
:livemode => boolean(),
:locale => boolean(),
:mode => String.t(),
:payment_intent => Stripe.id() | Stripe.PaymentIntent.t() | nil,
:payment_method_types => list(String.t()),
:setup_intent => Stripe.id() | Stripe.SetupIntent.t() | nil,
:submit_type => String.t(),
:subscription => Stripe.id() | Stripe.Subscription.t() | nil,
:success_url => String.t()
id: Stripe.id(),
object: String.t(),
billing_address_collection: String.t(),
cancel_url: boolean(),
client_reference_id: String.t(),
customer: Stripe.id() | Stripe.Customer.t() | nil,
customer_email: String.t(),
display_items: list(line_item),
livemode: boolean(),
locale: boolean(),
metadata: Stripe.Types.metadata(),
mode: String.t(),
payment_intent: Stripe.id() | Stripe.PaymentIntent.t() | nil,
payment_method_types: list(String.t()),
setup_intent: Stripe.id() | Stripe.SetupIntent.t() | nil,
shipping: %{
address: Stripe.Types.shipping(),
name: String.t()
},
shipping_address_collection: %{
allowed_countries: [String.t()]
},
submit_type: String.t() | nil,
subscription: Stripe.id() | Stripe.Subscription.t() | nil,
success_url: String.t()
}

defstruct [
Expand All @@ -95,10 +110,13 @@ defmodule Stripe.Session do
:display_items,
:livemode,
:locale,
:metadata,
:mode,
:payment_intent,
:payment_method_types,
:setup_intent,
:shipping,
:shipping_address_collection,
:submit_type,
:subscription,
:success_url
Expand All @@ -125,4 +143,6 @@ defmodule Stripe.Session do
|> put_method(:get)
|> make_request()
end

defdelegate list_line_items(id, opts \\ []), to: Stripe.Checkout.Session.LineItems, as: :list
end
42 changes: 42 additions & 0 deletions lib/stripe/checkout/session/line_items.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
defmodule Stripe.Checkout.Session.LineItems do
@moduledoc false

use Stripe.Entity
import Stripe.Request

@type t :: %__MODULE__{
id: Stripe.id(),
object: String.t(),
amount_subtotal: non_neg_integer,
amount_total: non_neg_integer,
currency: String.t(),
description: String.t(),
price: Stripe.Price.t(),
quantity: non_neg_integer
}

defstruct [
:id,
:object,
:amount_subtotal,
:amount_total,
:currency,
:description,
:price,
:quantity
]

@plural_endpoint "checkout/sessions"

@doc """
List line items on a checkout session.
"""
@spec list(Stripe.id(), Stripe.options()) ::
{:ok, Stripe.List.t(t())} | {:error, Stripe.Error.t()}
def list(id, opts \\ []) do
new_request(opts)
|> put_endpoint(@plural_endpoint <> "/#{get_id!(id)}/" <> "line_items")
|> put_method(:get)
|> make_request()
end
end
4 changes: 3 additions & 1 deletion lib/stripe/connect/account.ex
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ defmodule Stripe.Account do

This module does not yet support managed accounts.

Stripe API reference: https://stripe.com/docs/api#account
Stripe API reference: https://stripe.com/docs/api/accounts
"""

use Stripe.Entity
Expand Down Expand Up @@ -144,6 +144,7 @@ defmodule Stripe.Account do
country: String.t(),
created: Stripe.timestamp() | nil,
default_currency: String.t(),
deleted: boolean | nil,
details_submitted: boolean,
email: String.t() | nil,
external_accounts: Stripe.List.t(Stripe.BankAccount.t() | Stripe.Card.t()),
Expand All @@ -167,6 +168,7 @@ defmodule Stripe.Account do
:country,
:created,
:default_currency,
:deleted,
:details_submitted,
:email,
:external_accounts,
Expand Down
4 changes: 2 additions & 2 deletions lib/stripe/connect/account_link.ex
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ defmodule Stripe.AccountLink do
@spec create(params, Stripe.options()) :: {:ok, t} | {:error, Stripe.Error.t()}
when params: %{
:account => Stripe.Account.t() | Stripe.id(),
:failure_url => String.t(),
:success_url => String.t(),
:refresh_url => String.t(),
:return_url => String.t(),
:type => String.t(),
optional(:collect) => String.t()
}
Expand Down
Loading