本文整理汇总了Golang中github.com/stripe/stripe-go.RecipientParams.AppendTo方法的典型用法代码示例。如果您正苦于以下问题:Golang RecipientParams.AppendTo方法的具体用法?Golang RecipientParams.AppendTo怎么用?Golang RecipientParams.AppendTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/stripe/stripe-go.RecipientParams
的用法示例。
在下文中一共展示了RecipientParams.AppendTo方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Update
func (c Client) Update(id string, params *stripe.RecipientParams) (*stripe.Recipient, error) {
var body *url.Values
var commonParams *stripe.Params
if params != nil {
commonParams = ¶ms.Params
body = &url.Values{}
if len(params.Name) > 0 {
body.Add("name", params.Name)
}
if params.Bank != nil {
if len(params.Bank.Token) > 0 {
body.Add("bank_account", params.Bank.Token)
} else {
params.Bank.AppendDetails(body)
}
}
if len(params.Token) > 0 {
body.Add("card", params.Token)
} else if params.Card != nil {
params.Card.AppendDetails(body, true)
}
if len(params.TaxID) > 0 {
body.Add("tax_id", params.TaxID)
}
if len(params.DefaultCard) > 0 {
body.Add("default_card", params.DefaultCard)
}
if len(params.Email) > 0 {
body.Add("email", params.Email)
}
if len(params.Desc) > 0 {
body.Add("description", params.Desc)
}
params.AppendTo(body)
}
recipient := &stripe.Recipient{}
err := c.B.Call("POST", "/recipients/"+id, c.Key, body, commonParams, recipient)
return recipient, err
}
示例2: Get
func (c Client) Get(id string, params *stripe.RecipientParams) (*stripe.Recipient, error) {
var body *url.Values
var commonParams *stripe.Params
if params != nil {
commonParams = ¶ms.Params
body = &url.Values{}
params.AppendTo(body)
}
recipient := &stripe.Recipient{}
err := c.B.Call("GET", "/recipients/"+id, c.Key, body, commonParams, recipient)
return recipient, err
}
示例3: New
func (c Client) New(params *stripe.RecipientParams) (*stripe.Recipient, error) {
body := &url.Values{
"name": {params.Name},
"type": {string(params.Type)},
}
if params.Bank != nil {
if len(params.Bank.Token) > 0 {
body.Add("bank_account", params.Bank.Token)
} else {
params.Bank.AppendDetails(body)
}
}
if len(params.Token) > 0 {
body.Add("card", params.Token)
} else if params.Card != nil {
params.Card.AppendDetails(body, true)
}
if len(params.TaxID) > 0 {
body.Add("tax_id", params.TaxID)
}
if len(params.Email) > 0 {
body.Add("email", params.Email)
}
if len(params.Desc) > 0 {
body.Add("description", params.Desc)
}
params.AppendTo(body)
recipient := &stripe.Recipient{}
err := c.B.Call("POST", "/recipients", c.Key, body, ¶ms.Params, recipient)
return recipient, err
}