-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add legal_entity fields to StripeConnectAccount
- Loading branch information
Showing
9 changed files
with
310 additions
and
34 deletions.
There are no files selected for viewing
62 changes: 59 additions & 3 deletions
62
lib/code_corps/stripe_service/adapters/stripe_connect_account.ex
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
defmodule CodeCorps.StripeService.Util do | ||
@moduledoc """ | ||
Utility functions for handling the Stripe API. | ||
""" | ||
|
||
@doc """ | ||
Takes a source map and a list of tuples representing how the source map | ||
should be transformed into a new map, then applies the mapping | ||
operation on each field | ||
""" | ||
def transform_map(api_map, mapping), do: mapping |> Enum.reduce(%{}, &map_field(&1, &2, api_map)) | ||
|
||
# Takes a tuple which contains a target field and a source path, | ||
# then puts value on the source path from the source map | ||
# into to target map under the target field name. | ||
# Example: | ||
# | ||
# - `source_map` is `%{path: %{to: %{field: some_value}} } | ||
# - `source_path` is `[:path, :to, :field]` | ||
# - `target_field` is `:path_to_field` | ||
# - `some_value` will be put into `target_map`, under the key `:path_to_field` | ||
defp map_field({target_field, source_path}, target_map, source_map) do | ||
value = get_in(source_map, source_path) | ||
target_map |> Map.put(target_field, value) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
priv/repo/migrations/20161221085759_add_legal_entity_fields_to_stripe_connect_account.exs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
defmodule CodeCorps.Repo.Migrations.AddLegalEntityFieldsToStripeConnectAccount do | ||
use Ecto.Migration | ||
|
||
def change do | ||
alter table(:stripe_connect_accounts) do | ||
add :legal_entity_address_city, :string | ||
add :legal_entity_address_country, :string | ||
add :legal_entity_address_line1, :string | ||
add :legal_entity_address_line2, :string | ||
add :legal_entity_address_postal_code, :string | ||
add :legal_entity_address_state, :string | ||
|
||
add :legal_entity_business_name, :string | ||
add :legal_entity_business_tax_id_provided, :boolean, default: false | ||
add :legal_entity_business_vat_id_provided, :boolean, default: false | ||
add :legal_entity_dob_day, :string | ||
add :legal_entity_dob_month, :string | ||
add :legal_entity_dob_year, :string | ||
|
||
add :legal_entity_first_name, :string | ||
add :legal_entity_last_name, :string | ||
add :legal_entity_gender, :string | ||
add :legal_entity_maiden_name, :string | ||
|
||
add :legal_entity_personal_address_city, :string | ||
add :legal_entity_personal_address_country, :string | ||
add :legal_entity_personal_address_line1, :string | ||
add :legal_entity_personal_address_line2, :string | ||
add :legal_entity_personal_address_postal_code, :string | ||
add :legal_entity_personal_address_state, :string | ||
|
||
add :legal_entity_phone_number, :string | ||
|
||
add :legal_entity_personal_id_number_provided, :boolean, default: false | ||
add :legal_entity_ssn_last_4_provided, :boolean, default: false | ||
|
||
add :legal_entity_type, :string | ||
|
||
add :legal_entity_verification_details, :string | ||
add :legal_entity_verification_details_code, :string | ||
add :legal_entity_verification_document, :string | ||
add :legal_entity_verification_status, :string | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.