Skip to content

Commit

Permalink
Fix card and bank account endpoints to the most recent ones
Browse files Browse the repository at this point in the history
Card and Bank accounts used to be managed through /cards and /bank_accounts
this has changed years ago to move to /sources and /external_accounts but
we never fully updated the library to match this

We now use the proper/latest endpoints. Listing cards/bank accounts now
pass the right default parameters in the URL too to limit to those objects.
  • Loading branch information
remi-stripe committed Jun 6, 2018
1 parent 69562de commit 56c6c56
Showing 2 changed files with 15 additions and 15 deletions.
18 changes: 9 additions & 9 deletions bankaccount/client.go
Original file line number Diff line number Diff line change
@@ -33,7 +33,7 @@ func (c Client) New(params *stripe.BankAccountParams) (*stripe.BankAccount, erro
if params.Customer != nil {
err = c.B.Call("POST", fmt.Sprintf("/customers/%v/sources", stripe.StringValue(params.Customer)), c.Key, body, &params.Params, ba)
} else {
err = c.B.Call("POST", fmt.Sprintf("/accounts/%v/bank_accounts", stripe.StringValue(params.Account)), c.Key, body, &params.Params, ba)
err = c.B.Call("POST", fmt.Sprintf("/accounts/%v/external_accounts", stripe.StringValue(params.Account)), c.Key, body, &params.Params, ba)
}

return ba, err
@@ -58,9 +58,9 @@ func (c Client) Get(id string, params *stripe.BankAccountParams) (*stripe.BankAc
var err error

if params != nil && params.Customer != nil {
err = c.B.Call("GET", fmt.Sprintf("/customers/%v/bank_accounts/%v", stripe.StringValue(params.Customer), id), c.Key, body, commonParams, ba)
err = c.B.Call("GET", fmt.Sprintf("/customers/%v/sources/%v", stripe.StringValue(params.Customer), id), c.Key, body, commonParams, ba)
} else if params != nil && params.Account != nil {
err = c.B.Call("GET", fmt.Sprintf("/accounts/%v/bank_accounts/%v", stripe.StringValue(params.Account), id), c.Key, body, commonParams, ba)
err = c.B.Call("GET", fmt.Sprintf("/accounts/%v/external_accounts/%v", stripe.StringValue(params.Account), id), c.Key, body, commonParams, ba)
} else {
err = errors.New("Invalid bank account params: either Customer or Account need to be set")
}
@@ -87,9 +87,9 @@ func (c Client) Update(id string, params *stripe.BankAccountParams) (*stripe.Ban
var err error

if params.Customer != nil {
err = c.B.Call("POST", fmt.Sprintf("/customers/%v/bank_accounts/%v", stripe.StringValue(params.Customer), id), c.Key, body, commonParams, ba)
err = c.B.Call("POST", fmt.Sprintf("/customers/%v/sources/%v", stripe.StringValue(params.Customer), id), c.Key, body, commonParams, ba)
} else if params.Account != nil {
err = c.B.Call("POST", fmt.Sprintf("/accounts/%v/bank_accounts/%v", stripe.StringValue(params.Account), id), c.Key, body, commonParams, ba)
err = c.B.Call("POST", fmt.Sprintf("/accounts/%v/external_accounts/%v", stripe.StringValue(params.Account), id), c.Key, body, commonParams, ba)
} else {
err = errors.New("Invalid bank account params: either Customer or Account need to be set")
}
@@ -116,9 +116,9 @@ func (c Client) Del(id string, params *stripe.BankAccountParams) (*stripe.BankAc
var err error

if params.Customer != nil {
err = c.B.Call("DELETE", fmt.Sprintf("/customers/%v/bank_accounts/%v", stripe.StringValue(params.Customer), id), c.Key, body, commonParams, ba)
err = c.B.Call("DELETE", fmt.Sprintf("/customers/%v/sources/%v", stripe.StringValue(params.Customer), id), c.Key, body, commonParams, ba)
} else if params.Account != nil {
err = c.B.Call("DELETE", fmt.Sprintf("/accounts/%v/bank_accounts/%v", stripe.StringValue(params.Account), id), c.Key, body, commonParams, ba)
err = c.B.Call("DELETE", fmt.Sprintf("/accounts/%v/external_accounts/%v", stripe.StringValue(params.Account), id), c.Key, body, commonParams, ba)
} else {
err = errors.New("Invalid bank account params: either Customer or Account need to be set")
}
@@ -145,9 +145,9 @@ func (c Client) List(params *stripe.BankAccountListParams) *Iter {
var err error

if params.Customer != nil {
err = c.B.Call("GET", fmt.Sprintf("/customers/%v/bank_accounts", stripe.StringValue(params.Customer)), c.Key, b, p, list)
err = c.B.Call("GET", fmt.Sprintf("/customers/%v/sources?object=bank_account", stripe.StringValue(params.Customer)), c.Key, b, p, list)
} else if params.Account != nil {
err = c.B.Call("GET", fmt.Sprintf("/accounts/%v/bank_accounts", stripe.StringValue(params.Account)), c.Key, b, p, list)
err = c.B.Call("GET", fmt.Sprintf("/accounts/%v/external_accounts?object=bank_account", stripe.StringValue(params.Account)), c.Key, b, p, list)
} else {
err = errors.New("Invalid bank account params: either Customer or Account need to be set")
}
12 changes: 6 additions & 6 deletions card/client.go
Original file line number Diff line number Diff line change
@@ -39,7 +39,7 @@ func (c Client) New(params *stripe.CardParams) (*stripe.Card, error) {
if params.Account != nil {
err = c.B.Call("POST", fmt.Sprintf("/accounts/%v/external_accounts", stripe.StringValue(params.Account)), c.Key, body, &params.Params, card)
} else if params.Customer != nil {
err = c.B.Call("POST", fmt.Sprintf("/customers/%v/cards", stripe.StringValue(params.Customer)), c.Key, body, &params.Params, card)
err = c.B.Call("POST", fmt.Sprintf("/customers/%v/sources", stripe.StringValue(params.Customer)), c.Key, body, &params.Params, card)
} else if params.Recipient != nil {
err = c.B.Call("POST", fmt.Sprintf("/recipients/%v/cards", stripe.StringValue(params.Recipient)), c.Key, body, &params.Params, card)
} else {
@@ -75,7 +75,7 @@ func (c Client) Get(id string, params *stripe.CardParams) (*stripe.Card, error)
if params.Account != nil {
err = c.B.Call("GET", fmt.Sprintf("/accounts/%v/external_accounts/%v", stripe.StringValue(params.Account), id), c.Key, body, commonParams, card)
} else if params.Customer != nil {
err = c.B.Call("GET", fmt.Sprintf("/customers/%v/cards/%v", stripe.StringValue(params.Customer), id), c.Key, body, commonParams, card)
err = c.B.Call("GET", fmt.Sprintf("/customers/%v/sources/%v", stripe.StringValue(params.Customer), id), c.Key, body, commonParams, card)
} else if params.Recipient != nil {
err = c.B.Call("GET", fmt.Sprintf("/recipients/%v/cards/%v", stripe.StringValue(params.Recipient), id), c.Key, body, commonParams, card)
} else {
@@ -105,7 +105,7 @@ func (c Client) Update(id string, params *stripe.CardParams) (*stripe.Card, erro
if params.Account != nil {
err = c.B.Call("POST", fmt.Sprintf("/accounts/%v/external_accounts/%v", stripe.StringValue(params.Account), id), c.Key, body, &params.Params, card)
} else if params.Customer != nil {
err = c.B.Call("POST", fmt.Sprintf("/customers/%v/cards/%v", stripe.StringValue(params.Customer), id), c.Key, body, &params.Params, card)
err = c.B.Call("POST", fmt.Sprintf("/customers/%v/sources/%v", stripe.StringValue(params.Customer), id), c.Key, body, &params.Params, card)
} else if params.Recipient != nil {
err = c.B.Call("POST", fmt.Sprintf("/recipients/%v/cards/%v", stripe.StringValue(params.Recipient), id), c.Key, body, &params.Params, card)
} else {
@@ -139,7 +139,7 @@ func (c Client) Del(id string, params *stripe.CardParams) (*stripe.Card, error)
if params.Account != nil {
err = c.B.Call("DELETE", fmt.Sprintf("/accounts/%v/external_accounts/%v", stripe.StringValue(params.Account), id), c.Key, body, commonParams, card)
} else if params.Customer != nil {
err = c.B.Call("DELETE", fmt.Sprintf("/customers/%v/cards/%v", stripe.StringValue(params.Customer), id), c.Key, body, commonParams, card)
err = c.B.Call("DELETE", fmt.Sprintf("/customers/%v/sources/%v", stripe.StringValue(params.Customer), id), c.Key, body, commonParams, card)
} else if params.Recipient != nil {
err = c.B.Call("DELETE", fmt.Sprintf("/recipients/%v/cards/%v", stripe.StringValue(params.Recipient), id), c.Key, body, commonParams, card)
} else {
@@ -175,9 +175,9 @@ func (c Client) List(params *stripe.CardListParams) *Iter {
}

if params.Account != nil {
err = c.B.Call("GET", fmt.Sprintf("/accounts/%v/external_accounts", stripe.StringValue(params.Account)), c.Key, b, p, list)
err = c.B.Call("GET", fmt.Sprintf("/accounts/%v/external_accounts?object=card", stripe.StringValue(params.Account)), c.Key, b, p, list)
} else if params.Customer != nil {
err = c.B.Call("GET", fmt.Sprintf("/customers/%v/cards", stripe.StringValue(params.Customer)), c.Key, b, p, list)
err = c.B.Call("GET", fmt.Sprintf("/customers/%v/sources?object=card", stripe.StringValue(params.Customer)), c.Key, b, p, list)
} else if params.Recipient != nil {
err = c.B.Call("GET", fmt.Sprintf("/recipients/%v/cards", stripe.StringValue(params.Recipient)), c.Key, b, p, list)
} else {

0 comments on commit 56c6c56

Please sign in to comment.