chargebee

package
v1.0.53 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 5, 2026 License: AGPL-3.0 Imports: 34 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BillingAddress

type BillingAddress struct {
	FirstName string `json:"first_name"`
	LastName  string `json:"last_name"`
	Email     string `json:"email"`
	Company   string `json:"company"`
	Phone     string `json:"phone"`
	Line1     string `json:"line1"`
	Line2     string `json:"line2"`
	Line3     string `json:"line3"`
	City      string `json:"city"`
	State     string `json:"state"`
	StateCode string `json:"state_code"`
	Zip       string `json:"zip"`
	Country   string `json:"country"`
}

BillingAddress represents billing address in customer response

type BillingAddressRequest

type BillingAddressRequest struct {
	FirstName string `json:"first_name,omitempty"`
	LastName  string `json:"last_name,omitempty"`
	Email     string `json:"email,omitempty"`
	Company   string `json:"company,omitempty"`
	Phone     string `json:"phone,omitempty"`
	Line1     string `json:"line1,omitempty"`
	Line2     string `json:"line2,omitempty"`
	Line3     string `json:"line3,omitempty"`
	City      string `json:"city,omitempty"`
	State     string `json:"state,omitempty"`
	StateCode string `json:"state_code,omitempty"`
	Zip       string `json:"zip,omitempty"`
	Country   string `json:"country,omitempty"`
}

BillingAddressRequest represents billing address in customer request

type ChargebeeClient

type ChargebeeClient interface {
	// Configuration and initialization
	GetChargebeeConfig(ctx context.Context) (*ChargebeeConfig, error)
	GetDecryptedChargebeeConfig(conn *connection.Connection) (*ChargebeeConfig, error)
	HasChargebeeConnection(ctx context.Context) bool
	GetConnection(ctx context.Context) (*connection.Connection, error)
	InitializeChargebeeSDK(ctx context.Context) error
	VerifyWebhookSignature(ctx context.Context, payload []byte, signature string) error
	VerifyWebhookBasicAuth(ctx context.Context, username, password string) error

	// Item Family API wrappers
	CreateItemFamily(ctx context.Context, params *itemfamily.CreateRequestParams) (*chargebee.Result, error)
	ListItemFamilies(ctx context.Context, params *itemfamily.ListRequestParams) (*chargebee.ResultList, error)

	// Item API wrappers
	CreateItem(ctx context.Context, params *item.CreateRequestParams) (*chargebee.Result, error)
	RetrieveItem(ctx context.Context, itemID string) (*chargebee.Result, error)

	// Item Price API wrappers
	CreateItemPrice(ctx context.Context, params *itemprice.CreateRequestParams) (*chargebee.Result, error)
	RetrieveItemPrice(ctx context.Context, itemPriceID string) (*chargebee.Result, error)

	// Customer API wrappers
	CreateCustomer(ctx context.Context, params *customer.CreateRequestParams) (*chargebee.Result, error)
	RetrieveCustomer(ctx context.Context, customerID string) (*chargebee.Result, error)

	// Invoice API wrappers
	CreateInvoice(ctx context.Context, params *chargebeeInvoice.CreateForChargeItemsAndChargesRequestParams) (*chargebee.Result, error)
	RetrieveInvoice(ctx context.Context, invoiceID string, params *chargebeeInvoice.RetrieveRequestParams) (*chargebee.Result, error)
}

ChargebeeClient defines the interface for Chargebee API operations

func NewClient

func NewClient(
	connectionRepo connection.Repository,
	encryptionService security.EncryptionService,
	logger *logger.Logger,
) ChargebeeClient

NewClient creates a new Chargebee client

type ChargebeeConfig

type ChargebeeConfig struct {
	Site            string // Chargebee site name (e.g., "acme-test")
	APIKey          string // Chargebee API key
	WebhookSecret   string // Webhook secret for verification (optional, NOT USED in v2)
	WebhookUsername string // Basic Auth username for webhook verification (Chargebee v2 security)
	WebhookPassword string // Basic Auth password for webhook verification (Chargebee v2 security)
}

