billing.go 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. package types
  2. import (
  3. "github.com/google/uuid"
  4. )
  5. // Stripe types
  6. // PaymentMethod is a subset of the Stripe PaymentMethod type,
  7. // with only the fields used in the dashboard
  8. type PaymentMethod = struct {
  9. ID string `json:"id"`
  10. DisplayBrand string `json:"display_brand"`
  11. Last4 string `json:"last4"`
  12. ExpMonth int64 `json:"exp_month"`
  13. ExpYear int64 `json:"exp_year"`
  14. Default bool `json:"is_default"`
  15. }
  16. // Metronome Types
  17. // Customer represents a customer in Metronome
  18. type Customer struct {
  19. ID uuid.UUID `json:"id"`
  20. Name string `json:"name"` // Required. Name of the customer
  21. Aliases []string `json:"ingest_aliases"` // Aliases that can be used to refer to this customer in usage events
  22. BillingConfig BillingConfig `json:"billing_config,omitempty"`
  23. CustomFields map[string]string `json:"custom_fields,omitempty"`
  24. }
  25. // CustomerArchiveRequest will archive the customer in Metronome.
  26. type CustomerArchiveRequest struct {
  27. CustomerID uuid.UUID `json:"id"`
  28. }
  29. // BillingConfig is the configuration for the billing provider (Stripe, etc.)
  30. type BillingConfig struct {
  31. BillingProviderType string `json:"billing_provider_type"` // Required. Can be any of "aws_marketplace", "stripe", "netsuite", "custom", "azure_marketplace", "quickbooks_online", or "workday"
  32. BillingProviderCustomerID string `json:"billing_provider_customer_id"`
  33. StripeCollectionMethod string `json:"stripe_collection_method"` // Can be any of "charge_automatically" or "send_invoice"
  34. }
  35. // AddCustomerPlanRequest represents a request to add a customer plan with specific details.
  36. type AddCustomerPlanRequest struct {
  37. PlanID uuid.UUID `json:"plan_id"` // Required. The customer ID, plan ID, and date range for the plan to be applied.
  38. StartingOn string `json:"starting_on"` // Required. RFC 3339 timestamp for when the plan becomes active for this customer. Must be at 0:00 UTC (midnight).
  39. EndingBefore string `json:"ending_before,omitempty"` // Optional. RFC 3339 timestamp for when the plan ends (exclusive) for this customer. Must be at 0:00 UTC (midnight).
  40. NetPaymentTermsDays int `json:"net_payment_terms_days,omitempty"` // Number of days after issuance of invoice after which the invoice is due (e.g., Net 30).
  41. }
  42. // AddCustomerPlanResponse is a response to the add customer plan request. Returns customer-plan relationship id.
  43. type AddCustomerPlanResponse struct {
  44. Data struct {
  45. CustomerPlanID uuid.UUID `json:"id"`
  46. } `json:"data"`
  47. }
  48. // EndCustomerPlanRequest represents a request to end the plan for a specific customer.
  49. type EndCustomerPlanRequest struct {
  50. EndingBefore string `json:"ending_before,omitempty"` // RFC 3339 timestamp for when the plan ends (exclusive) for this customer. Must be at 0:00 UTC (midnight).
  51. VoidInvoices bool `json:"void_invoices"` // If true, plan end date can be before the last finalized invoice date. Any invoices generated after the plan end date will be voided.
  52. VoidStripeInvoices bool `json:"void_stripe_invoices"` // Will void Stripe invoices if VoidInvoices is set to true. Drafts will be deleted.
  53. }