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 Stripe version #483

Merged
merged 20 commits into from
Jun 7, 2019
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
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: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ before_install:
script:
- |
if [ "$TRAVIS_ELIXIR_VERSION" == "1.8" ]; then
mix format --dry-run --check-formatted;
mix format --dry-run --check-formatted;
fi
- mix coveralls.travis
- MIX_ENV=dev mix dialyzer --halt-exit-status
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ The actively developed line of releases is `2.x.x` and is contained within the `
------------ | -------------
`2.0.x` | `2018-02-28`
`2.1.x - 2.2.x` | `2018-05-21`
`master` | `2018-11-08`
`master` | `2019-03-14`

# Documentation

Expand Down
2 changes: 1 addition & 1 deletion lib/stripe/api.ex
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ 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:
Expand Down
248 changes: 107 additions & 141 deletions lib/stripe/connect/account.ex
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,49 @@ defmodule Stripe.Account do
cvc_failure: boolean
}

@type legal_entity :: %{
additional_owners: [legal_entity_additional_owner] | nil,
address: legal_entity_address,
address_kana: legal_entity_japan_address | nil,
address_kanji: legal_entity_japan_address | nil,
@type requirements :: %{
current_deadline: Stripe.timestamp() | nil,
currently_due: Stripe.List.t(String.t()) | nil,
disabled_reason: String.t() | nil,
eventually_due: Stripe.List.t(String.t()) | nil,
past_due: Stripe.List.t(String.t()) | nil
}

@type settings :: %{
branding: map | nil,
card_payments: map | nil,
dashboard: map | nil,
payments: map | nil,
payouts: map | nil
}

@type company :: %{
address: Stripe.Types.address(),
address_kana: Stripe.Types.japan_address() | nil,
address_kanji: Stripe.Types.japan_address() | nil,
directors_provided: boolean | nil,
name: String.t() | nil,
name_kana: String.t() | nil,
name_kanji: String.t() | nil,
owners_provided: boolean | nil,
phone: String.t() | nil,
tax_id_provided: boolean | nil,
tax_id_registar: String.t(),
vat_id_provided: boolean | nil
}

@type individual :: %{
additional_owners: [individual_additional_owner] | nil,
address: Stripe.Types.address(),
address_kana: Stripe.Types.japan_address() | nil,
address_kanji: Stripe.Types.japan_address() | nil,
business_name: String.t() | nil,
business_name_kana: String.t() | nil,
business_name_kanji: String.t() | nil,
business_tax_id_provided: boolean,
business_vat_id_provided: boolean,
deleted: boolean | nil,
dob: legal_entity_dob,
dob: Stripe.Types.dob(),
first_name: String.t() | nil,
first_name_kana: String.t() | nil,
first_name_kanji: String.t() | nil,
Expand All @@ -40,52 +71,27 @@ defmodule Stripe.Account do
last_name_kana: String.t() | nil,
last_name_kanji: String.t() | nil,
maiden_name: String.t() | nil,
personal_address: legal_entity_address,
personal_address_kana: legal_entity_japan_address | nil,
personal_address_kanji: legal_entity_japan_address | nil,
personal_address: Stripe.Types.address(),
personal_address_kana: Stripe.Types.japan_address() | nil,
personal_address_kanji: Stripe.Types.japan_address() | nil,
personal_id_number_provided: boolean,
phone_number: String.t() | nil,
ssn_last_4_provided: String.t(),
tax_id_registar: String.t(),
type: String.t() | nil,
verification: legal_entity_verification
verification: individual_verification
}

@type legal_entity_additional_owner :: %{
address: legal_entity_address,
dob: legal_entity_dob,
@type individual_additional_owner :: %{
address: Stripe.Types.address(),
dob: Stripe.Types.dob(),
first_name: String.t() | nil,
last_name: String.t() | nil,
maiden_name: String.t() | nil,
verification: legal_entity_verification
verification: individual_verification
}

@type legal_entity_address :: %{
city: String.t() | nil,
country: String.t() | nil,
line1: String.t() | nil,
line2: String.t() | nil,
postal_code: String.t() | nil,
state: String.t() | nil
}

@type legal_entity_dob :: %{
day: 1..31 | nil,
month: 1..12 | nil,
year: pos_integer | nil
}

@type legal_entity_japan_address :: %{
city: String.t() | nil,
country: String.t() | nil,
line1: String.t() | nil,
line2: String.t() | nil,
postal_code: String.t() | nil,
state: String.t() | nil,
town: String.t() | nil
}

@type legal_entity_verification :: %{
@type individual_verification :: %{
details: String.t() | nil,
details_code: String.t() | nil,
document: Stripe.id() | Stripe.FileUpload.t() | nil,
Expand All @@ -104,106 +110,97 @@ defmodule Stripe.Account do
fields_needed: [String.t()]
}

@type business_profile :: %{
mcc: String.t() | nil,
name: String.t() | nil,
product_description: String.t() | nil,
support_address: %{
city: String.t() | nil,
country: String.t() | nil,
line1: String.t() | nil,
line2: String.t() | nil,
postal_code: String.t() | nil,
state: String.t() | nil
},
support_email: String.t() | nil,
support_phone: String.t() | nil,
support_url: String.t() | nil,
url: String.t() | nil
}

@type capabilities :: %{
card_payments: String.t() | nil,
legacy_payments: String.t() | nil,
platform_payments: String.t() | nil
}

@type t :: %__MODULE__{
id: Stripe.id(),
object: String.t(),
business_logo: String.t() | nil,
business_name: String.t() | nil,
business_url: String.t() | nil,
business_profile: business_profile | nil,
business_type: String.t() | nil,
capabilities: capabilities | nil,
charges_enabled: boolean,
created: Stripe.timestamp() | nil,
company: company | nil,
country: String.t(),
debit_negative_balances: boolean,
decline_charge_on: decline_charge_on,
created: Stripe.timestamp() | nil,
default_currency: String.t(),
details_submitted: boolean,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The deleted key seems to be missing here

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where do you see this? (just making sure we are both looking at the same documentation)

https://stripe.com/docs/api/accounts/object
https://raw.githubusercontent.com/stripe/openapi/master/openapi/spec3.yaml

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I ran the tests against the stripe-mock and got this warning
[warn] Extra keys were received but ignored when converting Stripe.Account: [:deleted]

But it seems the deleted is only added to the response in the test for the Account.delete/2 function.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems Account.delete/2 returns the deleted account but that is no more than this in JSON

{
  "id": "acct_1032D82eZvKYlo2C",
  "object": "account",
  "deleted": true
}

We may need a different pattern to deal with deletes of this kind.

display_name: String.t() | nil,
email: String.t() | nil,
external_accounts: Stripe.List.t(Stripe.BankAccount.t() | Stripe.Card.t()),
legal_entity: legal_entity,
individual: individual | nil,
metadata: Stripe.Types.metadata(),
payout_schedule: Stripe.Types.transfer_schedule(),
payout_statement_descriptor: String.t() | nil,
payouts_enabled: boolean,
product_description: String.t() | nil,
statement_descriptor: String.t() | nil,
support_email: String.t() | nil,
support_phone: String.t() | nil,
timezone: String.t() | nil,
tos_acceptance: tos_acceptance,
type: String.t(),
verification: verification
payouts_enabled: boolean | nil,
requirements: requirements | nil,
settings: settings | nil,
tos_acceptance: tos_acceptance | nil,
type: String.t()
}

defstruct [
:id,
:object,
:business_logo,
:business_name,
:business_url,
:business_profile,
:business_type,
:capabilities,
:charges_enabled,
:company,
:country,
:created,
:debit_negative_balances,
:decline_charge_on,
:default_currency,
:deleted,
:details_submitted,
:display_name,
:email,
:external_accounts,
:legal_entity,
:individual,
:metadata,
:payout_schedule,
:payout_statement_descriptor,
:payouts_enabled,
:product_description,
:statement_descriptor,
:support_email,
:support_phone,
:timezone,
:requirements,
:settings,
:tos_acceptance,
:transfers_enabled,
:type,
:verification
:type
]

@singular_endpoint "account"
@plural_endpoint "accounts"

@type create_params :: %{
:type => String.t(),
optional(:account_token) => String.t(),
optional(:business_logo) => String.t(),
optional(:business_name) => String.t(),
optional(:business_primary_color) => String.t(),
optional(:business_url) => String.t(),
optional(:country) => String.t(),
optional(:debit_negative_balances) => boolean,
optional(:decline_charge_on) => decline_charge_on,
optional(:default_currency) => String.t(),
optional(:email) => String.t(),
optional(:external_account) => String.t(),
optional(:legal_entity) => legal_entity,
optional(:metadata) => Stripe.Types.metadata(),
optional(:payout_schedule) => Stripe.Types.transfer_schedule(),
optional(:payout_statement_descriptor) => String.t(),
optional(:product_description) => String.t(),
optional(:statement_descriptor) => String.t(),
optional(:support_email) => String.t(),
optional(:support_phone) => String.t(),
optional(:support_url) => String.t(),
optional(:tos_acceptance) => tos_acceptance
}

@doc """
Create an account.
"""
@spec create(params, Stripe.options()) :: {:ok, t} | {:error, Stripe.Error.t()}
when params: %{
:type => String.t(),
optional(:country) => String.t(),
optional(:account_token) => String.t(),
optional(:business_profile) => business_profile,
optional(:business_type) => String.t(),
optional(:company) => company,
optional(:email) => String.t(),
optional(:type) => String.t()
optional(:external_account) => String.t(),
optional(:individual) => individual,
optional(:metadata) => Stripe.Types.metadata(),
optional(:requested_capabilities) => capabilities,
optional(:settings) => settings,
optional(:tos_acceptance) => tos_acceptance
}
def create(params, opts \\ []) do
new_request(opts)
Expand Down Expand Up @@ -240,55 +237,24 @@ defmodule Stripe.Account do
|> make_request()
end

@type update_params :: %{
optional(:account_token) => String.t(),
optional(:business_logo) => String.t(),
optional(:business_name) => String.t(),
optional(:business_primary_color) => String.t(),
optional(:business_url) => String.t(),
optional(:country) => String.t(),
optional(:debit_negative_balances) => boolean,
optional(:decline_charge_on) => decline_charge_on,
optional(:default_currency) => String.t(),
optional(:email) => String.t(),
optional(:external_account) => String.t(),
optional(:legal_entity) => legal_entity,
optional(:metadata) => Stripe.Types.metadata(),
optional(:payout_schedule) => Stripe.Types.transfer_schedule(),
optional(:payout_statement_descriptor) => String.t(),
optional(:product_description) => String.t(),
optional(:statement_descriptor) => String.t(),
optional(:support_email) => String.t(),
optional(:support_phone) => String.t(),
optional(:support_url) => String.t(),
optional(:tos_acceptance) => tos_acceptance
}

@doc """
Update an account.
Takes the `id` and a map of changes.
"""
@spec update(Stripe.id() | t, params, Stripe.options()) :: {:ok, t} | {:error, Stripe.Error.t()}
when params: %{
optional(:business_logo) => String.t(),
optional(:business_name) => String.t(),
optional(:business_primary_color) => String.t(),
optional(:business_url) => String.t(),
optional(:double_negative_balances) => boolean,
optional(:decline_charge_on) => decline_charge_on,
optional(:account_token) => String.t(),
optional(:business_profile) => business_profile,
optional(:business_type) => String.t(),
optional(:company) => company,
optional(:default_currency) => String.t(),
optional(:email) => String.t(),
optional(:external_accounts) => String.t(),
optional(:legal_entity) => legal_entity,
optional(:individual) => individual,
optional(:metadata) => Stripe.Types.metadata(),
optional(:payout_schedule) => Stripe.Types.transfer_schedule(),
optional(:payout_statement_descriptor) => String.t(),
optional(:product_description) => String.t(),
optional(:statement_descriptor) => String.t(),
optional(:support_phone) => String.t(),
optional(:support_email) => String.t(),
optional(:support_url) => String.t(),
optional(:requested_capabilities) => capabilities,
optional(:settings) => settings,
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

major

optional(:tos_acceptance) => tos_acceptance
}
def update(id, params, opts \\ []) do
Expand Down
Loading