-
Notifications
You must be signed in to change notification settings - Fork 343
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
66 additions
and
0 deletions.
There are no files selected for viewing
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,50 @@ | ||
defmodule Stripe.AccountLink do | ||
@moduledoc """ | ||
Work with Stripe Connect account link objects. | ||
You can: | ||
- Create an account link | ||
Stripe API reference: https://stripe.com/docs/api/account_links | ||
""" | ||
|
||
use Stripe.Entity | ||
import Stripe.Request | ||
|
||
@type t :: %__MODULE__{ | ||
object: String.t(), | ||
created: Stripe.timestamp(), | ||
expires_at: Stripe.timestamp(), | ||
url: String.t() | ||
} | ||
|
||
defstruct [ | ||
:object, | ||
:created, | ||
:expires_at, | ||
:url | ||
] | ||
|
||
@plural_endpoint "account_links" | ||
|
||
@doc """ | ||
Create an account link. | ||
""" | ||
@spec create(params, Stripe.options()) :: {:ok, t} | {:error, Stripe.Error.t()} | ||
when params: %{ | ||
:account => Stripe.Account.t() | Stripe.id(), | ||
:failure_url => String.t(), | ||
:success_url => String.t(), | ||
:type => String.t(), | ||
optional(:collect) => String.t() | ||
} | ||
def create(params, opts \\ []) do | ||
new_request(opts) | ||
|> put_endpoint(@plural_endpoint) | ||
|> put_params(params) | ||
|> put_method(:post) | ||
|> cast_to_id([:account]) | ||
|> make_request() | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
defmodule Stripe.AccountLinkTest do | ||
use Stripe.StripeCase, async: true | ||
|
||
test "is creatable" do | ||
params = %{ | ||
account: "acct_123", | ||
failure_url: "https://stripe.com", | ||
success_url: "https://stripe.com", | ||
type: "custom_account_verification" | ||
} | ||
|
||
assert {:ok, %Stripe.AccountLink{}} = Stripe.AccountLink.create(params) | ||
assert_stripe_requested(:post, "/v1/account_links") | ||
end | ||
end |