Documentation ¶
Index ¶
- Constants
- type BankAccountObject
- type CardObject
- type CatalogItem
- type CatalogItems
- type Contact
- type Contacts
- type Customer
- type CustomerBalance
- type CustomerBalanceHistories
- type CustomerBalanceHistory
- type Customers
- type Discount
- type EmailDetail
- type EmailRequest
- type EmailResponse
- type EmailResponses
- type Event
- type Expand
- type File
- type Files
- type Filter
- type Invoice
- type Invoices
- type LineItem
- type PaymentMethod
- type PaymentSource
- type PendingLineItem
- type Plan
- type PlanData
- type Plans
- type Rate
- type Refund
- type SaveableCustomer
- type Sort
- type SortOrder
- type Subscription
- type SubscriptionAddon
- type Subscriptions
- type Tax
- type Transaction
- type Transactions
Constants ¶
const CustomersEndPoint = "/customers"
const EventsEndPoint = "/events"
const FilesEndPoint = "/files"
const InvoicesEndPoint = "/invoices"
const PlansEndPoint = "/plans/"
const RatesEndPoint = "/rates/"
const SubscriptionsEndPoint = "/subscriptions"
const TransactionsEndPoint = "/transactions"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BankAccountObject ¶
type BankAccountObject struct { Id int64 `json:"id,omitempty"` //The bank account’s unique ID Object string `json:"object,omitempty"` //bank_account BankName string `json:"bank_name,omitempty"` //Bank name Last4 string `json:"last4,omitempty"` //Last 4 digits of bank account RoutingNumber string `json:"routing_number,omitempty"` //Bank routing number Verified bool `json:"verified,omitempty"` //Whether the bank account has been verified with instant verification or micro-deposits Currency string `json:"currency,omitempty"` //3-letter ISO code }
type CardObject ¶
type CardObject struct { Id int64 `json:"id,omitempty"` //The card’s unique ID Object string `json:"object,omitempty"` //card Brand string `json:"brand,omitempty"` //Card brand Last4 string `json:"last4,omitempty"` //Last 4 digits of card ExpMonth int `json:"exp_month,omitempty"` //Expiry month ExpYear int `json:"exp_year,omitempty"` //Expiry year Funding string `json:"funding,omitempty"` //Funding instrument, can be credit, debit, prepaid, or unknown }
type CatalogItem ¶
type CatalogItem struct { Id string `json:"id,omitempty"` //The customer’s unique ID Object string `json:"object,omitempty"` //Contact name Name string `json:"name,omitempty"` //Email address Currency string `json:"currency,omitempty"` //When true the contact will be copied on any account communications UnitCost float64 `json:"unit_cost,omitempty"` //First address line Description string `json:"description,omitempty"` //Optional description Type string `json:"service,omitempty"` //Optional line item type. Used to group line items by type in reporting Taxes []Rate `json:"taxes,omitempty"` //Collection of Tax Rate Objects Discountable bool `json:"discountable,omitempty"` //Excludes amount from discounts when false Taxable bool `json:"taxable,omitempty"` //Excludes amount from taxes when false CreatedAt int64 `json:"created_at,omitempty"` //Timestamp when created MetaData map[string]interface{} `json:"metadata,omitempty"` //A hash of key/value pairs that can store additional information about this object. }
type CatalogItems ¶
type CatalogItems []CatalogItem
type Contact ¶
type Contact struct { Id int64 `json:"id,omitempty"` //The customer’s unique ID Name string `json:"name,omitempty"` //Contact name Email string `json:"email,omitempty"` //Email address Primary bool `json:"primary,omitempty"` //When true the contact will be copied on any account communications Address1 string `json:"address1,omitempty"` //First address line Address2 string `json:"address2,omitempty"` //Optional second address line City string `json:"city,omitempty"` //City State string `json:"state,omitempty"` //State or province PostalCode string `json:"postal_code,omitempty"` //Zip or postal code Country string `json:"country,omitempty"` //Two-letter ISO code CreatedAt int64 `json:"created_at,omitempty"` //Timestamp when created }
Contacts can be attached to customers. A contact could represent an additional email recipient for a customer, or perhaps an address in addition to the billing address, like a shipping address.
type Customer ¶
type Customer struct { SaveableCustomer Id int64 `json:"id,omitempty"` //The customer’s unique ID CollectionMode string `json:"collection_mode,omitempty"` //Invoice collection mode, auto or manual PaymentSourceRAW json.RawMessage `json:"payment_source,omitempty"` //Holds the raw payment json information for later parsing PaymentSource *PaymentSource `json:"-"` //Customer’s payment source, if attached PaymentSourceReady bool `json:"-"` //If true than run UnbundlePaymentSource() StatementPdfUrl string `json:"statement_pdf_url,omitempty"` //URL to download the latest account statement CreatedAt int64 `json:"created_at,omitempty"` //Timestamp when created }
Customers represent the entity you are billing, whether this is an organization or a individual. Each customer has a collection mode, automatic or manual. In automatic collection mode any invoices will be charged to your customer’s payment source. Currently we only support debit and credit cards as payment sources. Conversely, manual collection mode will let your customers pay each invoice issued with one of the payment methods you accept.
func (*Customer) BundlePaymentSource ¶
func (*Customer) UnbundlePaymentSource ¶
func (c *Customer) UnbundlePaymentSource() (*PaymentSource, error)
We only need to run this if c.PaymentSourceReady is false
type CustomerBalance ¶
type CustomerBalance struct { AvailableCredits int64 `json:"available_credits,omitempty"` PastDue bool `json:"past_due,omitempty"` Histories CustomerBalanceHistories `json:"history,omitempty"` TotalOutstanding int64 `json:"total_outstanding,omitempty"` }
type CustomerBalanceHistories ¶
type CustomerBalanceHistories []CustomerBalanceHistory
type CustomerBalanceHistory ¶
type Discount ¶
type Discount struct { Id int64 `json:"id,omitempty"` //The discount’s unique ID Amount float64 `json:"amount,omitempty"` //Discount amount Coupon Rate `json:"coupon,omitempty"` //Coupon the discount was computed from, if any Expires int64 `json:"expires,omitempty"` //Time until discount expires, if any }
Represents the application of a discount to an invoice or line item.
type EmailDetail ¶
type EmailRequest ¶
type EmailRequest struct { To []EmailDetail `json:"to,omitempty"` Bcc string `json:"bcc,omitempty"` Subject string `json:"subject,omitempty"` Message string `json:"message,omitempty"` }
type EmailResponse ¶
type EmailResponse struct { Id string `json:"id,omitempty"` State string `json:"state,omitempty"` RejectReason string `json:"reject_reason,omitempty"` Email string `json:"email,omitempty"` Template string `json:"template,omitempty"` Subject string `json:"subject,omitempty"` Message string `json:"message,omitempty"` Opens int64 `json:"opens,omitempty"` Clicks int64 `json:"clicks,omitempty"` CreatedAt int64 `json:"created_at,omitempty"` }
type EmailResponses ¶
type EmailResponses []EmailResponse
type Event ¶
type Event struct { Id int64 `json:"id,omitempty"` //The event’s unique ID Type string `json:"type,omitempty"` //Event type Timestamp int64 `json:"timestamp,omitempty"` Data json.RawMessage `json:"data,omitempty"` //Contains an object property with the object that was subject of the event and an optional previous property for object.updated events that is a hash of the old values that changed during the event }
type File ¶
type File struct { Id int64 `json:"id,omitempty"` //The file’s unique ID Object string `json:"object,omitempty"` //file Name string `json:"name,omitempty"` //Filename Size int `json:"size,omitempty"` //File size in bytes Type string `json:"type,omitempty"` //MIME Type Url string `json:"url,omitempty"` //File URL CreatedAt int64 `json:"created_at,omitempty"` //Timestamp when created }
Represents an external file.
type Filter ¶
type Filter struct {
// contains filtered or unexported fields
}
type Invoice ¶
type Invoice struct { Id int64 `json:"id,omitempty"` //The invoice’s unique ID Customer int64 `json:"customer,omitempty"` //Customer ID Name string `json:"name,omitempty"` //Invoice name for internal use, defaults to “Invoice” Number string `json:"number,omitempty"` //The reference number assigned to the invoice for use in the dashboard CollectionMode string `json:"collection_mode,omitempty"` //Invoice collection mode, auto or manual Currency string `json:"currency,omitempty"` //3-letter ISO code Draft bool `json:"draft,omitempty"` //When false, the invoice is considered outstanding, or when true, the invoice is a draft Closed bool `json:"closed,omitempty"` //When true, an invoice is closed and considered bad debt. No further payments are allowed. Paid bool `json:"paid,omitempty"` //Indicates whether an invoice has been paid in full Status string `json:"status,omitempty"` //Invoice state, one of draft, not_sent, sent, viewed, past_due, pending, paid Chase bool `json:"chase,omitempty"` //Whether chasing is enabled for the invoice NextChaseOn int64 `json:"next_chase_on,omitempty"` //Next scheduled chase AttemptCount int64 `json:"attempt_count,omitempty"` //# of payment attempts NextPaymentAttempt int64 `json:"next_payment_attempt,omitempty"` //Next scheduled charge attempt, when in automatic collection Subscription int64 `json:"subscription,omitempty"` //Subscription ID if invoice came from subscription Date int64 `json:"date,omitempty"` //Invoice date DueDate int64 `json:"due_date,omitempty"` //Date payment is due by PaymentTerms string `json:"payment_terms,omitempty"` //Payment terms for the invoice, i.e. “NET 30” Items []LineItem `json:"items,omitempty"` //Collection of Line Items Notes string `json:"notes,omitempty"` //Additional notes displayed on invoice Subtotal float64 `json:"subtotal,omitempty"` //Subtotal Discounts []Discount `json:"discounts,omitempty"` //Collection of Discounts Taxes []Tax `json:"taxes,omitempty"` //Collection of Taxes Total float64 `json:"total,omitempty"` //Total Balance float64 `json:"balance,omitempty"` //Balance owed Tags []string `json:"tags,omitempty"` //Invoice tags Url string `json:"url,omitempty"` //URL to view the invoice in the billing portal PaymentUrl string `json:"payment_url,omitempty"` //URL for the invoice payment page PdfUrl string `json:"pdf_url,omitempty"` //URL to download the invoice as a PDF CreatedAt int64 `json:"created_at,omitempty"` //Timestamp when created MetaData map[string]interface{} `json:"metadata,omitempty"` //A hash of key/value pairs that can store additional information about this object. CalculateTaxes bool `json:"calculate_taxes,omitempty"` // Flag to indicate whether taxes should be calculated on the invoice }
Todo Add Tags Object and Attachements Objects
type LineItem ¶
type LineItem struct { Id int64 `json:"id,omitempty"` //The line item’s unique ID CatalogItem string `json:"catalog_item,omitempty"` //Optional Catalog Item ID. Fills the line item with the name and pricing of the Catalog Item. Type string `json:"type,omitempty"` //Optional line item type. Used to group line items by type in reporting Name string `json:"name,omitempty"` //Title Description string `json:"description,omitempty"` //Optional description Quantity float64 `json:"quantity,omitempty"` //Quantity UnitCost float64 `json:"unit_cost,omitempty"` //Unit cost or rate Amount float64 `json:"amount,omitempty"` //Computed from quantity x unit_cost Discountable bool `json:"discountable,omitempty"` //Excludes amount from invoice discounts when false Discounts []Discount `json:"discounts,omitempty"` //Line item Discounts Taxable bool `json:"taxable,omitempty"` //Excludes amount from invoice taxes when false Taxes []Tax `json:"taxes,omitempty"` //Line item Taxes Plan string `json:"plan,omitempty"` //Plan ID, only present when type is plan Metadata map[string]interface{} `json:"metadata,omitempty"` //A hash of key/value pairs that can store additional information about this object. }
type PaymentMethod ¶
type PaymentMethod struct { Ach bool `json:"ach,omitempty"` Bitcoin bool `json:"bitcoin,omitempty"` Cash bool `json:"cash,omitempty"` Check bool `json:"check,omitempty"` CreditCard bool `json:"credit_card,omitempty"` Other bool `json:"other,omitempty"` Paypal bool `json:"paypal,omitempty"` WireTransfer bool `json:"wire_transfer,omitempty"` }
type PaymentSource ¶
type PaymentSource struct { CardObject *CardObject BankAccountObject *BankAccountObject Type string }
type PendingLineItem ¶
type PendingLineItem struct { Id int64 `json:"id,omitempty"` CatalogItem string `json:"catalog_item,omitempty"` //Optional Catalog Item ID. Fills the line item with the name and pricing of the Catalog Item. Type string `json:"type,omitempty"` //Optional line item type. Used to group line items by type in reporting Name string `json:"name,omitempty"` //Title Description string `json:"description,omitempty"` //Optional description Quantity float64 `json:"quantity,omitempty"` //Quantity UnitCost float64 `json:"unit_cost,omitempty"` //Unit cost or rate Discountable bool `json:"discountable,omitempty"` //Excludes amount from invoice discounts when false, defaults to `true Discounts []Discount `json:"discounts,omitempty"` //Line item Discounts Taxable bool `json:"taxable,omitempty"` //Excludes amount from invoice taxes when false, defaults to `true Taxes []Tax `json:"taxes,omitempty"` //Line item Taxes Metadata map[string]interface{} `json:"metadata,omitempty"` //A hash of key/value pairs that can store additional information about this object. }
Metered billing on Invoiced allows you to bill customers for charges that occur during a billing cycle outside of their ordinary subscription. These charges are called pending line items. A pending line item is a Line Item that has been attached to a customer, but not billed yet. Pending line items will be swept up by the next invoice that is triggered for the customer. This happens automatically with subscription invoices or when triggering an invoice manually.
type PlanData ¶
type PlanData struct { CreatedAt int64 `json:"created_at,omitempty"` UpdatedAt int64 `json:"updated_at,omitempty"` Id int64 `json:"id,omitempty"` Name string `json:"name,omitempty"` Theme int64 `json:"theme,omitempty"` Chase bool `json:"chase,omitempty"` Amount bool `json:"amount,omitempty"` Interval string `json:"interval,omitempty"` IntervalCount int64 `json:"interval_count,omitempty"` Description string `json:"description,omitempty"` Type string `json:"type,omitempty"` Note string `json:"note,omitempty"` Terms string `json:"terms,omitempty"` SendInvoiceAfterRenewal string `json:"send_invoice_after_renewal,omitempty"` DisabledPaymentMethods string `json:"disabled_payment_methods,omitempty"` }
type Rate ¶
type Rate struct { CreatedAt int64 `json:"created_at,omitempty"` UpdatedAt int64 `json:"updated_at,omitempty"` Id string `json:"id,omitempty"` IsPercent bool `json:"is_percent,omitempty"` MetaData interface{} `json:"metadata,omitempty"` Name string `json:"name,omitempty"` Value float64 `json:"value,omitempty"` Object string `json:"object,omitempty"` }
type Refund ¶
type Refund struct {
Amount float64 `json:"amount,omitempty"` //Amount to refund - required
}
type SaveableCustomer ¶
type SaveableCustomer struct { Name string `json:"name,omitempty"` //Customer name Number string `json:"number,omitempty"` //A unique ID to help tie your customer to your external systems Email string `json:"email,omitempty"` //Email address AutoPay bool `json:"autopay,omitempty"` //AutoPay enabled? PaymentTerms string `json:"payment_terms,omitempty"` //Payment terms used for manual collection mode, i.e. “NET 30” Taxes []Rate `json:"taxes,omitempty"` //Collection of Tax Rate IDs Type string `json:"type,omitempty"` //Organization type, company or person AttentionTo string `json:"attention_to,omitempty"` //Used for ATTN: address line if company Address1 string `json:"address1,omitempty"` //First address line Address2 string `json:"address2,omitempty"` //Optional second address line City string `json:"city,omitempty"` //City State string `json:"state,omitempty"` //State or province PostalCode string `json:"postal_code,omitempty"` //Zip or postal code Country string `json:"country,omitempty"` //Two-letter ISO code TaxID string `json:"taxid,omitempty"` //Tax ID to be displayed on documents Phone string `json:"phone,omitempty"` //Phone # Notes string `json:"notes,omitempty"` //Private customer notes MetaData map[string]interface{} `json:"metadata,omitempty"` //A hash of key/value pairs that can store additional information about this object. StripeToken string `json:"stripe_token,omitempty"` //A Stripe credit card token to set as the customer's default payment source }
SaveableCustomer includes the subset of Customer fields which are valid for customer creation/update requests
type Subscription ¶
type Subscription struct { Id int64 `json:"id,omitempty"` //The subscription’s unique ID Customer int64 `json:"customer,omitempty"` //Associated Customer Plan string `json:"plan,omitempty"` //Plan ID StartDate int64 `json:"start_date,omitempty"` //Timestamp subscription starts (or started) Quantity int64 `json:"quantity,omitempty"` //Plan quantity. Defaults to 1 Cycles int64 `json:"cycles,omitempty"` //Number of billing cycles the subscription runs for, when null runs until canceled (default). PeriodStart int64 `json:"period_start,omitempty"` //Start of the current billing period PeriodEnd int64 `json:"period_end,omitempty"` //End of the current billing period ContractPeriodStart int64 `json:"contract_period_start,omitempty"` //Start of current contract period ContractPeriodEnd int64 `json:"contract_period_end,omitempty"` //End of current contract period RenewsNext int64 `json:"renews_next,omitempty"` //Date of next automatic renewal Status string `json:"status,omitempty"` //Subscription status, one of not_started, active, past_due, finished Addons []SubscriptionAddon `json:"addons,omitempty"` //Collection of Subscription Addons Discounts []Discount `json:"discount,omitempty"` //Collection of Coupon IDs Taxes []Rate `json:"taxes,omitempty"` //Collection of Tax Rate IDs Url string `json:"url,omitempty"` //URL to manage the subscription in the billing portal CreatedAt int64 `json:"created_at,omitempty"` //Timestamp when created MetaData map[string]interface{} `json:"metadata,omitempty"` //A hash of key/value pairs that can store additional information about this object. Prorate bool `json:"prorate,omitempty"` ContractRenewalMode string `json:"contract_renewal_mode,omitempty"` ShipTo struct { Address1 string `json:"address1,omitempty"` Address2 string `json:"address2,omitempty"` AttentionTo string `json:"attention_to,omitempty"` City string `json:"city,omitempty"` Country string `json:"country,omitempty"` Name string `json:"name,omitempty"` PostalCode string `json:"postal_code,omitempty"` State string `json:"state,omitempty"` } `json:"ship_to,omitempty"` // Shipping address }
func (*Subscription) String ¶
func (s *Subscription) String() string
type SubscriptionAddon ¶
type SubscriptionAddon struct { Id int64 `json:"id,omitempty"` //The subscription’s unique ID CatalogItem string `json:"catalog_item,omitempty"` //Catalog Item ID Plan string `json:"plan,omitempty"` //The Subscription's Plan ID Quantity int64 `json:"quantity,omitempty"` //Quantity CreatedAt int64 `json:"created_at,omitempty"` //Timestamp when created }
type Subscriptions ¶
type Subscriptions []Subscription
type Tax ¶
type Tax struct { Id int64 `json:"id,omitempty"` //The tax’s unique ID Amount float64 `json:"amount,omitempty"` //Tax amount TaxRate Rate `json:"tax_rate,omitempty"` //Tax Rate the tax was computed from, if any }
Represents the application of tax to an invoice or line item.
type Transaction ¶
type Transaction struct { Id int64 `json:"id,omitempty"` Customer int64 `json:"customer,omitempty"` //Customer ID, required if invoice ID is not supplied Invoice int64 `json:"invoice,omitempty"` //Invoice ID, if any Type string `json:"type,omitempty"` //Transaction type, charge, payment, refund, or adjustment - required Date int64 `json:"date,omitempty"` //Transaction date, defaults to current timestamp Method string `json:"method,omitempty"` //Payment instrument used to facilitate transaction, defaults to other Status string `json:"status,omitempty"` //Transaction status, one of succeeded, pending, or failed, defaults to succeeded Gateway string `json:"gateway,omitempty"` //Payment gateway that processed the transaction, if any GatewayId string `json:"gateway_id,omitempty"` //Transaction ID from the payment gateway, or check # if method is check Currency string `json:"currency,omitempty"` //3-letter ISO code Amount float64 `json:"amount,omitempty"` //Transaction amount Fee float64 `json:"fee,omitempty"` //Processing fees Notes string `json:"notes,omitempty"` //Internal notes FailureReason string `json:"failure_reason,omitempty"` //Failure message from the payment gateway (only available when status = failed) ParentTransaction int64 `json:"parent_transaction,omitempty"` //ID of the original transaction for refunds PdfUrl string `json:"pdf_url,omitempty"` //URL to download the invoice as a PDF CreatedAt int64 `json:"created_at,omitempty"` //Timestamp when created MetaData map[string]interface{} `json:"metadata,omitempty"` //A hash of key/value pairs that can store additional information about this object. }
type Transactions ¶
type Transactions []Transaction