本文整理汇总了Golang中github.com/stripe/stripe-go.InvoiceParams.AppendTo方法的典型用法代码示例。如果您正苦于以下问题:Golang InvoiceParams.AppendTo方法的具体用法?Golang InvoiceParams.AppendTo怎么用?Golang InvoiceParams.AppendTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/stripe/stripe-go.InvoiceParams
的用法示例。
在下文中一共展示了InvoiceParams.AppendTo方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: New
func (c Client) New(params *stripe.InvoiceParams) (*stripe.Invoice, error) {
body := &url.Values{
"customer": {params.Customer},
}
if len(params.Desc) > 0 {
body.Add("description", params.Desc)
}
if len(params.Statement) > 0 {
body.Add("statement_descriptor", params.Statement)
}
if len(params.Sub) > 0 {
body.Add("subscription", params.Sub)
}
params.AppendTo(body)
token := c.Key
if params.Fee > 0 {
body.Add("application_fee", strconv.FormatUint(params.Fee, 10))
}
if params.TaxPercent > 0 {
body.Add("tax_percent", strconv.FormatFloat(params.TaxPercent, 'f', 2, 64))
}
invoice := &stripe.Invoice{}
err := c.B.Call("POST", "/invoices", token, body, ¶ms.Params, invoice)
return invoice, err
}
示例2: GetNext
func (c Client) GetNext(params *stripe.InvoiceParams) (*stripe.Invoice, error) {
body := &stripe.RequestValues{}
body.Add("customer", params.Customer)
if len(params.Sub) > 0 {
body.Add("subscription", params.Sub)
}
if len(params.SubPlan) > 0 {
body.Add("subscription_plan", params.SubPlan)
}
if params.SubNoProrate {
body.Add("subscription_prorate", strconv.FormatBool(false))
}
if params.SubProrationDate > 0 {
body.Add("subscription_proration_date", strconv.FormatInt(params.SubProrationDate, 10))
}
if params.SubQuantity > 0 {
body.Add("subscription_quantity", strconv.FormatUint(params.SubQuantity, 10))
}
if params.SubTrialEnd > 0 {
body.Add("subscription_trial_end", strconv.FormatInt(params.SubTrialEnd, 10))
}
params.AppendTo(body)
invoice := &stripe.Invoice{}
err := c.B.Call("GET", "/invoices/upcoming", c.Key, body, ¶ms.Params, invoice)
return invoice, err
}
示例3: Update
func (c Client) Update(id string, params *stripe.InvoiceParams) (*stripe.Invoice, error) {
var body *stripe.RequestValues
token := c.Key
var commonParams *stripe.Params
if params != nil {
commonParams = ¶ms.Params
body = &stripe.RequestValues{}
if len(params.Desc) > 0 {
body.Add("description", params.Desc)
}
if len(params.Statement) > 0 {
body.Add("statement_descriptor", params.Statement)
}
if len(params.Sub) > 0 {
body.Add("subscription", params.Sub)
}
if params.Closed {
body.Add("closed", strconv.FormatBool(true))
} else if params.NoClosed {
body.Add("closed", strconv.FormatBool(false))
}
if params.Forgive {
body.Add("forgiven", strconv.FormatBool(true))
}
if params.Fee > 0 {
body.Add("application_fee", strconv.FormatUint(params.Fee, 10))
}
if params.TaxPercent > 0 {
body.Add("tax_percent", strconv.FormatFloat(params.TaxPercent, 'f', 2, 64))
} else if params.TaxPercentZero {
body.Add("tax_percent", "0")
}
params.AppendTo(body)
}
invoice := &stripe.Invoice{}
err := c.B.Call("POST", "/invoices/"+id, token, body, commonParams, invoice)
return invoice, err
}
示例4: Pay
func (c Client) Pay(id string, params *stripe.InvoiceParams) (*stripe.Invoice, error) {
var body *url.Values
var commonParams *stripe.Params
if params != nil {
commonParams = ¶ms.Params
body = &url.Values{}
params.AppendTo(body)
}
invoice := &stripe.Invoice{}
err := c.B.Call("POST", fmt.Sprintf("/invoices/%v/pay", id), c.Key, body, commonParams, invoice)
return invoice, err
}
示例5: Get
func (c Client) Get(id string, params *stripe.InvoiceParams) (*stripe.Invoice, error) {
var body *url.Values
var commonParams *stripe.Params
if params != nil {
commonParams = ¶ms.Params
body = &url.Values{}
params.AppendTo(body)
}
invoice := &stripe.Invoice{}
err := c.B.Call("GET", "/invoices/"+id, c.Key, body, commonParams, invoice)
return invoice, err
}
示例6: GetNext
func (c Client) GetNext(params *stripe.InvoiceParams) (*stripe.Invoice, error) {
body := &url.Values{
"customer": {params.Customer},
}
if len(params.Sub) > 0 {
body.Add("subscription", params.Sub)
}
params.AppendTo(body)
invoice := &stripe.Invoice{}
err := c.B.Call("GET", "/invoices/upcoming", c.Key, body, ¶ms.Params, invoice)
return invoice, err
}