Skip to content

Commit e2186db

Browse files
committed
Change bank accounts to external accounts
1 parent 0b4c54e commit e2186db

12 files changed

Lines changed: 36 additions & 23 deletions

lib/code_corps/stripe_service/adapters/stripe_external_account.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ defmodule CodeCorps.StripeService.Adapters.StripeExternalAccountAdapter do
77
:routing_number, :status
88
]
99

10-
def to_params(%Stripe.BankAccount{} = bank_account) do
10+
def to_params(%Stripe.ExternalAccount{} = bank_account) do
1111
params =
1212
bank_account
1313
|> Map.from_struct
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
defmodule CodeCorps.StripeService.Events.ConnectExternalAccountCreated do
2+
def handle(%{"data" => %{"object" => %{"account" => account_id_from_stripe, "id" => id_from_stripe}}}) do
3+
CodeCorps.StripeService.StripeConnectExternalAccountService.create(id_from_stripe, account_id_from_stripe)
4+
end
5+
end

lib/code_corps/stripe_service/events/external_account_created.ex

Lines changed: 0 additions & 5 deletions
This file was deleted.

lib/code_corps/stripe_service/stripe_external_account_service.ex renamed to lib/code_corps/stripe_service/stripe_connect_external_account_service.ex

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
defmodule CodeCorps.StripeService.StripeExternalAccountService do
1+
defmodule CodeCorps.StripeService.StripeConnectExternalAccountService do
22
alias CodeCorps.{Repo, StripeExternalAccount}
33
alias CodeCorps.StripeService.Adapters.StripeExternalAccountAdapter
44

55
@api Application.get_env(:code_corps, :stripe)
66

7-
def create(id_from_stripe) do
8-
with {:ok, %Stripe.BankAccount{} = bank_account} <- @api.BankAccount.retrieve(id_from_stripe),
7+
def create(id_from_stripe, account_id_from_stripe) do
8+
with {:ok, %Stripe.ExternalAccount{} = bank_account} <- @api.ExternalAccount.retrieve(id_from_stripe, connect_account: account_id_from_stripe),
99
{:ok, params} <- StripeExternalAccountAdapter.to_params(bank_account)
1010
do
1111
%StripeExternalAccount{}

lib/code_corps/stripe_service/webhook_processing/connect_event_handler.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ defmodule CodeCorps.StripeService.WebhookProcessing.ConnectEventHandler do
1616
def handle_event(%{"type" => type} = attributes), do: do_handle(type, attributes)
1717

1818
defp do_handle("account.updated", attributes), do: Events.AccountUpdated.handle(attributes)
19-
defp do_handle("account.external_account.created", attributes), do: Events.ExternalAccountCreated.handle(attributes)
19+
defp do_handle("account.external_account.created", attributes), do: Events.ConnectExternalAccountCreated.handle(attributes)
2020
defp do_handle("customer.subscription.deleted", attributes), do: Events.CustomerSubscriptionDeleted.handle(attributes)
2121
defp do_handle("customer.subscription.updated", attributes), do: Events.CustomerSubscriptionUpdated.handle(attributes)
2222
defp do_handle(_, _), do: {:ok, :unhandled_event}

lib/code_corps/stripe_testing/bank_account.ex renamed to lib/code_corps/stripe_testing/external_account.ex

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
defmodule CodeCorps.StripeTesting.BankAccount do
2-
def retrieve(id) do
1+
defmodule CodeCorps.StripeTesting.ExternalAccount do
2+
def retrieve(id, _) do
33
{:ok, bank_account(id)}
44
end
55

