本文整理汇总了Golang中github.com/stripe/stripe-go.BankAccountParams类的典型用法代码示例。如果您正苦于以下问题:Golang BankAccountParams类的具体用法?Golang BankAccountParams怎么用?Golang BankAccountParams使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了BankAccountParams类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: New
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, ¶ms.Params, ba)
return ba, err
}
开发者ID:outdoorsy,项目名称:stripe-go,代码行数:25,代码来源:client.go
示例2: Update
func (c Client) Update(id string, params *stripe.BankAccountParams) (*stripe.BankAccount, error) {
var body *stripe.RequestValues
var commonParams *stripe.Params
if params != nil {
commonParams = ¶ms.Params
body = &stripe.RequestValues{}
if params.Default {
body.Add("default_for_currency", strconv.FormatBool(params.Default))
}
params.AppendTo(body)
}
ba := &stripe.BankAccount{}
var err error
if len(params.Customer) > 0 {
err = c.B.Call("POST", fmt.Sprintf("/customers/%v/bank_accounts/%v", params.Customer, id), c.Key, body, commonParams, ba)
} else if len(params.AccountID) > 0 {
err = c.B.Call("POST", fmt.Sprintf("/accounts/%v/bank_accounts/%v", params.AccountID, id), c.Key, body, commonParams, ba)
} else {
err = errors.New("Invalid bank account params: either Customer or AccountID need to be set")
}
return ba, err
}
开发者ID:captain401,项目名称:stripe-go,代码行数:28,代码来源:client.go
示例3: New
func (c Client) New(params *stripe.BankAccountParams) (*stripe.BankAccount, error) {
body := &stripe.RequestValues{}
isCustomer := len(params.Customer) > 0
var sourceType string
if isCustomer {
sourceType = "source"
} else {
sourceType = "external_account"
}
// Use token (if exists) or a dictionary containing a user’s bank account details.
if len(params.Token) > 0 {
body.Add(sourceType, params.Token)
if params.Default {
body.Add("default_for_currency", strconv.FormatBool(params.Default))
}
} else {
body.Add(sourceType+"[object]", "bank_account")
body.Add(sourceType+"[country]", params.Country)
body.Add(sourceType+"[account_number]", params.Account)
body.Add(sourceType+"[currency]", params.Currency)
if isCustomer {
body.Add(sourceType+"[account_holder_name]", params.AccountHolderName)
body.Add(sourceType+"[account_holder_type]", params.AccountHolderType)
}
if len(params.Routing) > 0 {
body.Add(sourceType+"[routing_number]", params.Routing)
}
if params.Default {
body.Add(sourceType+"[default_for_currency]", strconv.FormatBool(params.Default))
}
}
params.AppendTo(body)
ba := &stripe.BankAccount{}
var err error
if isCustomer {
err = c.B.Call("POST", fmt.Sprintf("/customers/%v/sources", params.Customer), c.Key, body, ¶ms.Params, ba)
} else {
err = c.B.Call("POST", fmt.Sprintf("/accounts/%v/bank_accounts", params.AccountID), c.Key, body, ¶ms.Params, ba)
}
return ba, err
}
开发者ID:captain401,项目名称:stripe-go,代码行数:50,代码来源:client.go
示例4: Get
func (c Client) Get(id string, params *stripe.BankAccountParams) (*stripe.BankAccount, error) {
var body *url.Values
var commonParams *stripe.Params
if params != nil {
commonParams = ¶ms.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
}
开发者ID:outdoorsy,项目名称:stripe-go,代码行数:15,代码来源:client.go
示例5: Update
func (c Client) Update(id string, params *stripe.BankAccountParams) (*stripe.BankAccount, error) {
var body *url.Values
var commonParams *stripe.Params
if params != nil {
commonParams = ¶ms.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
}
开发者ID:outdoorsy,项目名称:stripe-go,代码行数:20,代码来源:client.go
示例6: Get
func (c Client) Get(id string, params *stripe.BankAccountParams) (*stripe.BankAccount, error) {
var body *stripe.RequestValues
var commonParams *stripe.Params
if params != nil {
commonParams = ¶ms.Params
body = &stripe.RequestValues{}
params.AppendTo(body)
}
ba := &stripe.BankAccount{}
var err error
if len(params.Customer) > 0 {
err = c.B.Call("GET", fmt.Sprintf("/customers/%v/bank_accounts/%v", params.AccountID, id), c.Key, body, commonParams, ba)
} else if len(params.AccountID) > 0 {
err = c.B.Call("GET", fmt.Sprintf("/accounts/%v/bank_accounts/%v", params.AccountID, id), c.Key, body, commonParams, ba)
} else {
err = errors.New("Invalid bank account params: either Customer or AccountID need to be set")
}
return ba, err
}
开发者ID:captain401,项目名称:stripe-go,代码行数:23,代码来源:client.go
注:本文中的github.com/stripe/stripe-go.BankAccountParams类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论