Beispiel #1
0
func (c Client) New(params *stripe.AccountParams) (*stripe.Account, error) {
	body := &url.Values{
		"managed": {strconv.FormatBool(params.Managed)},
	}

	if len(params.Country) > 0 {
		body.Add("country", params.Country)
	}

	if len(params.Email) > 0 {
		body.Add("email", params.Email)
	}

	if len(params.DefaultCurrency) > 0 {
		body.Add("default_currency", params.DefaultCurrency)
	}

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

	if len(params.BusinessName) > 0 {
		body.Add("business_name", params.BusinessName)
	}

	if len(params.SupportPhone) > 0 {
		body.Add("support_phone", params.SupportPhone)
	}

	if params.LegalEntity != nil {
		params.LegalEntity.AppendDetails(body)
	}

	if params.TransferSchedule != nil {
		params.TransferSchedule.AppendDetails(body)
	}

	if params.BankAccount != nil {
		params.BankAccount.AppendDetails(body)
	}

	if params.TosAcceptance != nil {
		params.TosAcceptance.AppendDetails(body)
	}

	params.AppendTo(body)

	acct := &stripe.Account{}
	err := c.B.Call("POST", "/accounts", c.Key, body, &params.Params, acct)

	return acct, err
}
Beispiel #2
0
func (c Client) GetByID(id string, params *stripe.AccountParams) (*stripe.Account, error) {
	var body *url.Values
	var commonParams *stripe.Params

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

	account := &stripe.Account{}
	err := c.B.Call("GET", "/accounts/"+id, c.Key, body, commonParams, account)

	return account, err
}
Beispiel #3
0
func (c Client) Update(id string, params *stripe.AccountParams) (*stripe.Account, error) {
	var body *url.Values
	var commonParams *stripe.Params

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

		if len(params.Email) > 0 {
			body.Add("email", params.Email)
		}

		if len(params.DefaultCurrency) > 0 {
			body.Add("default_currency", params.DefaultCurrency)
		}

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

		if len(params.BusinessName) > 0 {
			body.Add("business_name", params.BusinessName)
		}

		if len(params.SupportPhone) > 0 {
			body.Add("support_phone", params.SupportPhone)
		}

		if params.LegalEntity != nil {
			params.LegalEntity.AppendDetails(body)
		}

		if params.TransferSchedule != nil {
			params.TransferSchedule.AppendDetails(body)
		}

		if params.BankAccount != nil {
			params.BankAccount.AppendDetails(body)
		}

		params.AppendTo(body)
	}

	acct := &stripe.Account{}
	err := c.B.Call("POST", "/accounts/"+id, c.Key, body, commonParams, acct)

	return acct, err
}