Beispiel #1
0
func (c Client) Update(id string, params *stripe.ReversalParams) (*stripe.Reversal, error) {
	body := &url.Values{}

	params.AppendTo(body)

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

	return reversal, err
}
Beispiel #2
0
func (c Client) Get(id string, params *stripe.ReversalParams) (*stripe.Reversal, error) {
	if params == nil {
		return nil, fmt.Errorf("params cannot be nil, and params.Transfer must be set")
	}

	body := &url.Values{}
	params.AppendTo(body)

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

	return reversal, err
}
Beispiel #3
0
func (c Client) New(params *stripe.ReversalParams) (*stripe.Reversal, error) {
	body := &url.Values{}

	if params.Amount > 0 {
		body.Add("amount", strconv.FormatUint(params.Amount, 10))
	}

	if params.Fee {
		body.Add("refund_application_fee", strconv.FormatBool(params.Fee))
	}

	params.AppendTo(body)

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

	return reversal, err
}