ChargebeeConfig holds decrypted Chargebee configuration

type ChargebeeCustomerService

type ChargebeeCustomerService interface {
	SyncCustomerToChargebee(ctx context.Context, flexpriceCustomer *customerDomain.Customer) (*CustomerResponse, error)
	GetOrCreateChargebeeCustomer(ctx context.Context, flexpriceCustomer *customerDomain.Customer) (string, error)
	GetChargebeeCustomerID(ctx context.Context, flexpriceCustomerID string) (string, error)
	EnsureCustomerSyncedToChargebee(ctx context.Context, customerID string) (*customerDomain.Customer, error)
}

ChargebeeCustomerService defines the interface for Chargebee customer operations

func NewCustomerService

func NewCustomerService(params CustomerServiceParams) ChargebeeCustomerService

NewCustomerService creates a new Chargebee customer service

type ChargebeeInvoiceService

type ChargebeeInvoiceService interface {
	CreateInvoice(ctx context.Context, req *InvoiceCreateRequest) (*InvoiceResponse, error)
	RetrieveInvoice(ctx context.Context, invoiceID string) (*InvoiceResponse, error)
	SyncInvoiceToChargebee(ctx context.Context, req ChargebeeInvoiceSyncRequest) (*ChargebeeInvoiceSyncResponse, error)
}

ChargebeeInvoiceService defines the interface for Chargebee invoice operations

func NewInvoiceService

func NewInvoiceService(params InvoiceServiceParams) ChargebeeInvoiceService

NewInvoiceService creates a new Chargebee invoice service

type ChargebeeInvoiceSyncRequest

type ChargebeeInvoiceSyncRequest struct {
	InvoiceID string `json:"invoice_id" validate:"required"`
}

ChargebeeInvoiceSyncRequest represents a request to sync an invoice to Chargebee

type ChargebeeInvoiceSyncResponse

type ChargebeeInvoiceSyncResponse struct {
	ChargebeeInvoiceID string `json:"chargebee_invoice_id"`
	Status             string `json:"status"`
	Total              int64  `json:"total"`
	AmountDue          int64  `json:"amount_due"`
	CurrencyCode       string `json:"currency_code"`
}

ChargebeeInvoiceSyncResponse represents the response from syncing an invoice to Chargebee

type ChargebeeItemFamilyService

type ChargebeeItemFamilyService interface {
	CreateItemFamily(ctx context.Context, req *ItemFamilyCreateRequest) (*ItemFamilyResponse, error)
	ListItemFamilies(ctx context.Context) ([]*ItemFamilyResponse, error)
	GetLatestItemFamily(ctx context.Context) (*ItemFamilyResponse, error)
}

ChargebeeItemFamilyService defines the interface for Chargebee item family operations

func NewItemFamilyService

func NewItemFamilyService(params ItemFamilyServiceParams) ChargebeeItemFamilyService

NewItemFamilyService creates a new Chargebee item family service

type ChargebeeItemPriceService

type ChargebeeItemPriceService interface {
	CreateItemPrice(ctx context.Context, req *ItemPriceCreateRequest) (*ItemPriceResponse, error)
	RetrieveItemPrice(ctx context.Context, itemPriceID string) (*ItemPriceResponse, error)
}

ChargebeeItemPriceService defines the interface for Chargebee item price operations

func NewItemPriceService

func NewItemPriceService(params ItemPriceServiceParams) ChargebeeItemPriceService

NewItemPriceService creates a new Chargebee item price service

type ChargebeeItemService

type ChargebeeItemService interface {
	CreateItem(ctx context.Context, req *ItemCreateRequest) (*ItemResponse, error)
	RetrieveItem(ctx context.Context, itemID string) (*ItemResponse, error)
}

ChargebeeItemService defines the interface for Chargebee item operations

func NewItemService

func NewItemService(params ItemServiceParams) ChargebeeItemService

