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 }
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 }
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 }