Skip to content

Commit

Permalink
Fix resources to pass a parameter's value in the URL not the pointer
Browse files Browse the repository at this point in the history
While inspecting the logs of stripe-mock closely, I found a few examples
of parameters that were passed incorrectly in the URL because the pointer
address was sent instead of the value it referenced.
  • Loading branch information
remi-stripe committed Jun 6, 2018
1 parent c0085ac commit 66ac54f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion invoice/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ func (c Client) ListLines(params *stripe.InvoiceLineListParams) *LineIter {

return &LineIter{stripe.GetIter(lp, body, func(b *form.Values) ([]interface{}, stripe.ListMeta, error) {
list := &stripe.InvoiceLineList{}
err := c.B.Call("GET", fmt.Sprintf("/invoices/%v/lines", params.ID), c.Key, b, p, list)
err := c.B.Call("GET", fmt.Sprintf("/invoices/%v/lines", stripe.StringValue(params.ID)), c.Key, b, p, list)

ret := make([]interface{}, len(list.Data))
for i, v := range list.Data {
Expand Down
8 changes: 4 additions & 4 deletions reversal/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func (c Client) New(params *stripe.ReversalParams) (*stripe.Reversal, error) {
form.AppendTo(body, params)

reversal := &stripe.Reversal{}
err := c.B.Call("POST", fmt.Sprintf("/transfers/%v/reversals", params.Transfer), c.Key, body, &params.Params, reversal)
err := c.B.Call("POST", fmt.Sprintf("/transfers/%v/reversals", stripe.StringValue(params.Transfer)), c.Key, body, &params.Params, reversal)

return reversal, err
}
Expand All @@ -43,7 +43,7 @@ func (c Client) Get(id string, params *stripe.ReversalParams) (*stripe.Reversal,
form.AppendTo(body, params)

reversal := &stripe.Reversal{}
err := c.B.Call("GET", fmt.Sprintf("/transfers/%v/reversals/%v", params.Transfer, id), c.Key, body, &params.Params, reversal)
err := c.B.Call("GET", fmt.Sprintf("/transfers/%v/reversals/%v", stripe.StringValue(params.Transfer), id), c.Key, body, &params.Params, reversal)

return reversal, err
}
Expand All @@ -58,7 +58,7 @@ func (c Client) Update(id string, params *stripe.ReversalParams) (*stripe.Revers
form.AppendTo(body, params)

reversal := &stripe.Reversal{}
err := c.B.Call("POST", fmt.Sprintf("/transfers/%v/reversals/%v", params.Transfer, id), c.Key, body, &params.Params, reversal)
err := c.B.Call("POST", fmt.Sprintf("/transfers/%v/reversals/%v", stripe.StringValue(params.Transfer), id), c.Key, body, &params.Params, reversal)

return reversal, err
}
Expand All @@ -76,7 +76,7 @@ func (c Client) List(params *stripe.ReversalListParams) *Iter {

return &Iter{stripe.GetIter(lp, body, func(b *form.Values) ([]interface{}, stripe.ListMeta, error) {
list := &stripe.ReversalList{}
err := c.B.Call("GET", fmt.Sprintf("/transfers/%v/reversals", params.Transfer), c.Key, b, p, list)
err := c.B.Call("GET", fmt.Sprintf("/transfers/%v/reversals", stripe.StringValue(params.Transfer)), c.Key, b, p, list)

ret := make([]interface{}, len(list.Data))
for i, v := range list.Data {
Expand Down
2 changes: 1 addition & 1 deletion source/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ func (c Client) Detach(id string, params *stripe.SourceObjectDetachParams) (*str
var err error

if params.Customer != nil {
err = c.B.Call("DELETE", fmt.Sprintf("/customers/%v/sources/%v", params.Customer, id), c.Key, body, commonParams, source)
err = c.B.Call("DELETE", fmt.Sprintf("/customers/%v/sources/%v", stripe.StringValue(params.Customer), id), c.Key, body, commonParams, source)
} else {
err = errors.New("Invalid source detach params: Customer needs to be set")
}
Expand Down

0 comments on commit 66ac54f

Please sign in to comment.