本文整理汇总了Golang中github.com/stripe/stripe-go.PlanParams类的典型用法代码示例。如果您正苦于以下问题:Golang PlanParams类的具体用法?Golang PlanParams怎么用?Golang PlanParams使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PlanParams类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: New
func (c Client) New(params *stripe.PlanParams) (*stripe.Plan, error) {
body := &url.Values{
"id": {params.ID},
"name": {params.Name},
"amount": {strconv.FormatUint(params.Amount, 10)},
"currency": {string(params.Currency)},
"interval": {string(params.Interval)},
}
if params.IntervalCount > 0 {
body.Add("interval_count", strconv.FormatUint(params.IntervalCount, 10))
}
if params.TrialPeriod > 0 {
body.Add("trial_period_days", strconv.FormatUint(params.TrialPeriod, 10))
}
if len(params.Statement) > 0 {
body.Add("statement_descriptor", params.Statement)
}
params.AppendTo(body)
plan := &stripe.Plan{}
err := c.B.Call("POST", "/plans", c.Key, body, ¶ms.Params, plan)
return plan, err
}
示例2: Get
func (c Client) Get(id string, params *stripe.PlanParams) (*stripe.Plan, error) {
var body *url.Values
var commonParams *stripe.Params
if params != nil {
commonParams = ¶ms.Params
body = &url.Values{}
params.AppendTo(body)
}
plan := &stripe.Plan{}
err := c.B.Call("GET", "/plans/"+id, c.Key, body, commonParams, plan)
return plan, err
}
示例3: Update
func (c Client) Update(id string, params *stripe.PlanParams) (*stripe.Plan, 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 len(params.Statement) > 0 {
body.Add("statement_descriptor", params.Statement)
}
params.AppendTo(body)
}
plan := &stripe.Plan{}
err := c.B.Call("POST", "/plans/"+id, c.Key, body, commonParams, plan)
return plan, err
}