billing

package
v1.0.0-beta.230 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2026 License: Apache-2.0 Imports: 93 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertTotals

func AssertTotals(t *testing.T, expected ExpectedTotals, actual totals.Totals)

func ExpectJSONEqual

func ExpectJSONEqual(t *testing.T, exp, actual any)

func WithCustomInvoicingConfig

func WithCustomInvoicingConfig(config appcustominvoicing.Configuration) setupCustomInvoicingOption

Types

type BaseSuite

type BaseSuite struct {
	suite.Suite

	TestDB   *testutils.TestDB
	DBClient *db.Client

	BillingAdapter    billing.Adapter
	BillingService    billing.Service
	SequenceService   billingsequence.Service
	InvoiceCalculator *invoicecalc.MockableInvoiceCalculator

	FeatureService         feature.FeatureConnector
	FeatureRepo            feature.FeatureRepo
	MeterAdapter           *meteradapter.TestAdapter
	MockStreamingConnector *streamingtestutils.MockStreamingConnector

	CustomerService customer.Service
	SubjectService  subject.Service

	CustomInvoicingService appcustominvoicing.Service

	AppService app.Service
	SandboxApp *appsandbox.MockableFactory

	TaxCodeService taxcode.Service
}

func (*BaseSuite) AssertDecimalEqual

func (s *BaseSuite) AssertDecimalEqual(expected, actual alpacadecimal.Decimal, label string)

func (*BaseSuite) AssertTotals

func (s *BaseSuite) AssertTotals(expected ExpectedTotals, actual totals.Totals)

func (*BaseSuite) CreateDraftInvoice

func (s *BaseSuite) CreateDraftInvoice(t *testing.T, ctx context.Context, in DraftInvoiceInput) billing.StandardInvoice

func (*BaseSuite) CreateGatheringInvoice

func (s *BaseSuite) CreateGatheringInvoice(t *testing.T, ctx context.Context, in DraftInvoiceInput)

func (*BaseSuite) CreateTestCustomer

func (s *BaseSuite) CreateTestCustomer(ns string, subjectKey string) *customer.Customer

func (*BaseSuite) DebugDumpGatheringInvoice

func (s *BaseSuite) DebugDumpGatheringInvoice(h string, i billing.GatheringInvoice)

func (*BaseSuite) DebugDumpInvoice

func (s *BaseSuite) DebugDumpInvoice(h string, i billing.GenericInvoiceReader)

func (*BaseSuite) DebugDumpStandardInvoice

func (s *BaseSuite) DebugDumpStandardInvoice(h string, i billing.StandardInvoice)

func (*BaseSuite) GetSubscriptionMixInDependencies

func (b *BaseSuite) GetSubscriptionMixInDependencies() SubscriptionMixInDependencies

func (*BaseSuite) GetUniqueNamespace

func (s *BaseSuite) GetUniqueNamespace(prefix string) string

GetUniqueNamespace returns a unique namespace with the given prefix

func (*BaseSuite) InstallSandboxApp

func (s *BaseSuite) InstallSandboxApp(t *testing.T, ns string) app.App

func (*BaseSuite) ProvisionBillingProfile

func (s *BaseSuite) ProvisionBillingProfile(ctx context.Context, ns string, appID app.AppID, opts ...BillingProfileProvisionOption) *billing.Profile

func (*BaseSuite) ProvisionDefaultTaxCodes

func (s *BaseSuite) ProvisionDefaultTaxCodes(ctx context.Context, ns string) taxcode.OrganizationDefaultTaxCodes

ProvisionDefaultTaxCodes creates the invoicing and credit-grant tax codes for the namespace and stores them as the organization defaults. Tests that create charges via the real charges service must call this for the namespace, because charge creation auto-stamps the namespace's default tax code when the caller's TaxConfig has no TaxCodeID.

func (*BaseSuite) ProvisionProviderDefaultTaxCode

func (s *BaseSuite) ProvisionProviderDefaultTaxCode(ctx context.Context, ns string) taxcode.TaxCode

ProvisionProviderDefaultTaxCode creates the tax code used when an invoicing app omits an app-specific provider code. This is distinct from organization default tax-code settings: API invoice edit diffing needs the provider-default tax code row to resolve empty provider tax config, but it must not imply that the namespace has configured org-level default tax codes.

func (*BaseSuite) RequireTotals

func (s *BaseSuite) RequireTotals(expected ExpectedTotals, actual totals.Totals)

func (*BaseSuite) SeedProfileDefaultTaxConfigViaAdapter

func (s *BaseSuite) SeedProfileDefaultTaxConfigViaAdapter(ctx context.Context, profileID billing.ProfileID, taxConfig *productcatalog.TaxConfig) *billing.AdapterGetProfileResponse

SeedProfileDefaultTaxConfigViaAdapter seeds a stored DefaultTaxConfig on an existing billing profile directly through the billing adapter, bypassing the service-level tax code deprecation gate (InvoicingConfig.EnforceTaxCodeDeprecation). This simulates legacy rows that were created before tax codes on billing profiles were deprecated.

The tax config is resolved in place exactly like the pre-deprecation service path (productcatalog.ResolveTaxConfig cross-populates TaxCodeID and Stripe.Code), then persisted via the adapter so the JSON column, tax_code_id FK and tax_behavior columns are written by the production adapter code path. Returns the re-read profile so tests can assert on the stored state including read-time backfill.

func (*BaseSuite) SetupApiRequestsTotalFeature

func (s *BaseSuite) SetupApiRequestsTotalFeature(ctx context.Context, ns string) TestFeature

func (*BaseSuite) SetupCustomInvoicing

func (s *BaseSuite) SetupCustomInvoicing(namespace string, opts ...setupCustomInvoicingOption) SetupCustomInvoicingResponse

func (*BaseSuite) SetupCustomInvoicingApp

func (s *BaseSuite) SetupCustomInvoicingApp() appcustominvoicing.Service

func (*BaseSuite) SetupSuite

func (s *BaseSuite) SetupSuite()

func (*BaseSuite) TearDownSuite

func (s *BaseSuite) TearDownSuite()

func (*BaseSuite) TearDownTest

func (s *BaseSuite) TearDownTest()

type BillingProfileEditFn

type BillingProfileEditFn func(p *billing.CreateProfileInput)

type BillingProfileProvisionOption

type BillingProfileProvisionOption func(*BillingProfileProvisionOptions)

func WithManualApproval

func WithManualApproval() BillingProfileProvisionOption

func WithProgressiveBilling

func WithProgressiveBilling() BillingProfileProvisionOption

type BillingProfileProvisionOptions

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

type DraftInvoiceInput

type DraftInvoiceInput struct {
	Namespace string
	Customer  *customer.Customer
}

func (DraftInvoiceInput) Validate

func (i DraftInvoiceInput) Validate() error

type ExpectedTotals

type ExpectedTotals struct {
	Amount              float64 `json:"amount"`
	ChargesTotal        float64 `json:"chargesTotal"`
	DiscountsTotal      float64 `json:"discountsTotal"`
	TaxesInclusiveTotal float64 `json:"taxesInclusiveTotal"`
	TaxesExclusiveTotal float64 `json:"taxesExclusiveTotal"`
	TaxesTotal          float64 `json:"taxesTotal"`
	Total               float64 `json:"total"`
	CreditsTotal        float64 `json:"creditsTotal"`
}

type SetupCustomInvoicingResponse

type SetupCustomInvoicingResponse struct {
	App app.App
}

type SetupSuiteOptions

type SetupSuiteOptions struct {
	ForceAtlas bool
}

type SubscriptionMixInDependencies

type SubscriptionMixInDependencies struct {
	DBClient *db.Client

	FeatureRepo     feature.FeatureRepo
	FeatureService  feature.FeatureConnector
	CustomerService customer.Service

	MeterAdapter           *meteradapter.TestAdapter
	MockStreamingConnector *streamingtestutils.MockStreamingConnector
}

func (SubscriptionMixInDependencies) Validate

func (d SubscriptionMixInDependencies) Validate() error

type SubscriptionMixin

type SubscriptionMixin struct {
	PlanService                 plan.Service
	SubscriptionService         subscription.Service
	SubscriptionAddonService    subscriptionaddon.Service
	SubscriptionPlanAdapter     subscriptiontestutils.PlanSubscriptionAdapter
	SubscriptionWorkflowService subscriptionworkflow.Service
	EntitlementConnector        entitlement.Service
}

func (*SubscriptionMixin) SetupEntitlements

func (*SubscriptionMixin) SetupSuite

func (s *SubscriptionMixin) SetupSuite(t *testing.T, deps SubscriptionMixInDependencies)

type TestFeature

type TestFeature struct {
	Cleanup func()
	Feature feature.Feature
}

Jump to

Keyboard shortcuts

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