From d314422bb57e723ce4f05c7cc6918f30724a0750 Mon Sep 17 00:00:00 2001 From: Remi Jannel Date: Tue, 12 Dec 2017 18:39:35 -0500 Subject: [PATCH 1/2] Support passing original_source to clone a source to a connected account --- source.go | 1 + source/client_test.go | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/source.go b/source.go index 0016bbbe20..3b05318de9 100644 --- a/source.go +++ b/source.go @@ -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"` diff --git a/source/client_test.go b/source/client_test.go index d83e354f99..2928433110 100644 --- a/source/client_test.go +++ b/source/client_test.go @@ -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) +} From 2098ea621720b0a7db193223b31976b16d84691b Mon Sep 17 00:00:00 2001 From: Remi Jannel Date: Tue, 12 Dec 2017 18:39:19 -0500 Subject: [PATCH 2/2] Properly support passing card and bank_account on Token creation When using Shared Customers, you can take a card or bank account on the platform and create a new token for it on a connected account by passing its id in card/bank_account along with the customer id. --- bankaccount.go | 3 +++ card.go | 3 +++ token/client_test.go | 26 ++++++++++++++++++++++++++ 3 files changed, 32 insertions(+) diff --git a/bankaccount.go b/bankaccount.go index 863cefaa05..ccd0ff65e5 100644 --- a/bankaccount.go +++ b/bankaccount.go @@ -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 diff --git a/card.go b/card.go index 8267111299..c8dea8d488 100644 --- a/card.go +++ b/card.go @@ -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 diff --git a/token/client_test.go b/token/client_test.go index 9842d7257f..5414d3e006 100644 --- a/token/client_test.go +++ b/token/client_test.go @@ -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) +}