Exemplo n.º 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("refund_transfer", strconv.FormatBool(params.Transfer))
	}

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

	params.AppendTo(body)

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

	return refund, err
}
Exemplo n.º 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
}
Exemplo n.º 3
0
func (c Client) Update(id string, params *stripe.RefundParams) (*stripe.Refund, error) {
	body := &url.Values{}

	params.AppendTo(body)

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

	return refund, err
}
Exemplo n.º 4
0
func (c Client) Get(id string, params *stripe.RefundParams) (*stripe.Refund, error) {
	if params == nil {
		return nil, fmt.Errorf("params cannot be nil, and params.Charge must be set")
	}

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

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

	return refund, err
}
Exemplo n.º 5
0
func (c Client) Get(id string, params *stripe.RefundParams) (*stripe.Refund, error) {
	var body *stripe.RequestValues
	var commonParams *stripe.Params

	if params != nil {
		commonParams = &params.Params
		body = &stripe.RequestValues{}
		params.AppendTo(body)
	}

	refund := &stripe.Refund{}
	err := c.B.Call("GET", "/refunds/"+id, c.Key, body, commonParams, refund)

	return refund, err
}