本文整理汇总了Golang中github.com/stripe/stripe-go.CustomerParams类的典型用法代码示例。如果您正苦于以下问题:Golang CustomerParams类的具体用法?Golang CustomerParams怎么用?Golang CustomerParams使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CustomerParams类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: New
func (c Client) New(params *stripe.CustomerParams) (*stripe.Customer, error) {
var body *url.Values
var commonParams *stripe.Params
if params != nil {
body = &url.Values{}
if params.Balance != 0 {
body.Add("account_balance", strconv.FormatInt(params.Balance, 10))
}
if params.Source != nil {
params.Source.AppendDetails(body, true)
}
if len(params.Desc) > 0 {
body.Add("description", params.Desc)
}
if len(params.Coupon) > 0 {
body.Add("coupon", params.Coupon)
}
if len(params.Email) > 0 {
body.Add("email", params.Email)
}
if len(params.Plan) > 0 {
body.Add("plan", params.Plan)
if params.Quantity > 0 {
body.Add("quantity", strconv.FormatUint(params.Quantity, 10))
}
if params.TrialEnd > 0 {
body.Add("trial_end", strconv.FormatInt(params.TrialEnd, 10))
}
}
if params.Shipping != nil {
params.Shipping.AppendDetails(body)
}
commonParams = ¶ms.Params
params.AppendTo(body)
}
cust := &stripe.Customer{}
err := c.B.Call("POST", "/customers", c.Key, body, commonParams, cust)
return cust, err
}
示例2: Update
func (c Client) Update(id string, params *stripe.CustomerParams) (*stripe.Customer, error) {
var body *stripe.RequestValues
var commonParams *stripe.Params
if params != nil {
commonParams = ¶ms.Params
body = &stripe.RequestValues{}
if params.Balance != 0 {
body.Add("account_balance", strconv.FormatInt(params.Balance, 10))
} else if params.BalanceZero {
body.Add("account_balance", "0")
}
if params.Source != nil {
params.Source.AppendDetails(body, true)
}
if len(params.Desc) > 0 {
body.Add("description", params.Desc)
}
if len(params.Coupon) > 0 {
body.Add("coupon", params.Coupon)
}
if len(params.Email) > 0 {
body.Add("email", params.Email)
}
if len(params.DefaultSource) > 0 {
body.Add("default_source", params.DefaultSource)
}
params.AppendTo(body)
if params.Shipping != nil {
params.Shipping.AppendDetails(body)
}
if len(params.BusinessVatID) > 0 {
body.Add("business_vat_id", params.BusinessVatID)
}
}
cust := &stripe.Customer{}
err := c.B.Call("POST", "/customers/"+id, c.Key, body, commonParams, cust)
return cust, err
}
示例3: Get
func (c Client) Get(id string, params *stripe.CustomerParams) (*stripe.Customer, error) {
var body *url.Values
var commonParams *stripe.Params
if params != nil {
body = &url.Values{}
commonParams = ¶ms.Params
params.AppendTo(body)
}
cust := &stripe.Customer{}
err := c.B.Call("GET", "/customers/"+id, c.Key, body, commonParams, cust)
return cust, err
}