Ejemplo n.º 1
0
func (c Client) New(params *stripe.BankAccountParams) (*stripe.BankAccount, error) {

	body := &url.Values{}

	// Use token (if exists) or a dictionary containing a user’s bank account details.
	if len(params.Token) > 0 {
		body.Add("external_account", params.Token)
	} else {
		body.Add("external_account[object]", "bank_account")
		body.Add("external_account[country]", params.Country)
		body.Add("external_account[account_number]", params.Account)
		body.Add("external_account[routing_number]", params.Routing)
		body.Add("external_account[currency]", params.Currency)

		if params.Default {
			body.Add("external_account[default_for_currency]", strconv.FormatBool(params.Default))
		}
	}
	params.AppendTo(body)

	ba := &stripe.BankAccount{}
	err := c.B.Call("POST", fmt.Sprintf("/accounts/%v/bank_accounts", params.AccountID), c.Key, body, &params.Params, ba)

	return ba, err
}
Ejemplo n.º 2
0
func (c Client) Get(id string, params *stripe.BankAccountParams) (*stripe.BankAccount, error) {
	var body *url.Values
	var commonParams *stripe.Params

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

	ba := &stripe.BankAccount{}
	err := c.B.Call("GET", fmt.Sprintf("/accounts/%v/bank_accounts/%v", params.AccountID, id), c.Key, body, commonParams, ba)

	return ba, err
}
Ejemplo n.º 3
0
func (c Client) Update(id string, params *stripe.BankAccountParams) (*stripe.BankAccount, error) {
	var body *url.Values
	var commonParams *stripe.Params

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

		if params.Default {
			body.Add("default_for_currency", strconv.FormatBool(params.Default))
		}

		params.AppendTo(body)
	}

	ba := &stripe.BankAccount{}
	err := c.B.Call("POST", fmt.Sprintf("/accounts/%v/bank_accounts/%v", params.AccountID, id), c.Key, body, commonParams, ba)

	return ba, err
}