66
defp bank_account(id) do
7-
%Stripe.BankAccount{
7+
%Stripe.ExternalAccount{
88
id: id,
99
object: "bank_account",
1010
account: "acct_1032D82eZvKYlo2C",

mix.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
"segment": {:hex, :segment, "0.1.1", "47bf9191590e7a533c105d1e21518e0d6da47c91e8d98ebb649c624db5dfc359", [:mix], [{:httpoison, "~> 0.8", [hex: :httpoison, optional: false]}, {:poison, "~> 1.3 or ~> 2.0", [hex: :poison, optional: false]}]},
5757
"sentry": {:hex, :sentry, "2.1.0", "51e7ca261b519294ac73b30763893c4a7ad2005205514aefa5bf37ccb83e44ea", [:mix], [{:hackney, "~> 1.6.1", [hex: :hackney, optional: false]}, {:plug, "~> 1.0", [hex: :plug, optional: true]}, {:poison, "~> 1.5 or ~> 2.0 or ~> 3.0", [hex: :poison, optional: false]}, {:uuid, "~> 1.0", [hex: :uuid, optional: false]}]},
5858
"ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.0", "edee20847c42e379bf91261db474ffbe373f8acb56e9079acb6038d4e0bf414f", [:make, :rebar], []},
59-
"stripity_stripe": {:git, "https://github.com/code-corps/stripity_stripe.git", "bffefa3195d4fc75dafece4094d697506dc72c07", [branch: "2.0"]},
59+
"stripity_stripe": {:git, "https://github.com/code-corps/stripity_stripe.git", "f325778c8fb2af3bc04c9d894daef0c47c1500de", [branch: "2.0"]},
6060
"sweet_xml": {:hex, :sweet_xml, "0.6.3", "814265792baeb163421811c546581c522dfdcb9d1767b1e59959c52906414e80", [:mix], []},
6161
"timber": {:hex, :timber, "0.4.7", "df3fcd79bcb4eb4b53874d906ef5f3a212937b4bc7b7c5b244745202cc389443", [:mix], [{:ecto, "~> 2.0", [hex: :ecto, optional: true]}, {:phoenix, "~> 1.2", [hex: :phoenix, optional: true]}, {:plug, "~> 1.2", [hex: :plug, optional: true]}, {:poison, "~> 2.0 or ~> 3.0", [hex: :poison, optional: false]}]},
6262
"timex": {:hex, :timex, "3.1.5", "413d6d8d6f0162a5d47080cb8ca520d790184ac43e097c95191c7563bf25b428", [:mix], [{:combine, "~> 0.7", [hex: :combine, optional: false]}, {:gettext, "~> 0.10", [hex: :gettext, optional: false]}, {:tzdata, "~> 0.1.8 or ~> 0.5", [hex: :tzdata, optional: false]}]},

test/lib/code_corps/stripe_service/adapters/stripe_external_account_test.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ defmodule CodeCorps.StripeService.Adapters.StripeExternalAccountTestAdapter do
33

44
import CodeCorps.StripeService.Adapters.StripeExternalAccountAdapter, only: [to_params: 1]
55

6-
@stripe_connect_account %Stripe.BankAccount{
6+
@stripe_connect_account %Stripe.ExternalAccount{
77
id: "ba_19SSZG2eZvKYlo2CXnmzYU5H",
88
object: "bank_account",
99
account: "acct_1032D82eZvKYlo2C",

test/lib/code_corps/stripe_service/stripe_external_account_service_test.exs renamed to test/lib/code_corps/stripe_service/stripe_connect_external_account_service_test.exs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
1-
defmodule CodeCorps.StripeService.StripeExternalAccountServiceTest do
1+
defmodule CodeCorps.StripeService.StripeConnectExternalAccountServiceTest do
22
use ExUnit.Case, async: true
33

44
use CodeCorps.ModelCase
55

6-
alias CodeCorps.StripeService.StripeExternalAccountService
6+
alias CodeCorps.StripeService.StripeConnectExternalAccountService
77

88
describe "create" do
99
test "creates a StripeExternalAccount" do
1010
id_from_stripe = "ba_testing123"
11+
account_id_from_stripe = "acct_123"
1112

1213
{:ok, %CodeCorps.StripeExternalAccount{} = bank_account} =
13-
StripeExternalAccountService.create(id_from_stripe)
14+
StripeConnectExternalAccountService.create(id_from_stripe, account_id_from_stripe)
1415

1516
assert bank_account.id_from_stripe == id_from_stripe
1617
end

test/lib/code_corps/stripe_service/stripe_platform_customer_service_test.exs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
defmodule CodeCorps.StripeService.StripePlatformCustomerServiceTest do
2+
@moduledoc false
3+
24
use CodeCorps.ModelCase
35

46
alias CodeCorps.StripePlatformCustomer

0 commit comments

Comments
 (0)