本文整理汇总了Golang中github.com/stripe/stripe-go.CardParams.AppendDetails方法的典型用法代码示例。如果您正苦于以下问题:Golang CardParams.AppendDetails方法的具体用法?Golang CardParams.AppendDetails怎么用?Golang CardParams.AppendDetails使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/stripe/stripe-go.CardParams
的用法示例。
在下文中一共展示了CardParams.AppendDetails方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Update
func (c Client) Update(id string, params *stripe.CardParams) (*stripe.Card, error) {
body := &url.Values{}
params.AppendDetails(body, false)
params.AppendTo(body)
card := &stripe.Card{}
var err error
if len(params.Customer) > 0 {
err = c.B.Call("POST", fmt.Sprintf("/customers/%v/cards/%v", params.Customer, id), c.Key, body, ¶ms.Params, card)
} else if len(params.Recipient) > 0 {
err = c.B.Call("POST", fmt.Sprintf("/recipients/%v/cards/%v", params.Recipient, id), c.Key, body, ¶ms.Params, card)
} else {
err = errors.New("Invalid card params: either customer or recipient need to be set")
}
return card, err
}
示例2: New
func (c Client) New(params *stripe.CardParams) (*stripe.Card, error) {
body := &stripe.RequestValues{}
params.AppendDetails(body, true)
params.AppendTo(body)
card := &stripe.Card{}
var err error
if len(params.Account) > 0 {
if params.Default {
body.Add("default_for_currency", strconv.FormatBool(params.Default))
}
err = c.B.Call("POST", fmt.Sprintf("/accounts/%v/external_accounts", params.Account), c.Key, body, ¶ms.Params, card)
} else if len(params.Customer) > 0 {
err = c.B.Call("POST", fmt.Sprintf("/customers/%v/cards", params.Customer), c.Key, body, ¶ms.Params, card)
} else if len(params.Recipient) > 0 {
err = c.B.Call("POST", fmt.Sprintf("/recipients/%v/cards", params.Recipient), c.Key, body, ¶ms.Params, card)
} else {
err = errors.New("Invalid card params: either account, customer or recipient need to be set")
}
return card, err
}