Пример #1
0
func (c Client) Get(id string, params *stripe.TransferParams) (*stripe.Transfer, error) {
	var body *url.Values
	var commonParams *stripe.Params

	if params != nil {
		commonParams = &params.Params
		body = &url.Values{}
		params.AppendTo(body)
	}

	transfer := &stripe.Transfer{}
	err := c.B.Call("GET", "/transfers/"+id, c.Key, body, commonParams, transfer)

	return transfer, err
}
Пример #2
0
func (c Client) Cancel(id string, params *stripe.TransferParams) (*stripe.Transfer, error) {
	var body *url.Values
	var commonParams *stripe.Params

	if params != nil {
		commonParams = &params.Params

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

	transfer := &stripe.Transfer{}
	err := c.B.Call("POST", fmt.Sprintf("/transfers/%v/cancel", id), c.Key, body, commonParams, transfer)

	return transfer, err
}
Пример #3
0
func (c Client) New(params *stripe.TransferParams) (*stripe.Transfer, error) {
	body := &url.Values{
		"amount":   {strconv.FormatInt(params.Amount, 10)},
		"currency": {string(params.Currency)},
	}

	if len(params.Recipient) > 0 {
		body.Add("recipient", params.Recipient)
	}

	if len(params.Bank) > 0 {
		body.Add("bank_account", params.Bank)
	} else if len(params.Card) > 0 {
		body.Add("card", params.Card)
	}

	if len(params.Desc) > 0 {
		body.Add("description", params.Desc)
	}

	if len(params.Statement) > 0 {
		body.Add("statement_descriptor", params.Statement)
	}

	if len(params.Dest) > 0 {
		body.Add("destination", params.Dest)
	}

	if len(params.SourceTx) > 0 {
		body.Add("source_transaction", params.SourceTx)
	}

	if params.Fee > 0 {
		body.Add("application_fee", strconv.FormatUint(params.Fee, 10))
	}
	params.AppendTo(body)

	transfer := &stripe.Transfer{}
	err := c.B.Call("POST", "/transfers", c.Key, body, &params.Params, transfer)

	return transfer, err
}
Пример #4
0
func (c Client) Update(id string, params *stripe.TransferParams) (*stripe.Transfer, error) {
	var body *url.Values
	var commonParams *stripe.Params

	if params != nil {
		commonParams = &params.Params

		body = &url.Values{}

		if len(params.Desc) > 0 {
			body.Add("description", params.Desc)
		}

		params.AppendTo(body)
	}

	transfer := &stripe.Transfer{}
	err := c.B.Call("POST", "/transfers/"+id, c.Key, body, commonParams, transfer)

	return transfer, err
}