Skip to content

Commit

Permalink
Make card token passing more intuitive
Browse files Browse the repository at this point in the history
You can pass it via *Params.Token or via *Params.CardParams.Token to
avoid confusion

Fixes issue #4
  • Loading branch information
cosn committed Sep 2, 2014
1 parent fff3ee8 commit 0c6a077
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
6 changes: 5 additions & 1 deletion charges.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,11 @@ func (c *ChargeClient) Create(params *ChargeParams) (*Charge, error) {
} else if len(params.Token) > 0 {
body.Add("card", params.Token)
} else if params.Card != nil {
params.Card.appendTo(body, true)
if len(params.Card.Token) > 0 {
body.Add("card", params.Card.Token)
} else {
params.Card.appendTo(body, true)
}
} else {
err := errors.New("Invalid charge params: either customer, card token or card need to be set")
return nil, err
Expand Down
6 changes: 5 additions & 1 deletion customers.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,11 @@ func (c *CustomerClient) Update(id string, params *CustomerParams) (*Customer, e
if len(params.Token) > 0 {
body.Add("card", params.Token)
} else if params.Card != nil {
params.Card.appendTo(body, true)
if len(params.Card.Token) > 0 {
body.Add("card", params.Card.Token)
} else {
params.Card.appendTo(body, true)
}
}

if len(params.Desc) > 0 {
Expand Down
6 changes: 5 additions & 1 deletion subscriptions.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,11 @@ func (c *SubscriptionClient) Update(id string, params *SubParams) (*Subscription
if len(params.Token) > 0 {
body.Add("card", params.Token)
} else if params.Card != nil {
params.Card.appendTo(body, true)
if len(params.Card.Token) > 0 {
body.Add("card", params.Card.Token)
} else {
params.Card.appendTo(body, true)
}
}

if len(params.Coupon) > 0 {
Expand Down

0 comments on commit 0c6a077

Please sign in to comment.