NewItemService creates a new Chargebee item service

type ChargebeePlanSyncService

type ChargebeePlanSyncService interface {
	SyncPlanToChargebee(ctx context.Context, plan *plan.Plan, prices []*price.Price) error
}

ChargebeePlanSyncService defines the interface for Chargebee plan synchronization

func NewPlanSyncService

func NewPlanSyncService(params PlanSyncServiceParams) ChargebeePlanSyncService

NewPlanSyncService creates a new Chargebee plan sync service

type ChargebeeTier

type ChargebeeTier struct {
	StartingUnit int64  `json:"starting_unit"`         // Starting quantity for this tier (1-based, Chargebee requirement)
	EndingUnit   *int64 `json:"ending_unit,omitempty"` // Ending quantity (nil for last tier)
	Price        int64  `json:"price"`                 // Price per unit in smallest currency unit
}

ChargebeeTier represents a pricing tier for Chargebee item prices

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client handles Chargebee API client setup and configuration

func (*Client) CreateCustomer

func (c *Client) CreateCustomer(ctx context.Context, params *customer.CreateRequestParams) (*chargebee.Result, error)

Customer API Wrappers CreateCustomer creates a customer in Chargebee

func (*Client) CreateInvoice

Invoice API Wrappers CreateInvoice creates an invoice in Chargebee

func (*Client) CreateItem

func (c *Client) CreateItem(ctx context.Context, params *item.CreateRequestParams) (*chargebee.Result, error)

Item API Wrappers CreateItem creates an item in Chargebee

func (*Client) CreateItemFamily

func (c *Client) CreateItemFamily(ctx context.Context, params *itemfamily.CreateRequestParams) (*chargebee.Result, error)

Item Family API Wrappers CreateItemFamily creates an item family in Chargebee

func (*Client) CreateItemPrice

func (c *Client) CreateItemPrice(ctx context.Context, params *itemprice.CreateRequestParams) (*chargebee.Result, error)

Item Price API Wrappers CreateItemPrice creates an item price in Chargebee

func (*Client) GetChargebeeConfig

func (c *Client) GetChargebeeConfig(ctx context.Context) (*ChargebeeConfig, error)

GetChargebeeConfig retrieves and decrypts Chargebee configuration for the current environment

func (*Client) GetConnection

func (c *Client) GetConnection(ctx context.Context) (*connection.Connection, error)

GetConnection retrieves the Chargebee connection for the current context

func (*Client) GetDecryptedChargebeeConfig

func (c *Client) GetDecryptedChargebeeConfig(conn *connection.Connection) (*ChargebeeConfig, error)

GetDecryptedChargebeeConfig decrypts and returns Chargebee configuration

func (*Client) HasChargebeeConnection

func (c *Client) HasChargebeeConnection(ctx context.Context) bool

HasChargebeeConnection checks if Chargebee connection exists for the current environment

func (*Client) InitializeChargebeeSDK

func (c *Client) InitializeChargebeeSDK(ctx context.Context) error

InitializeChargebeeSDK configures the global Chargebee SDK instance This should be called before making any Chargebee SDK API calls

func (*Client) ListItemFamilies

func (c *Client) ListItemFamilies(ctx context.Context, params *itemfamily.ListRequestParams) (*chargebee.ResultList, error)

ListItemFamilies lists item families from Chargebee

func (*Client) RetrieveCustomer

func (c *Client) RetrieveCustomer(ctx context.Context, customerID string) (*chargebee.Result, error)

RetrieveCustomer retrieves a customer from Chargebee

func (*Client) RetrieveInvoice

func (c *Client) RetrieveInvoice(ctx context.Context, invoiceID string, params *chargebeeInvoice.RetrieveRequestParams) (*chargebee.Result, error)

RetrieveInvoice retrieves an invoice from Chargebee

func (*Client) RetrieveItem

func (c *Client) RetrieveItem(ctx context.Context, itemID string) (*chargebee.Result, error)

RetrieveItem retrieves an item from Chargebee

func (*Client) RetrieveItemPrice

func (c *Client) RetrieveItemPrice(ctx context.Context, itemPriceID string) (*chargebee.Result, error)

RetrieveItemPrice retrieves an item price from Chargebee

func (*Client) VerifyWebhookBasicAuth

func (c *Client) VerifyWebhookBasicAuth(ctx context.Context, username, password string) error

VerifyWebhookBasicAuth verifies Basic Authentication credentials for Chargebee webhooks Chargebee v2 uses Basic Auth (username/password) as the primary webhook security mechanism

func (*Client) VerifyWebhookSignature

func (c *Client) VerifyWebhookSignature(ctx context.Context, payload []byte, signature string) error

VerifyWebhookSignature verifies the Chargebee webhook signature

type CustomerCreateRequest

type CustomerCreateRequest struct {
	ID             string                 `json:"id,omitempty"`
	FirstName      string                 `json:"first_name,omitempty"`
	LastName       string                 `json:"last_name,omitempty"`
	Email          string                 `json:"email,omitempty"`
	Company        string                 `json:"company,omitempty"`
	Phone          string                 `json:"phone,omitempty"`
	AutoCollection string                 `json:"auto_collection"` // "on" to enable automatic payment collection, "off" for manual
	BillingAddress *BillingAddressRequest `json:"billing_address,omitempty"`
}

CustomerCreateRequest represents the request to create a customer

type CustomerResponse

type CustomerResponse struct {
	ID              string          `json:"id"`
	FirstName       string          `json:"first_name"`
	LastName        string          `json:"last_name"`
	Email           string          `json:"email"`
	Company         string          `json:"company"`
	Phone           string          `json:"phone"`
	AutoCollection  string          `json:"auto_collection"`
	CreatedAt       time.Time       `json:"created_at"`
	UpdatedAt       time.Time       `json:"updated_at"`
	ResourceVersion int64           `json:"resource_version"`
	BillingAddress  *BillingAddress `json:"billing_address,omitempty"`
}

CustomerResponse represents a customer response from Chargebee

type CustomerService

type CustomerService struct {
	CustomerServiceParams
}

CustomerService handles Chargebee customer synchronization

func (*CustomerService) CreateCustomerInChargebee

func (s *CustomerService) CreateCustomerInChargebee(ctx context.Context, customerID string) error

CreateCustomerInChargebee creates a customer in Chargebee and updates our customer with Chargebee ID

func (*CustomerService) EnsureCustomerSyncedToChargebee

func (s *CustomerService) EnsureCustomerSyncedToChargebee(ctx context.Context, customerID string) (*customerDomain.Customer, error)

EnsureCustomerSyncedToChargebee ensures a customer is synced to Chargebee

func (*CustomerService) GetChargebeeCustomerID

func (s *CustomerService) GetChargebeeCustomerID(ctx context.Context, flexpriceCustomerID string) (string, error)

GetChargebeeCustomerID retrieves the Chargebee customer ID from entity mapping

func (*CustomerService) GetOrCreateChargebeeCustomer

func (s *CustomerService) GetOrCreateChargebeeCustomer(ctx context.Context, flexpriceCustomer *customerDomain.Customer) (string, error)

GetOrCreateChargebeeCustomer gets existing or creates a new customer in Chargebee

func (*CustomerService) SyncCustomerToChargebee

func (s *CustomerService) SyncCustomerToChargebee(ctx context.Context, flexpriceCustomer *customerDomain.Customer) (*CustomerResponse, error)

SyncCustomerToChargebee syncs FlexPrice customer to Chargebee

type CustomerServiceParams

type CustomerServiceParams struct {
	Client                       ChargebeeClient
	CustomerRepo                 customerDomain.Repository
	EntityIntegrationMappingRepo entityintegrationmapping.Repository
	Logger                       *logger.Logger
}

CustomerServiceParams holds dependencies for CustomerService

type ErrorResponse

type ErrorResponse struct {
	Message      string `json:"message"`
	Type         string `json:"type"`
	APIErrorCode string `json:"api_error_code"`
	Param        string `json:"param,omitempty"`
}

ErrorResponse represents an error response from Chargebee

type InvoiceCreateRequest

type InvoiceCreateRequest struct {
	CustomerID     string            `json:"customer_id"`
	AutoCollection string            `json:"auto_collection"` // "on" if customer has payment method, "off" otherwise
	LineItems      []InvoiceLineItem `json:"line_items"`
	Date           *time.Time        `json:"date,omitempty"`
}

InvoiceCreateRequest represents the request to create an invoice Note: Chargebee calculates due dates automatically based on customer payment terms and site settings. The due_date cannot be set during invoice creation.

type InvoiceLineItem

type InvoiceLineItem struct {
	ItemPriceID string     `json:"item_price_id"`
	Quantity    int        `json:"quantity"`
	UnitAmount  int64      `json:"unit_amount,omitempty"` // Amount in cents
	Description string     `json:"description,omitempty"`
	DateFrom    *time.Time `json:"date_from,omitempty"`
	DateTo      *time.Time `json:"date_to,omitempty"`
}

InvoiceLineItem represents a line item in invoice request

type InvoiceLineItemResponse

type InvoiceLineItemResponse struct {
	ID          string    `json:"id"`
	ItemPriceID string    `json:"item_price_id"`
	EntityType  string    `json:"entity_type"`
	Quantity    int       `json:"quantity"`
	UnitAmount  int64     `json:"unit_amount"`
	Amount      int64     `json:"amount"`
	Description string    `json:"description"`
	DateFrom    time.Time `json:"date_from"`
	DateTo      time.Time `json:"date_to"`
}

InvoiceLineItemResponse represents a line item in invoice response

type InvoiceResponse

type InvoiceResponse struct {
	ID              string                    `json:"id"`
	CustomerID      string                    `json:"customer_id"`
	Status          string                    `json:"status"`
	AutoCollection  string                    `json:"auto_collection"`
	Total           int64                     `json:"total"`
	AmountDue       int64                     `json:"amount_due"`
	AmountPaid      int64                     `json:"amount_paid"`
	CurrencyCode    string                    `json:"currency_code"`
	Date            time.Time                 `json:"date"`
	DueDate         *time.Time                `json:"due_date,omitempty"`
	CreatedAt       time.Time                 `json:"created_at"`
	UpdatedAt       time.Time                 `json:"updated_at"`
	ResourceVersion int64                     `json:"resource_version"`
	LineItems       []InvoiceLineItemResponse `json:"line_items,omitempty"`
}

InvoiceResponse represents an invoice response from Chargebee

type InvoiceService

type InvoiceService struct {
	InvoiceServiceParams
}

InvoiceService handles Chargebee invoice operations

func (*InvoiceService) CreateInvoice

func (s *InvoiceService) CreateInvoice(ctx context.Context, req *InvoiceCreateRequest) (*InvoiceResponse, error)

CreateInvoice creates a new invoice in Chargebee using charge items

func (*InvoiceService) GetFlexPriceInvoiceIDByChargebeeInvoiceID

func (s *InvoiceService) GetFlexPriceInvoiceIDByChargebeeInvoiceID(ctx context.Context, chargebeeInvoiceID string) (string, error)

GetFlexPriceInvoiceIDByChargebeeInvoiceID retrieves the FlexPrice invoice ID from entity mapping

func (*InvoiceService) PaymentExistsByGatewayPaymentID

func (s *InvoiceService) PaymentExistsByGatewayPaymentID(
	ctx context.Context,
	gatewayPaymentID string,
) (bool, error)

PaymentExistsByGatewayPaymentID checks if a payment already exists with the given gateway payment ID This is used for idempotency checks to prevent duplicate payment records from webhook retries

func (*InvoiceService) ProcessChargebeePaymentFromWebhook

