Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't add a card to an account #478

Closed
lefta opened this issue Oct 18, 2017 · 2 comments · Fixed by #479
Closed

Can't add a card to an account #478

lefta opened this issue Oct 18, 2017 · 2 comments · Fixed by #479
Assignees

Comments

@lefta
Copy link

lefta commented Oct 18, 2017

When adding a card to a client, the Stripe API returns a 400 error with a Received unknown parameter: source message.

Example code:

params := &stripe.CardParams{
	Account: "acct_...",
	Token:   "tok_mastercard_debit_transferFailure",
}
card.New(params)

The problem seems to lie in AppendToAsCardSourceOrExternalAccount. The function adds the source field even when params contains an account.

As a workaround, I was able to solve this issue by reimplementing the relevant parts of card.New():

c := card.Client{stripe.GetBackend(stripe.APIBackend), stripe.Key}
body := &form.Values{}
body.Add(form.FormatKey([]string{"external_account"}), params.Token)
card := &stripe.Card{}
err := c.B.Call("POST", fmt.Sprintf("/accounts/%v/external_accounts", params.Account), c.Key, body, &params.Params, card)

Go version: 1.9.1
Stripe Go library version: 28.3.0

@remi-stripe
Copy link
Contributor

Hey @lefta. Thanks a lot for the detailed report! I pushed a fix in #479 which solves the issue. Can you confirm this has no side effect in your current project?

@brandur-stripe
Copy link
Contributor

Hi there, we've released a fix for this as part of 28.3.2. Thanks for reporting and sorry about the trouble!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants