Skip to content

Commit

Permalink
Merge pull request #500 from stripe/remi-fix-card-source-sharing
Browse files Browse the repository at this point in the history
Support source sharing via Stripe Connect
  • Loading branch information
brandur-stripe authored Dec 13, 2017
2 parents 626a2f7 + 2098ea6 commit 5a3d733
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 0 deletions.
3 changes: 3 additions & 0 deletions bankaccount.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ type BankAccountParams struct {
// Token is a token referencing an external account like one returned from
// Stripe.js.
Token string `form:"-"`

// ID is used when tokenizing a bank account for shared customers
ID string `form:"*"`
}

// AppendToAsSourceOrExternalAccount appends the given BankAccountParams as
Expand Down
3 changes: 3 additions & 0 deletions card.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ type CardParams struct {
Token string `form:"-"`
Year string `form:"exp_year"`
Zip string `form:"address_zip"`

// ID is used when tokenizing a card for shared customers
ID string `form:"*"`
}

// AppendToAsCardSourceOrExternalAccount appends the given CardParams as either a
Expand Down
1 change: 1 addition & 0 deletions source.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ type SourceObjectParams struct {
Currency Currency `form:"currency"`
Customer string `form:"customer"`
Flow SourceFlow `form:"flow"`
OriginalSource string `form:"original_source"`
Owner *SourceOwnerParams `form:"owner"`
Redirect *RedirectParams `form:"redirect"`
StatementDescriptor string `form:"statement_descriptor"`
Expand Down
13 changes: 13 additions & 0 deletions source/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,16 @@ func TestSourceDetach(t *testing.T) {
assert.Nil(t, err)
assert.NotNil(t, source)
}

func TestSourceSharing(t *testing.T) {
params := &stripe.SourceObjectParams{
Type: "card",
Customer: "cus_123",
OriginalSource: "src_123",
Usage: stripe.UsageReusable,
}
params.SetStripeAccount("acct_123")
source, err := New(params)
assert.Nil(t, err)
assert.NotNil(t, source)
}
26 changes: 26 additions & 0 deletions token/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,29 @@ func TestTokenNew_WithPII(t *testing.T) {
assert.Nil(t, err)
assert.NotNil(t, token)
}

func TestTokenNew_SharedCustomerCard(t *testing.T) {
params := &stripe.TokenParams{
Card: &stripe.CardParams{
ID: "card_123",
},
Customer: "cus_123",
}
params.SetStripeAccount("acct_123")
token, err := New(params)
assert.Nil(t, err)
assert.NotNil(t, token)
}

func TestTokenNew_SharedCustomerBankAccount(t *testing.T) {
params := &stripe.TokenParams{
Bank: &stripe.BankAccountParams{
ID: "ba_123",
},
Customer: "cus_123",
}
params.SetStripeAccount("acct_123")
token, err := New(params)
assert.Nil(t, err)
assert.NotNil(t, token)
}

0 comments on commit 5a3d733

Please sign in to comment.