From db9adbc80c9a047e6b692cf281795cbd7a5a80a8 Mon Sep 17 00:00:00 2001 From: remi-stripe Date: Thu, 19 Oct 2017 13:27:55 -0400 Subject: [PATCH] Ensure that the token is only passed once (#479) Before this fix, passing Account and Token triggered the token to be sent both under `external_account` and under `source`. --- card.go | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/card.go b/card.go index 00a5b8ac96..8267111299 100644 --- a/card.go +++ b/card.go @@ -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 {