func (s *InvoiceService) ProcessChargebeePaymentFromWebhook(
	ctx context.Context,
	flexpriceInvoiceID string,
	chargebeeTransactionID string,
	chargebeeInvoiceID string,
	amount decimal.Decimal,
	currency string,
	paymentMethod string,
) error

ProcessChargebeePaymentFromWebhook processes a Chargebee payment and creates a FlexPrice payment record

func (*InvoiceService) ReconcileInvoicePayment

func (s *InvoiceService) ReconcileInvoicePayment(ctx context.Context, invoiceID string, paymentAmount decimal.Decimal) error

ReconcileInvoicePayment reconciles an invoice payment when a payment succeeds in Chargebee This is called from the webhook handler after a payment_succeeded event This method replicates the logic from invoiceService.ReconcilePaymentStatus but uses repositories directly

func (*InvoiceService) RetrieveInvoice

func (s *InvoiceService) RetrieveInvoice(ctx context.Context, invoiceID string) (*InvoiceResponse, error)

RetrieveInvoice retrieves an invoice from Chargebee

func (*InvoiceService) SyncInvoiceToChargebee

SyncInvoiceToChargebee syncs a FlexPrice invoice to Chargebee

type InvoiceServiceParams

type InvoiceServiceParams struct {
	Client                       ChargebeeClient
	CustomerSvc                  ChargebeeCustomerService
	InvoiceRepo                  invoice.Repository
	PaymentRepo                  payment.Repository
	EntityIntegrationMappingRepo entityintegrationmapping.Repository
	Logger                       *logger.Logger
}

InvoiceServiceParams holds dependencies for InvoiceService

type ItemCreateRequest

type ItemCreateRequest struct {
	ID              string `json:"id"`
	Name            string `json:"name"`
	Type            string `json:"type"` // "charge" for one-time charges
	ItemFamilyID    string `json:"item_family_id"`
	Description     string `json:"description,omitempty"`
	ExternalName    string `json:"external_name,omitempty"`
	EnabledInPortal bool   `json:"enabled_in_portal"`
}

ItemCreateRequest represents the request to create an item

type ItemFamilyCreateRequest

type ItemFamilyCreateRequest struct {
	ID          string `json:"id"`
	Name        string `json:"name"`
	Description string `json:"description,omitempty"`
}

ItemFamilyCreateRequest represents the request to create an item family

type ItemFamilyResponse

type ItemFamilyResponse struct {
	ID              string    `json:"id"`
	Name            string    `json:"name"`
	Description     string    `json:"description"`
	Status          string    `json:"status"`
	ResourceVersion int64     `json:"resource_version"`
	UpdatedAt       time.Time `json:"updated_at"`
}

ItemFamilyResponse represents an item family response from Chargebee

type ItemFamilyService

type ItemFamilyService struct {
	ItemFamilyServiceParams
}

ItemFamilyService handles Chargebee item family operations

func (*ItemFamilyService) CreateItemFamily

CreateItemFamily creates a new item family in Chargebee

func (*ItemFamilyService) GetLatestItemFamily

func (s *ItemFamilyService) GetLatestItemFamily(ctx context.Context) (*ItemFamilyResponse, error)

GetLatestItemFamily retrieves the most recently updated item family

func (*ItemFamilyService) ListItemFamilies

func (s *ItemFamilyService) ListItemFamilies(ctx context.Context) ([]*ItemFamilyResponse, error)

ListItemFamilies retrieves all item families from Chargebee

type ItemFamilyServiceParams

type ItemFamilyServiceParams struct {
	Client ChargebeeClient
	Logger *logger.Logger
}

ItemFamilyServiceParams holds dependencies for ItemFamilyService

type ItemPriceCreateRequest

