本文整理汇总了Golang中github.com/stripe/stripe-go.InvoiceItemParams类的典型用法代码示例。如果您正苦于以下问题:Golang InvoiceItemParams类的具体用法?Golang InvoiceItemParams怎么用?Golang InvoiceItemParams使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了InvoiceItemParams类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Update
func (c Client) Update(id string, params *stripe.InvoiceItemParams) (*stripe.InvoiceItem, error) {
var body *stripe.RequestValues
var commonParams *stripe.Params
if params != nil {
commonParams = ¶ms.Params
body = &stripe.RequestValues{}
if params.Amount != 0 {
body.Add("amount", strconv.FormatInt(params.Amount, 10))
}
if len(params.Desc) > 0 {
body.Add("description", params.Desc)
}
if params.Discountable {
body.Add("discountable", strconv.FormatBool(true))
}
params.AppendTo(body)
}
invoiceItem := &stripe.InvoiceItem{}
err := c.B.Call("POST", "/invoiceitems/"+id, c.Key, body, commonParams, invoiceItem)
return invoiceItem, err
}
示例2: New
func (c Client) New(params *stripe.InvoiceItemParams) (*stripe.InvoiceItem, error) {
body := &stripe.RequestValues{}
body.Add("customer", params.Customer)
body.Add("amount", strconv.FormatInt(params.Amount, 10))
body.Add("currency", string(params.Currency))
if len(params.Invoice) > 0 {
body.Add("invoice", params.Invoice)
}
if len(params.Desc) > 0 {
body.Add("description", params.Desc)
}
if len(params.Sub) > 0 {
body.Add("subscription", params.Sub)
}
if params.Discountable {
body.Add("discountable", strconv.FormatBool(true))
}
params.AppendTo(body)
invoiceItem := &stripe.InvoiceItem{}
err := c.B.Call("POST", "/invoiceitems", c.Key, body, ¶ms.Params, invoiceItem)
return invoiceItem, err
}
示例3: Get
func (c Client) Get(id string, params *stripe.InvoiceItemParams) (*stripe.InvoiceItem, error) {
var body *stripe.RequestValues
var commonParams *stripe.Params
if params != nil {
commonParams = ¶ms.Params
body = &stripe.RequestValues{}
params.AppendTo(body)
}
invoiceItem := &stripe.InvoiceItem{}
err := c.B.Call("GET", "/invoiceitems/"+id, c.Key, body, commonParams, invoiceItem)
return invoiceItem, err
}