Documentation
¶
Index ¶
- Constants
- Variables
- func NewChargeNotFoundError(namespace, id string) error
- func NewLockKeyForCharge(chargeID meta.ChargeID) (lockr.Key, error)
- type Adapter
- type AdvanceChargesEvent
- type AdvanceChargesInput
- type ApplyPatchesInput
- type Charge
- func (c Charge) AsCreditPurchaseCharge() (creditpurchase.Charge, error)
- func (c Charge) AsFlatFeeCharge() (flatfee.Charge, error)
- func (c Charge) AsUsageBasedCharge() (usagebased.Charge, error)
- func (c Charge) GetChargeID() (meta.ChargeID, error)
- func (c Charge) GetCurrency() (currencyx.Code, error)
- func (c Charge) GetCustomerID() (customer.CustomerID, error)
- func (c Charge) GetID() string
- func (c Charge) GetNamespace() string
- func (c Charge) GetUniqueReferenceID() (*string, error)
- func (c Charge) SettlementMode() (productcatalog.SettlementMode, error)
- func (c Charge) Type() meta.ChargeType
- func (c Charge) Validate() error
- type ChargeIntent
- func (i ChargeIntent) AsCreditPurchaseIntent() (creditpurchase.Intent, error)
- func (i ChargeIntent) AsFlatFeeIntent() (flatfee.Intent, error)
- func (i ChargeIntent) AsUsageBasedIntent() (usagebased.Intent, error)
- func (c ChargeIntent) GetUniqueReferenceID() (*string, error)
- func (i ChargeIntent) Meta() (meta.Intent, error)
- func (i ChargeIntent) Type() meta.ChargeType
- func (i ChargeIntent) Validate() error
- func (i ChargeIntent) WithTaxCodeID(id string) (ChargeIntent, error)
- type ChargeIntents
- type ChargeIntentsByType
- type ChargeSearchItem
- type ChargeSearchItems
- type ChargeService
- type Charges
- type ChargesSearchAdapter
- type CreateInput
- type CreditPurchaseFacadeService
- type GetByIDInput
- type GetByIDsInput
- type HandleCreditPurchaseExternalPaymentStateTransitionInput
- type ListChargesInput
- type ListCustomersToAdvanceInput
- type Patch
- type Service
- type WithIndex
Constants ¶
View Source
const ErrCodeChargeInvalid models.ErrorCode = "charge_invalid"
View Source
const ErrCodeChargeNamespaceEmpty models.ErrorCode = "charge_namespace_empty"
View Source
const ErrCodeChargeNotFound models.ErrorCode = "charge_not_found"
View Source
const ErrCodeCreditRealizationsAlreadyAllocated models.ErrorCode = "credit_realizations_already_allocated"
View Source
const (
EventSubsystem metadata.EventSubsystem = "billing"
)
Variables ¶
View Source
var CreditNotesSupportedByLineUpdater = false
CreditNotesSupportedByLineUpdater controls whether charge-backed immutable invoice-line proration can materialize replacement gathering lines. The default behavior is false until the invoice line updater supports credit notes for correcting immutable invoice history.
View Source
var ErrChargeInvalid = models.NewValidationIssue( ErrCodeChargeInvalid, "charge is invalid", models.WithCriticalSeverity(), commonhttp.WithHTTPStatusCodeAttribute(http.StatusBadRequest), )
View Source
var ErrChargeNamespaceEmpty = models.NewValidationIssue( ErrCodeChargeNamespaceEmpty, "namespace must not be empty", models.WithFieldString("namespace"), models.WithCriticalSeverity(), commonhttp.WithHTTPStatusCodeAttribute(http.StatusBadRequest), )
View Source
var ErrChargeNotFound = models.NewValidationIssue( ErrCodeChargeNotFound, "charge not found", models.WithFieldString("id"), models.WithCriticalSeverity(), commonhttp.WithHTTPStatusCodeAttribute(http.StatusNotFound), )
View Source
var ErrCreditRealizationsAlreadyAllocated = models.NewValidationIssue( ErrCodeCreditRealizationsAlreadyAllocated, "credit realizations already allocated", models.WithCriticalSeverity(), commonhttp.WithHTTPStatusCodeAttribute(http.StatusBadRequest), )
Functions ¶
func NewChargeNotFoundError ¶
Types ¶
type Adapter ¶
type Adapter interface {
ChargesSearchAdapter
entutils.TxCreator
}
type AdvanceChargesEvent ¶
type AdvanceChargesEvent struct {
Namespace string `json:"namespace"`
CustomerID string `json:"customer_id"`
}
func (AdvanceChargesEvent) EventMetadata ¶
func (e AdvanceChargesEvent) EventMetadata() metadata.EventMetadata
func (AdvanceChargesEvent) EventName ¶
func (e AdvanceChargesEvent) EventName() string
func (AdvanceChargesEvent) Validate ¶
func (e AdvanceChargesEvent) Validate() error
type AdvanceChargesInput ¶
type AdvanceChargesInput struct {
Customer customer.CustomerID
}
func (AdvanceChargesInput) Validate ¶
func (i AdvanceChargesInput) Validate() error
type ApplyPatchesInput ¶
type ApplyPatchesInput struct {
CustomerID customer.CustomerID
Creates ChargeIntents
// PatchesByChargeID is a map of charge ID to the patches to apply to the charge. This format is used to make sure
// there's only a single patch affecting a single charge.
PatchesByChargeID map[string]Patch
}
func ConcatenateApplyPatchesInputs ¶
func ConcatenateApplyPatchesInputs(inputs ...ApplyPatchesInput) (ApplyPatchesInput, error)
ConcatenateApplyPatchesInputs concatenates the given inputs into a single input, while enforcing uniqueness constraints.
func (ApplyPatchesInput) IsEmpty ¶
func (i ApplyPatchesInput) IsEmpty() bool
func (ApplyPatchesInput) Validate ¶
func (i ApplyPatchesInput) Validate() error
type Charge ¶
type Charge struct {
// contains filtered or unexported fields
}
func NewCharge ¶
func NewCharge[T flatfee.Charge | usagebased.Charge | creditpurchase.Charge](ch T) Charge
func (Charge) AsCreditPurchaseCharge ¶
func (c Charge) AsCreditPurchaseCharge() (creditpurchase.Charge, error)
func (Charge) AsUsageBasedCharge ¶
func (c Charge) AsUsageBasedCharge() (usagebased.Charge, error)
func (Charge) GetCustomerID ¶
func (c Charge) GetCustomerID() (customer.CustomerID, error)
func (Charge) GetNamespace ¶
func (Charge) GetUniqueReferenceID ¶
func (Charge) SettlementMode ¶
func (c Charge) SettlementMode() (productcatalog.SettlementMode, error)
func (Charge) Type ¶
func (c Charge) Type() meta.ChargeType
type ChargeIntent ¶
type ChargeIntent struct {
// contains filtered or unexported fields
}
func NewChargeIntent ¶
func NewChargeIntent[T flatfee.Intent | usagebased.Intent | creditpurchase.Intent](ch T) ChargeIntent
func (ChargeIntent) AsCreditPurchaseIntent ¶
func (i ChargeIntent) AsCreditPurchaseIntent() (creditpurchase.Intent, error)
func (ChargeIntent) AsFlatFeeIntent ¶
func (i ChargeIntent) AsFlatFeeIntent() (flatfee.Intent, error)
func (ChargeIntent) AsUsageBasedIntent ¶
func (i ChargeIntent) AsUsageBasedIntent() (usagebased.Intent, error)
func (ChargeIntent) GetUniqueReferenceID ¶
func (c ChargeIntent) GetUniqueReferenceID() (*string, error)
func (ChargeIntent) Meta ¶
func (i ChargeIntent) Meta() (meta.Intent, error)
Meta returns the shared meta.Intent embedded in every charge type.
func (ChargeIntent) Type ¶
func (i ChargeIntent) Type() meta.ChargeType
func (ChargeIntent) Validate ¶
func (i ChargeIntent) Validate() error
func (ChargeIntent) WithTaxCodeID ¶
func (i ChargeIntent) WithTaxCodeID(id string) (ChargeIntent, error)
WithTaxCodeID returns a copy of the intent with TaxCodeID set to id. If TaxConfig is nil a new one is created; all other fields are preserved.
type ChargeIntents ¶
type ChargeIntents []ChargeIntent
func (ChargeIntents) ByType ¶
func (i ChargeIntents) ByType() (ChargeIntentsByType, error)
func (ChargeIntents) CollectFeatureKeys ¶
func (i ChargeIntents) CollectFeatureKeys() ([]string, error)
func (ChargeIntents) Validate ¶
func (i ChargeIntents) Validate() error
type ChargeIntentsByType ¶
type ChargeIntentsByType struct {
FlatFee []WithIndex[flatfee.Intent]
CreditPurchase []WithIndex[creditpurchase.Intent]
UsageBased []WithIndex[usagebased.Intent]
}
type ChargeSearchItem ¶
type ChargeSearchItem struct {
ID meta.ChargeID
Type meta.ChargeType
CustomerID string
}
func (*ChargeSearchItem) Validate ¶
func (c *ChargeSearchItem) Validate() error
type ChargeSearchItems ¶
type ChargeSearchItems []ChargeSearchItem
func (ChargeSearchItems) Validate ¶
func (c ChargeSearchItems) Validate() error
type ChargeService ¶
type ChargeService interface {
GetByID(ctx context.Context, input GetByIDInput) (Charge, error)
GetByIDs(ctx context.Context, input GetByIDsInput) (Charges, error)
Create(ctx context.Context, input CreateInput) (Charges, error)
UpdateSubscriptionItemID(ctx context.Context, charge Charge, newSubscriptionItemID string) (Charge, error)
AdvanceCharges(ctx context.Context, input AdvanceChargesInput) (Charges, error)
ListCustomersToAdvance(ctx context.Context, input ListCustomersToAdvanceInput) (pagination.Result[customer.CustomerID], error)
// ApplyPatches currently returns no affected-charge payload. If exact post-apply
// results are needed, shrink/extend must first be implemented properly instead of
// going through the temporary delete+create remap.
ApplyPatches(ctx context.Context, input ApplyPatchesInput) error
ListCharges(ctx context.Context, input ListChargesInput) (pagination.Result[Charge], error)
}
type ChargesSearchAdapter ¶
type ChargesSearchAdapter interface {
GetByIDs(ctx context.Context, input GetByIDsInput) (ChargeSearchItems, error)
ListCharges(ctx context.Context, input ListChargesInput) (pagination.Result[ChargeSearchItem], error)
ListCustomersToAdvance(ctx context.Context, input ListCustomersToAdvanceInput) (pagination.Result[customer.CustomerID], error)
}
type CreateInput ¶
type CreateInput struct {
Namespace string
Intents ChargeIntents
}
func (CreateInput) Validate ¶
func (i CreateInput) Validate() error
type CreditPurchaseFacadeService ¶
type CreditPurchaseFacadeService interface {
HandleCreditPurchaseExternalPaymentStateTransition(ctx context.Context, input HandleCreditPurchaseExternalPaymentStateTransitionInput) (creditpurchase.Charge, error)
}
type GetByIDInput ¶
func (GetByIDInput) Validate ¶
func (i GetByIDInput) Validate() error
type GetByIDsInput ¶
func (GetByIDsInput) Validate ¶
func (i GetByIDsInput) Validate() error
type HandleCreditPurchaseExternalPaymentStateTransitionInput ¶
type HandleCreditPurchaseExternalPaymentStateTransitionInput struct {
ChargeID meta.ChargeID
TargetPaymentState payment.Status
}
func (HandleCreditPurchaseExternalPaymentStateTransitionInput) Validate ¶
func (i HandleCreditPurchaseExternalPaymentStateTransitionInput) Validate() error
type ListChargesInput ¶
type ListChargesInput struct {
pagination.Page
Namespace string
CustomerIDs []string
SubscriptionIDs []string
ChargeTypes []meta.ChargeType
StatusIn []meta.ChargeStatus
StatusNotIn []meta.ChargeStatus
IncludeDeleted bool
// OrderBy is the field to sort by. Supported values: id, created_at,
// service_period.from, billing_period.from.
// Defaults to created_at when empty.
OrderBy string
Order sortx.Order
Expands meta.Expands
}
func (ListChargesInput) Validate ¶
func (i ListChargesInput) Validate() error
type ListCustomersToAdvanceInput ¶
type ListCustomersToAdvanceInput struct {
pagination.Page
Namespaces []string
AdvanceAfterLTE time.Time
}
func (ListCustomersToAdvanceInput) Validate ¶
func (i ListCustomersToAdvanceInput) Validate() error
type Service ¶
type Service interface {
ChargeService
// Facade interfaces provide convinience helpers for the API layer.
CreditPurchaseFacadeService
}
Source Files
¶
Click to show internal directories.
Click to hide internal directories.