Beispiel #1
0
func (c Client) New(params *stripe.RefundParams) (*stripe.Refund, 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))
	}

	if params.Transfer {
		body.Add("reverse_transfer", strconv.FormatBool(params.Transfer))
	}

	if len(params.Reason) > 0 {
		body.Add("reason", string(params.Reason))
	}

	if len(params.Charge) > 0 {
		body.Add("charge", string(params.Charge))
	}

	params.AppendTo(body)

	refund := &stripe.Refund{}
	err := c.B.Call("POST", fmt.Sprintf("/refunds"), c.Key, body, &params.Params, refund)

	return refund, err
}
Beispiel #2
0
func (c Client) Get(id string, params *stripe.RefundParams) (*stripe.Refund, error) {
	body := &url.Values{}
	params.AppendTo(body)

	refund := &stripe.Refund{}
	err := c.B.Call("GET", fmt.Sprintf("/refunds/%v", id), c.Key, body, &params.Params, refund)

	return refund, err
}