Skip to content

Commit

Permalink
Merge pull request #273 from code-corps/clean-up-token-types
Browse files Browse the repository at this point in the history
Clean up Token, BankAccount, Card, Source types
  • Loading branch information
joshsmith authored Nov 18, 2017
2 parents b2e2c43 + 8d9a78c commit 3cc9dd7
Show file tree
Hide file tree
Showing 5 changed files with 263 additions and 132 deletions.
60 changes: 50 additions & 10 deletions lib/stripe/core_resources/token.ex
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,57 @@ defmodule Stripe.Token do
"""
use Stripe.Entity

@type token_bank_account :: %{
id: Stripe.id,
object: String.t,
account_holder_name: String.t | nil,
account_holder_type: Stripe.BankAccount.account_holder_type | nil,
bank_name: String.t | nil,
country: String.t,
currency: String.t,
fingerprint: String.t | nil,
last4: String.t,
routing_number: String.t | nil,
status: Stripe.BankAccount.status
}

@type token_card :: %{
id: Stripe.id,
object: String.t,
address_city: String.t | nil,
address_country: String.t | nil,
address_line1: String.t | nil,
address_line1_check: Stripe.Card.check_result | nil,
address_line2: String.t | nil,
address_state: String.t | nil,
address_zip: String.t | nil,
address_zip_check: Stripe.Card.check_result | nil,
brand: String.t,
country: String.t | nil,
currency: String.t,
cvc_check: Stripe.Card.check_result | nil,
dynamic_last4: String.t | nil,
exp_month: integer,
exp_year: integer,
fingerprint: String.t | nil,
funding: Stripe.Card.funding,
last4: String.t,
metadata: Stripe.Types.metadata,
name: String.t | nil,
tokenization_method: Stripe.Card.tokenization_method | nil
}

@type t :: %__MODULE__{
id: Stripe.id,
object: String.t,
bank_account: Stripe.BankAccount.t,
card: Stripe.Card.t,
client_ip: String.t,
created: Stripe.timestamp,
livemode: boolean,
type: :card | :bank_account,
used: boolean
}
id: Stripe.id,
object: String.t,
bank_account: token_bank_account,
card: token_card,
client_ip: String.t | nil,
created: Stripe.timestamp,
livemode: boolean,
type: :card | :bank_account,
used: boolean
}

defstruct [
:id,
Expand Down
38 changes: 20 additions & 18 deletions lib/stripe/payment_methods/bank_account.ex
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,27 @@ defmodule Stripe.BankAccount do
"""
use Stripe.Entity

@type account_holder_type :: :individual | :company

@type status :: :new | :validated | :verified | :verification_failed | :errored

@type t :: %__MODULE__{
id: Stripe.id,
object: String.t,
account: Stripe.id | Stripe.Account.t,
account_holder_name: String.t,
account_holder_type: :individual | :company,
bank_name: String.t,
country: String.t,
currency: String.t,
customer: Stripe.id | Stripe.Customer.t,
default_for_currency: boolean,
fingerprint: String.t,
last4: String.t,
metadata: %{
optional(String.t) => String.t
},
routing_number: String.t,
status: :new | :validated | :verified | :verification_failed | :errored
}
id: Stripe.id,
object: String.t,
account: Stripe.id | Stripe.Account.t | nil,
account_holder_name: String.t | nil,
account_holder_type: account_holder_type | nil,
bank_name: String.t | nil,
country: String.t,
currency: String.t,
customer: Stripe.id | Stripe.Customer.t | nil,
default_for_currency: boolean | nil,
fingerprint: String.t | nil,
last4: String.t,
metadata: Stripe.Types.metadata | nil,
routing_number: String.t | nil,
status: status
}

defstruct [
:id,
Expand Down
65 changes: 34 additions & 31 deletions lib/stripe/payment_methods/card.ex
Original file line number Diff line number Diff line change
Expand Up @@ -23,38 +23,41 @@ defmodule Stripe.Card do

@type check_result :: :pass | :fail | :unavailable | :unchecked

@type funding :: :credit | :debit | :prepaid | :unknown

@type tokenization_method :: :apple_pay | :android_pay

@type t :: %__MODULE__{
id: Stripe.id,
object: String.t,
account: Stripe.id | Stripe.Account.t,
address_city: String.t,
address_country: String.t,
address_line1: String.t,
address_line1_check: check_result,
address_line2: String.t,
address_state: String.t,
address_zip: String.t,
address_zip_check: check_result,
available_payout_methods: [:standard | :instant],
brand: String.t,
country: String.t,
currency: String.t,
customer: Stripe.id | Stripe.Customer.t,
cvc_check: check_result,
default_for_currency: boolean,
dynamic_last4: String.t,
exp_month: integer,
exp_year: integer,
fingerprint: String.t,
funding: :credit | :debit | :prepaid | :unknown,
last4: String.t,
metadata: %{
optional(String.t) => String.t
},
name: String.t,
recipient: Stripe.id | Stripe.Recipient.t,
tokenization_method: :apple_pay | :android_pay | nil
}
id: Stripe.id,
object: String.t,
account: Stripe.id | Stripe.Account.t | nil,
address_city: String.t | nil,
address_country: String.t | nil,
address_line1: String.t | nil,
address_line1_check: check_result | nil,
address_line2: String.t | nil,
address_state: String.t | nil,
address_zip: String.t | nil,
address_zip_check: check_result | nil,
available_payout_methods: [:standard | :instant] | nil,
brand: String.t,
country: String.t | nil,
currency: String.t | nil,
customer: Stripe.id | Stripe.Customer.t | nil,
cvc_check: check_result | nil,
default_for_currency: boolean | nil,
dynamic_last4: String.t | nil,
exp_month: integer,
exp_year: integer,
fingerprint: String.t | nil,
funding: funding,
last4: String.t,
metadata: Stripe.Types.metadata,
name: String.t | nil,
recipient: Stripe.id | Stripe.Recipient.t | nil,
tokenization_method: tokenization_method | nil
}

@type source :: :customer | :recipient | :account
@sources [:customer, :recipient, :account]
@type owner :: Stripe.Customer.t | Stripe.Account.t
Expand Down
Loading

0 comments on commit 3cc9dd7

Please sign in to comment.