Skip to content

Commit 30622ed

Browse files
committed
add helper to set up test account
1 parent 4736997 commit 30622ed

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

lib/algora/admin/admin.ex

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ defmodule Algora.Admin do
22
@moduledoc false
33
import Ecto.Query
44

5+
alias Algora.Accounts.User
6+
alias Algora.Payments
57
alias Algora.Repo
68
alias Algora.Workspace
79
alias Algora.Workspace.Ticket
@@ -72,6 +74,15 @@ defmodule Algora.Admin do
7274
|> Algora.Repo.update()
7375
end
7476

77+
def setup_test_account(user_handle) do
78+
with account_id when is_binary(account_id) <- Algora.config([:stripe, :test_account_id]),
79+
{:ok, user} <- Repo.fetch_by(User, handle: user_handle),
80+
{:ok, acct} <- Payments.create_account(user, "US"),
81+
{:ok, stripe_acct} <- Stripe.Account.retrieve(account_id) do
82+
Payments.update_account(acct, stripe_acct)
83+
end
84+
end
85+
7586
defp update_tickets(url, repo_id) do
7687
Repo.update_all(from(t in Ticket, where: fragment("?->>'repository_url' = ?", t.provider_meta, ^url)),
7788
set: [repository_id: repo_id]

0 commit comments

Comments
 (0)