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 }
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 }
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 }
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 }
func (c Client) Update(id string, params *stripe.InvoiceParams) (*stripe.Invoice, error) { var body *url.Values token := c.Key var commonParams *stripe.Params if params != nil { commonParams = ¶ms.Params body = &url.Values{} 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)) } 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)) } params.AppendTo(body) } invoice := &stripe.Invoice{} err := c.B.Call("POST", "/invoices/"+id, token, body, commonParams, invoice) return invoice, err }