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 }
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 }
func (c Client) Update(id string, params *stripe.CustomerParams) (*stripe.Customer, error) { var body *url.Values var commonParams *stripe.Params if params != nil { commonParams = ¶ms.Params 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.DefaultSource) > 0 { body.Add("default_source", params.DefaultSource) } params.AppendTo(body) if params.Shipping != nil { params.Shipping.AppendDetails(body) } } cust := &stripe.Customer{} err := c.B.Call("POST", "/customers/"+id, c.Key, body, commonParams, cust) return cust, err }