Skip to content

Commit

Permalink
Ensure that the token is only passed once (#479)
Browse files Browse the repository at this point in the history
Before this fix, passing Account and Token triggered the token to be sent
both under `external_account` and under `source`.
  • Loading branch information
remi-stripe authored and brandur-stripe committed Oct 19, 2017
1 parent b6a497c commit db9adbc
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions card.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,17 +68,16 @@ type CardParams struct {
// because the cards endpoint is a little unusual. There is one other resource
// like it, which is bank account.
func (c *CardParams) AppendToAsCardSourceOrExternalAccount(body *form.Values, keyParts []string) {
if len(c.Token) > 0 && len(c.Account) > 0 {
body.Add(form.FormatKey(append(keyParts, "external_account")), c.Token)

}

if c.Default {
body.Add(form.FormatKey(append(keyParts, "default_for_currency")), strconv.FormatBool(c.Default))
}

if len(c.Token) > 0 {
body.Add(form.FormatKey(append(keyParts, cardSource)), c.Token)
if len(c.Account) > 0 {
body.Add(form.FormatKey(append(keyParts, "external_account")), c.Token)
} else {
body.Add(form.FormatKey(append(keyParts, cardSource)), c.Token)
}
}

if len(c.Number) > 0 {
Expand Down

0 comments on commit db9adbc

Please sign in to comment.