type ItemPriceCreateRequest struct {
	ID           string          `json:"id"`
	ItemID       string          `json:"item_id"`
	Name         string          `json:"name"`
	ExternalName string          `json:"external_name,omitempty"`
	PricingModel string          `json:"pricing_model"` // "flat_fee", "per_unit", "tiered", "volume", "package", "stairstep"
	Price        int64           `json:"price"`         // Amount in cents (for flat_fee/per_unit)
	CurrencyCode string          `json:"currency_code"` // "USD", "INR", etc.
	Description  string          `json:"description,omitempty"`
	Tiers        []ChargebeeTier `json:"tiers,omitempty"`       // For tiered/volume pricing
	Period       *int            `json:"period,omitempty"`      // For package pricing (optional)
	PeriodUnit   string          `json:"period_unit,omitempty"` // For package pricing: "day", "week", "month", "year"
}

ItemPriceCreateRequest represents the request to create an item price

type ItemPriceResponse

type ItemPriceResponse struct {
	ID              string    `json:"id"`
	ItemID          string    `json:"item_id"`
	Name            string    `json:"name"`
	ExternalName    string    `json:"external_name"`
	PricingModel    string    `json:"pricing_model"`
	Price           int64     `json:"price"`
	CurrencyCode    string    `json:"currency_code"`
	Description     string    `json:"description"`
	Status          string    `json:"status"`
	ResourceVersion int64     `json:"resource_version"`
	UpdatedAt       time.Time `json:"updated_at"`
}

ItemPriceResponse represents an item price response from Chargebee

type ItemPriceService

type ItemPriceService struct {
	ItemPriceServiceParams
}

ItemPriceService handles Chargebee item price operations

func (*ItemPriceService) CreateItemPrice

CreateItemPrice creates a new item price in Chargebee

func (*ItemPriceService) RetrieveItemPrice

func (s *ItemPriceService) RetrieveItemPrice(ctx context.Context, itemPriceID string) (*ItemPriceResponse, error)

RetrieveItemPrice retrieves an item price from Chargebee

type ItemPriceServiceParams

type ItemPriceServiceParams struct {
	Client ChargebeeClient
	Logger *logger.Logger
}

ItemPriceServiceParams holds dependencies for ItemPriceService

type ItemResponse

type ItemResponse struct {
	ID              string    `json:"id"`
	Name            string    `json:"name"`
	Type            string    `json:"type"`
	ItemFamilyID    string    `json:"item_family_id"`
	Description     string    `json:"description"`
	ExternalName    string    `json:"external_name"`
	Status          string    `json:"status"`
	ResourceVersion int64     `json:"resource_version"`
	UpdatedAt       time.Time `json:"updated_at"`
}

ItemResponse represents an item response from Chargebee

type ItemService

type ItemService struct {
	ItemServiceParams
}

ItemService handles Chargebee item operations

func (*ItemService) CreateItem

func (s *ItemService) CreateItem(ctx context.Context, req *ItemCreateRequest) (*ItemResponse, error)

CreateItem creates a new item in Chargebee

func (*ItemService) RetrieveItem

func (s *ItemService) RetrieveItem(ctx context.Context, itemID string) (*ItemResponse, error)

RetrieveItem retrieves an item from Chargebee

type ItemServiceParams

type ItemServiceParams struct {
	Client ChargebeeClient
	Logger *logger.Logger
}

ItemServiceParams holds dependencies for ItemService

type PlanSyncService

type PlanSyncService struct {
	PlanSyncServiceParams
	// contains filtered or unexported fields
}

PlanSyncService handles synchronization of FlexPrice plans to Chargebee

func (*PlanSyncService) SyncPlanToChargebee

func (s *PlanSyncService) SyncPlanToChargebee(ctx context.Context, plan *plan.Plan, prices []*price.Price) error

SyncPlanToChargebee syncs a FlexPrice plan and its prices to Chargebee Creates a separate charge item for each price to avoid currency conflicts

type PlanSyncServiceParams

type PlanSyncServiceParams struct {
	Client                       ChargebeeClient
	EntityIntegrationMappingRepo entityintegrationmapping.Repository
	MeterRepo                    meter.Repository
	FeatureRepo                  feature.Repository
	Logger                       *logger.Logger
}

PlanSyncServiceParams holds dependencies for PlanSyncService

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL