Help us shape the future of Go! Take the 2026 Go Developer Survey

billing

package
v1.21.2 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2026 License: GPL-3.0 Imports: 24 Imported by: 0

Documentation

Overview

Package billing is the facade of the billing module: orders and their checkout, payment methods and gateway callbacks, coupons, the V2 order orchestration with its event stream, the wallet and the paid-order activation workflow (ADR-001). Admin and public handlers call the same service; access-plane concerns stay in the handlers.

Index

Constants

View Source
const CloseOrderTimeMinutes = checkout.CloseOrderTimeMinutes

CloseOrderTimeMinutes is the payment window of a pending order; the composition root schedules the deferred close after it.

Variables

View Source
var ErrGatewayUnconfirmed = checkout.ErrGatewayUnconfirmed

ErrGatewayUnconfirmed marks a refused close whose order stays pending until the gateway confirms payment; schedulers treat it as an expected outcome.

View Source
var ErrIdempotencyKeyReused = v2orch.ErrIdempotencyKeyReused

ErrIdempotencyKeyReused is handled as HTTP 409 by the V2 handler. It is a distinct transport condition: the original order remains intact.

View Source
var ErrInvalidPaymentCallback = gateway.ErrInvalidCallback

ErrInvalidPaymentCallback marks a rejected gateway callback that cannot be authenticated or does not describe its order, which redelivery cannot change; the notify handler answers a gateway that reads HTTP statuses with 400 for it and 500 for any other failure.

View Source
var ErrTooManyEventStreams = v2orch.ErrTooManyStreams

ErrTooManyEventStreams refuses an order event stream whose ticket already holds its maximum of concurrent streams.

Functions

func ConvertCurrency added in v1.20.2

func ConvertCurrency(from, to, accessKey string, amount float64) (float64, error)

func FormatAmount added in v1.21.0

func FormatAmount(minor int64) string

FormatAmount renders an amount in minor units with two decimal places (1990 → "19.90"). It is the one money formatter of the module, shared with the gateways, so reports and notifications show what was charged.

func NewRepoBuilder added in v1.15.2

func NewRepoBuilder() repository.BillingBuilder

NewRepoBuilder exports the module-owned repository implementations for store assembly (ADR-001 step-6 preparation).

Types

type AffiliateReader

type AffiliateReader = wallet.AffiliateReader

AffiliateReader and AuthMethodReader re-export the wallet subdomain's read-only ports onto the identity domain (referral tree, masked login identifiers); the legacy user repository satisfies both structurally.

type AuthMethodReader

type AuthMethodReader = wallet.AuthMethodReader

AffiliateReader and AuthMethodReader re-export the wallet subdomain's read-only ports onto the identity domain (referral tree, masked login identifiers); the legacy user repository satisfies both structurally.

type CurrencyRateCache added in v1.20.2

type CurrencyRateCache = exchangerate.Cache

CurrencyRateCache is shared with application assembly and the refresh worker. Provider communication remains private to billing.

func NewCurrencyRateCache added in v1.20.2

func NewCurrencyRateCache(rate float64) *CurrencyRateCache

type DailyOrderReport added in v1.15.16

type DailyOrderReport = adminorder.DailyReport

DailyOrderReport and its lines re-export the admin order subdomain's daily summary for the queue shell that formats and delivers it.

type DailyOrderReportLine added in v1.15.16

type DailyOrderReportLine = adminorder.DailyReportLine

DailyOrderReport and its lines re-export the admin order subdomain's daily summary for the queue shell that formats and delivers it.

type Deps

type Deps struct {
	PaidOrders  PaidOrderDependencies
	Orders      repository.OrderRepo
	OrderEvents OrderEventStore
	Payments    repository.PaymentRepo
	Coupons     repository.CouponRepo
	Withdrawals repository.UserWithdrawalRepo
	Plans       PlanReader
	UserSubs    UserSubscriptionReader
	// Store carries the billing-scoped transactions of the order and wallet
	// flows, the wallet view and the inbox markers. Subscription writes are
	// exposed only by the Inventory capability.
	Store     Store
	Inventory checkout.Inventory
	Tx        Transactor
	Queue     OrderQueue
	// Redis carries the outbox's wake-ups to the order event streams and
	// bounds the streams' concurrency.
	Redis *redis.Client
	// SingleModel forbids holding more than one blocking subscription;
	// runtime-mutable, read per request.
	SingleModel func() bool
	// CurrencyUnit is the site currency used for gateway verification;
	// runtime-mutable, read per request.
	CurrencyUnit func() string

	// InvitePolicy snapshots the runtime-mutable site-wide referral
	// fallback for the commission stage; UserProfiles resolves referral
	// settings, and the referrer a refund charges back, from the identity
	// domain.
	InvitePolicy func() (percentage uint8, onlyFirstPurchase bool)
	UserProfiles activation.ProfileReader

	// Wallet-specific dependencies: audit-log statements and the
	// identity-domain read ports. UserCache invalidates the identity
	// module's user cache after a balance checkout.
	Logs        repository.LogRepo
	UserCache   UserCache
	Affiliates  AffiliateReader
	AuthMethods AuthMethodReader

	// Portal-specific dependencies.
	PortalPlans        PortalPlanReader
	GuestAccounts      GuestAccountReader
	Sessions           SessionStore
	GuestCheckoutCache GuestCheckoutCache
	ExchangeRate       ExchangeRateCache
	Portal             PortalConfig
}

Deps declares everything the module needs; the composition root (internal/app) provides them; each field is scoped to the use cases it serves.

type EmailAliasReader added in v1.21.0

type EmailAliasReader = portal.EmailAliasReader

EmailAliasReader is the identity port extension that lets guest purchase refuse other spellings of an existing mailbox.

type ExchangeRateCache

type ExchangeRateCache = portal.ExchangeRateCache

Portal re-exports the guest storefront subdomain's ports and configuration for the composition root.

type GuestAccountReader

type GuestAccountReader = portal.GuestAccountReader

Portal re-exports the guest storefront subdomain's ports and configuration for the composition root.

type GuestCheckoutCache

type GuestCheckoutCache = portal.GuestCheckoutCache

Portal re-exports the guest storefront subdomain's ports and configuration for the composition root.

type GuestVerification added in v1.21.0

type GuestVerification = portal.GuestVerification

Portal re-exports the guest storefront subdomain's ports and configuration for the composition root.

type OrderEventStore added in v1.21.0

type OrderEventStore interface {
	v2orch.EventReader
	orderevents.Outbox
}

OrderEventStore is the durable order-event table: the event streams replay it, the outbox publisher drains it and the retention cleanup prunes it.

type OrderQueue

type OrderQueue interface {
	EnqueueActivation(ctx context.Context, orderNo string) error
	EnqueueDeferredClose(ctx context.Context, orderNo string) error
}

OrderQueue schedules the order lifecycle tasks. The composition root adapts the asynq client; an activation delivery that already exists for the order is not an error (the Paid state is the durable outbox), and a deferred close fires after the pending order's payment window expires.

type OrderStatistics added in v1.21.0

type OrderStatistics interface {
	// OrderRevenueOn, OrderRevenueInMonth and OrderRevenueTotal sum the
	// orders of date's day, of date's month and of all time.
	OrderRevenueOn(ctx context.Context, date time.Time) (order.OrdersTotal, error)
	OrderRevenueInMonth(ctx context.Context, date time.Time) (order.OrdersTotal, error)
	OrderRevenueTotal(ctx context.Context) (order.OrdersTotal, error)
	// DailyOrderRevenue breaks date's month down by day and
	// MonthlyOrderRevenue the last months up to date's by month.
	DailyOrderRevenue(ctx context.Context, date time.Time) ([]order.OrdersTotalWithDate, error)
	MonthlyOrderRevenue(ctx context.Context, date time.Time) ([]order.OrdersTotalWithDate, error)
	// PayingUsersOn, PayingUsersInMonth and PayingUsersTotal count the
	// buyers of new orders and of renewals of date's day, of date's month
	// and of all time.
	PayingUsersOn(ctx context.Context, date time.Time) (newUsers, renewalUsers int64, err error)
	PayingUsersInMonth(ctx context.Context, date time.Time) (newUsers, renewalUsers int64, err error)
	PayingUsersTotal(ctx context.Context) (newUsers, renewalUsers int64, err error)
}

OrderStatistics is the part of the facade the platform's dashboard and the Telegram bot read billing's order figures through, instead of billing's repositories (ADR-001 rule 4). The reads return the repository's results and errors as they are.

type PaidOrderDependencies added in v1.20.3

type PaidOrderDependencies = activation.WorkflowDeps

PaidOrderDependencies supplies the external capabilities of order activation. The billing module binds its own order and profile readers when constructed.

type PaymentCallbackStyle added in v1.21.0

type PaymentCallbackStyle = gateway.CallbackStyle

PaymentNotification is a gateway callback as the notify endpoint received it, and PaymentCallbackStyle how a gateway delivers and answers callbacks.

type PaymentNotification added in v1.21.0

type PaymentNotification = gateway.Notification

PaymentNotification is a gateway callback as the notify endpoint received it, and PaymentCallbackStyle how a gateway delivers and answers callbacks.

type PlanReader

type PlanReader = checkout.PlanReader

PlanReader re-exports the checkout subdomain's port onto the subscription domain's plan catalogue.

type PortalConfig

type PortalConfig = portal.Config

Portal re-exports the guest storefront subdomain's ports and configuration for the composition root.

type PortalPlanReader

type PortalPlanReader = portal.PlanReader

Portal re-exports the guest storefront subdomain's ports and configuration for the composition root.

type RegistrationPolicy added in v1.21.0

type RegistrationPolicy = portal.RegistrationPolicy

RegistrationPolicy is the registration settings a guest purchase follows; the composition root snapshots them per request from the same configuration identity's registration reads.

type Service

type Service interface {
	// OrderStatistics serves the other modules' reads of order figures.
	OrderStatistics

	CreateOrder(ctx context.Context, req *dto.CreateOrderRequest) error
	GetOrderList(ctx context.Context, req *dto.GetOrderListRequest) (*dto.GetOrderListResponse, error)
	// UpdateOrderStatus applies the admin's Pending->Paid transition and
	// enqueues activation, or closes the order through the same close flow
	// as owner and expiry closes.
	UpdateOrderStatus(ctx context.Context, req *dto.UpdateOrderStatusRequest) error

	CreatePaymentMethod(ctx context.Context, req *dto.CreatePaymentMethodRequest) (*dto.PaymentConfig, error)
	UpdatePaymentMethod(ctx context.Context, req *dto.UpdatePaymentMethodRequest) (*dto.PaymentConfig, error)
	DeletePaymentMethod(ctx context.Context, req *dto.DeletePaymentMethodRequest) error
	GetPaymentMethodList(ctx context.Context, req *dto.GetPaymentMethodListRequest) (*dto.GetPaymentMethodListResponse, error)
	GetPaymentPlatform(ctx context.Context) (*dto.PaymentPlatformResponse, error)

	CreateCoupon(ctx context.Context, req *dto.CreateCouponRequest) error
	UpdateCoupon(ctx context.Context, req *dto.UpdateCouponRequest) error
	DeleteCoupon(ctx context.Context, req *dto.DeleteCouponRequest) error
	BatchDeleteCoupon(ctx context.Context, req *dto.BatchDeleteCouponRequest) error
	GetCouponList(ctx context.Context, req *dto.GetCouponListRequest) (*dto.GetCouponListResponse, error)

	// The user-facing order queries resolve the current user from the request
	// context, enforce ownership and never expose referrer commission.
	QueryOrderDetail(ctx context.Context, req *dto.QueryOrderDetailRequest) (*dto.OrderDetail, error)
	QueryOrderList(ctx context.Context, req *dto.QueryOrderListRequest) (*dto.QueryOrderListResponse, error)

	// The checkout flows resolve the current user from the request context.
	Purchase(ctx context.Context, req *dto.PurchaseOrderRequest) (*dto.PurchaseOrderResponse, error)
	Renewal(ctx context.Context, req *dto.RenewalOrderRequest) (*dto.RenewalOrderResponse, error)
	ResetTraffic(ctx context.Context, req *dto.ResetTrafficOrderRequest) (*dto.ResetTrafficOrderResponse, error)
	Recharge(ctx context.Context, req *dto.RechargeOrderRequest) (*dto.RechargeOrderResponse, error)
	PreCreateOrder(ctx context.Context, req *dto.PurchaseOrderRequest) (*dto.PreOrderResponse, error)
	// CloseOrder settles gateway-collected money instead of closing, releases
	// coupon and gift reservations, and returns reserved plan inventory.
	CloseOrder(ctx context.Context, req *dto.CloseOrderRequest) error

	// The portal flows serve the guest storefront; checkout resolves the
	// client IP from the request context.
	PortalPurchase(ctx context.Context, req *dto.PortalPurchaseRequest) (*dto.PortalPurchaseResponse, error)
	PortalPrePurchase(ctx context.Context, req *dto.PrePurchaseOrderRequest) (*dto.PrePurchaseOrderResponse, error)
	PortalCheckout(ctx context.Context, req *dto.CheckoutOrderRequest) (*dto.CheckoutOrderResponse, error)
	QueryPurchaseOrder(ctx context.Context, req *dto.QueryPurchaseOrderRequest) (*dto.QueryPurchaseOrderResponse, error)
	GetAvailablePaymentMethods(ctx context.Context) (*dto.GetAvailablePaymentMethodsResponse, error)
	GetPortalSubscription(ctx context.Context, req *dto.GetSubscriptionRequest) (*dto.GetSubscriptionResponse, error)
	// IssuePortalSession exchanges a completed guest purchase for a normal
	// authenticated session.
	IssuePortalSession(ctx context.Context, userID int64) (string, error)

	// FindPaymentMethodByToken reads the payment method whose notify URL
	// carries token, with the repository's error unwrapped: the notify
	// middleware resolves a callback's method with it and answers a failed
	// lookup with that error.
	FindPaymentMethodByToken(ctx context.Context, token string) (*paymentEntity.Payment, error)
	// PaymentNotify authenticates and settles a gateway callback. It reads
	// the payment method the notify middleware resolved from the request
	// context; every gateway goes through the same verification.
	PaymentNotify(ctx context.Context, notification PaymentNotification) error
	// PaymentCallbackStyle reports how a platform delivers its callbacks and
	// expects them answered; false for a platform without a gateway.
	PaymentCallbackStyle(platform string) (PaymentCallbackStyle, bool)

	// The V2 orchestration: idempotent create-and-checkout, guest checkout
	// capabilities and SSE event-stream tickets.
	V2CreateAndCheckout(ctx context.Context, req *dto.V2CreateOrderRequest, idempotencyKey string) (*dto.V2OrderResponse, error)
	V2Checkout(ctx context.Context, orderNo string, req *dto.V2CheckoutOrderRequest) (*dto.V2OrderResponse, error)
	V2GetOrder(ctx context.Context, orderNo, checkoutToken string) (*dto.V2OrderResponse, error)
	V2EventTicket(ctx context.Context, orderNo, checkoutToken string) (*dto.V2EventTicketResponse, error)
	V2Session(ctx context.Context, orderNo, checkoutToken string) (*dto.V2OrderSessionResponse, error)
	// V2StreamOrderEvents serves an order's event stream to sink until ctx
	// ends or the ticket expires: the snapshot, the events after the replay
	// cursor, then live events. It returns an error only when the stream is
	// refused, before anything reached the sink (ErrTooManyEventStreams
	// when the ticket holds its maximum of concurrent streams).
	V2StreamOrderEvents(ctx context.Context, req V2EventStreamRequest, sink V2EventSink) error

	// PublishOrderEvents drains the order-event outbox the streams replay:
	// it broadcasts the oldest unpublished events, 500 at most, on their
	// orders' Redis channels to wake the streams, marking each published.
	// The first failure ends the run with its error, and the next run
	// publishes what this one did not. CleanupOrderEvents deletes the
	// published events created before cutoff and reports how many; an
	// unpublished event is kept whatever its age.
	PublishOrderEvents(ctx context.Context) error
	CleanupOrderEvents(ctx context.Context, cutoff time.Time) (int64, error)

	// The wallet flows resolve the current user from the request context:
	// commission withdrawal, balance/commission statements and the affiliate
	// earnings overview.
	CommissionWithdraw(ctx context.Context, req *dto.CommissionWithdrawRequest) (*dto.WithdrawalLog, error)
	QueryUserBalanceLog(ctx context.Context) (*dto.QueryUserBalanceLogListResponse, error)
	QueryUserCommissionLog(ctx context.Context, req *dto.QueryUserCommissionLogListRequest) (*dto.QueryUserCommissionLogListResponse, error)
	QueryWithdrawalLog(ctx context.Context, req *dto.QueryWithdrawalLogListRequest) (*dto.QueryWithdrawalLogListResponse, error)
	GetWithdrawalList(ctx context.Context, req *dto.GetWithdrawalListRequest) (*dto.GetWithdrawalListResponse, error)
	ReviewWithdrawal(ctx context.Context, req *dto.ReviewWithdrawalRequest) error
	QueryUserAffiliate(ctx context.Context) (*dto.QueryUserAffiliateCountResponse, error)
	QueryUserAffiliateList(ctx context.Context, req *dto.QueryUserAffiliateListRequest) (*dto.QueryUserAffiliateListResponse, error)

	// The wallet as other modules reach it (ADR-001 rules 2 and 4): they read
	// the billing-owned wallet table and move money only through these
	// methods, each movement in a billing transaction of its own that runs
	// after the requesting module committed its part.
	//
	// FindWallet reads a user's wallet; a user without a wallet row reads as
	// nil. FindWallets reads several; users without a row are absent from
	// the map.
	FindWallet(ctx context.Context, userID int64) (*walletEntity.Wallet, error)
	FindWallets(ctx context.Context, userIDs []int64) (map[int64]*walletEntity.Wallet, error)
	// OpenWallet sets the opening balance, gift amount and commission of an
	// account an administrator created. AdjustWallet applies an
	// administrator's wallet edit: under the wallet lock each amount the
	// adjustment sets becomes the wallet's, with an audit log recording the
	// change and the resulting amount; amounts left nil or already equal are
	// left alone.
	OpenWallet(ctx context.Context, opening walletEntity.Wallet) error
	AdjustWallet(ctx context.Context, adjustment walletEntity.Adjustment) error
	// UnsubscribeRefundSettled reports whether the refund of a cancelled user
	// subscription was settled. SettleUnsubscribeRefund settles it: amount,
	// capped at what the order and its paid renewals cost, goes back to the
	// buyer's wallet (gift amount first for a balance-paid order), the
	// referrer loses the commission share the refund takes back, and the
	// refund marker is recorded, all in one billing transaction. A
	// subscription without an order (orderID 0) only gets the marker; a
	// second settlement fails on it.
	UnsubscribeRefundSettled(ctx context.Context, subscriptionID int64) (bool, error)
	SettleUnsubscribeRefund(ctx context.Context, userID, subscriptionID, orderID, amount int64) error
	// QuotaGiftCredited reports whether a quota task's gift for a
	// subscription was credited. CreditQuotaGift credits amount to the gift
	// balance of the subscription's owner with its gift log dated at, exactly
	// once per (task, subscription); a zero amount only records the marker.
	QuotaGiftCredited(ctx context.Context, taskID, subscriptionID int64) (bool, error)
	CreditQuotaGift(ctx context.Context, taskID, subscriptionID, userID, amount int64, at time.Time) error

	// The order reads of the subscription module's fulfillment and refund
	// quote: an order by id or number, and an order with its renewals.
	FindOrder(ctx context.Context, id int64) (*order.Order, error)
	FindOrderByNo(ctx context.Context, orderNo string) (*order.Order, error)
	FindOrderDetails(ctx context.Context, id int64) (*order.Details, error)
	// OrdersByStatusAfter pages the orders in status by ascending id: at most
	// limit (1000 when limit is outside 1..1000) of those after afterID. The
	// pending and paid reconcilers walk their orders with it.
	OrdersByStatusAfter(ctx context.Context, status uint8, afterID int64, limit int) ([]*order.Order, error)

	// The billing-owned paid-order workflow and its idempotent stages:
	// recharge credit, referral commission and final settlement.
	ActivatePaidOrder(ctx context.Context, orderNo string) error
	ActivateRecharge(ctx context.Context, orderNo string) (balance int64, err error)
	SettleOrderCommission(ctx context.Context, orderNo string, buyerID int64) error
	FinalizeOrder(ctx context.Context, orderNo string) error

	// DailyOrderReport totals one day's settled orders for the operations
	// report; plan names are resolved so the caller only formats.
	DailyOrderReport(ctx context.Context, date time.Time) (*DailyOrderReport, error)
}

Service is the only surface other code may depend on; the implementation lives under internal/ where the compiler seals it off.

func New

func New(deps Deps) Service

type SessionStore

type SessionStore = portal.SessionStore

Portal re-exports the guest storefront subdomain's ports and configuration for the composition root.

type Store added in v1.20.3

type Store interface {
	InBillingTx(ctx context.Context, fn func(repository.BillingStore) error) error
	Inbox() repository.InboxRepo
	Wallet() repository.WalletRepo
}

Store is the persistence capability the order and wallet flows need beyond their repositories: billing-scoped transactions, the wallet view and the inbox. It excludes unrelated repositories and application-wide transactions.

type Transactor

type Transactor interface {
	InBillingTx(ctx context.Context, fn func(repository.BillingStore) error) error
}

Transactor is the module's window onto billing-scoped transactions; the repository store satisfies it structurally.

type UserCache added in v1.21.0

type UserCache interface {
	ClearUserCache(ctx context.Context, userIDs ...int64) error
}

UserCache drops the identity module's cached projection of users after a wallet movement changed what it shows; the identity facade provides it.

type UserSubscriptionReader

type UserSubscriptionReader = checkout.UserSubscriptionReader

UserSubscriptionReader re-exports the checkout subdomain's port onto the subscription domain's user subscriptions.

type V2EventSink added in v1.21.0

type V2EventSink = v2orch.EventSink

V2EventStreamRequest names an order event stream and V2EventSink receives its events.

type V2EventStreamRequest added in v1.21.0

type V2EventStreamRequest = v2orch.StreamRequest

V2EventStreamRequest names an order event stream and V2EventSink receives its events.

Directories

Path Synopsis
Package dto is the billing module's contract: the commands, queries and results of its facade and HTTP handlers, and the billing-owned read-only snapshots of other domains' data it returns.
Package dto is the billing module's contract: the commands, queries and results of its facade and HTTP handlers, and the billing-owned read-only snapshots of other domains' data it returns.
entity
coupon
Package coupon holds the billing domain's coupon entity: a discount code with its validity window, usage limits and the plans it applies to.
Package coupon holds the billing domain's coupon entity: a discount code with its validity window, usage limits and the plans it applies to.
order
Package order holds the billing domain's order entities and the rules that travel with them: the order and its details, the status state machine, order numbers, the durable order events and their wake-up channels, and the guest checkout data an order carries until the guest's account exists.
Package order holds the billing domain's order entities and the rules that travel with them: the order and its details, the status state machine, order numbers, the durable order events and their wake-up channels, and the guest checkout data an order carries until the guest's account exists.
payment
Package payment holds the billing domain's payment method entity and the stored configuration of each gateway it can be bound to.
Package payment holds the billing domain's payment method entity and the stored configuration of each gateway it can be bound to.
wallet
Package wallet holds the billing domain's money entities: the wallet row (the single source of truth for balance/gift/commission since migration 02144) and withdrawal records (ADR-001 step 5).
Package wallet holds the billing domain's money entities: the wallet row (the single source of truth for balance/gift/commission since migration 02144) and withdrawal records (ADR-001 step 5).
internal
activation
Package activation owns the paid-order activation workflow and implements its billing-domain stages: the recharge wallet credit, the referral commission and the final settlement.
Package activation owns the paid-order activation workflow and implements its billing-domain stages: the recharge wallet credit, the referral commission and the final settlement.
adminorder
Package adminorder implements the admin-side order management subdomain of the billing module.
Package adminorder implements the admin-side order management subdomain of the billing module.
adminpayment
Package adminpayment implements the payment-method management subdomain of the billing module.
Package adminpayment implements the payment-method management subdomain of the billing module.
billingtest
Package billingtest provides the billing module's behaviour-test harness: the real repository store over a private SQLite database and a miniredis instance, with seeding helpers for the rows order flows read.
Package billingtest provides the billing module's behaviour-test harness: the real repository store over a private SQLite database and a miniredis instance, with seeding helpers for the rows order flows read.
callbacks
Package callbacks implements the payment gateway callback subdomain of the billing module: it authenticates gateway notifications, verifies them against the order's immutable payment expectation, re-confirms with the gateway and settles the payment.
Package callbacks implements the payment gateway callback subdomain of the billing module: it authenticates gateway notifications, verifies them against the order's immutable payment expectation, re-confirms with the gateway and settles the payment.
checkout
Package checkout implements the user-facing money flows of the billing module: purchase, renewal, traffic reset, recharge, order preview and close.
Package checkout implements the user-facing money flows of the billing module: purchase, renewal, traffic reset, recharge, order preview and close.
coupon
Package coupon implements the coupon management subdomain of the billing module.
Package coupon implements the coupon management subdomain of the billing module.
exchangerate
Package exchangerate converts the site currency for gateways that collect another one: the apilayer conversion API and the cache of the refreshed CNY rate that checkout reads first.
Package exchangerate converts the site currency for gateways that collect another one: the apilayer conversion API and the cache of the refreshed CNY rate that checkout reads first.
gateway
Package gateway is the billing module's single seam onto payment gateways.
Package gateway is the billing module's single seam onto payment gateways.
ledger
Package ledger writes the wallet movement records of the billing module: every gift-credit and balance change an order makes is recorded here, with the same shape, timestamp and remark vocabulary.
Package ledger writes the wallet movement records of the billing module: every gift-credit and balance change an order makes is recorded here, with the same shape, timestamp and remark vocabulary.
orderaudit
Package orderaudit writes the durable audit record created alongside an order.
Package orderaudit writes the durable audit record created alongside an order.
ordercontext
Package ordercontext carries the idempotency metadata of a V2 order creation through the request context into the order creators V1 and V2 share; a V1 request carries none.
Package ordercontext carries the idempotency metadata of a V2 order creation through the request context into the order creators V1 and V2 share; a V1 request carries none.
orderevents
Package orderevents runs billing's order-event outbox.
Package orderevents runs billing's order-event outbox.
payment
Package payment holds what every payment gateway protocol shares: the supported platforms and their names, and the money conversions between the minor units orders count and the decimal amounts gateways exchange.
Package payment holds what every payment gateway protocol shares: the supported platforms and their names, and the money conversions between the minor units orders count and the decimal amounts gateways exchange.
payment/alipay
Package alipay implements the Alipay face-to-face payment protocol: QR code trade creation, trade query and close, and signed notification decoding.
Package alipay implements the Alipay face-to-face payment protocol: QR code trade creation, trade query and close, and signed notification decoding.
payment/cryptomus
Package cryptomus implements the Cryptomus crypto-payment gateway protocol: invoice creation, invoice lookup and webhook signature verification.
Package cryptomus implements the Cryptomus crypto-payment gateway protocol: invoice creation, invoice lookup and webhook signature verification.
payment/epay
Package epay implements the EPay payment protocol: signed payment URLs, callback signature verification and the order query, with the EasyPay-compatible query as a fallback.
Package epay implements the EPay payment protocol: signed payment URLs, callback signature verification and the order query, with the EasyPay-compatible query as a fallback.
payment/epay/protocol
Package protocol implements EPay V1 and V2 using Go's standard library.
Package protocol implements EPay V1 and V2 using Go's standard library.
payment/stripe
Package stripe implements the Stripe payment protocol: payment intents and their payment sheets, customers, webhook endpoints and signed webhook events.
Package stripe implements the Stripe payment protocol: payment intents and their payment sheets, customers, webhook endpoints and signed webhook events.
portal
Package portal implements the guest storefront subdomain of the billing module: guest pre-orders, gateway/balance checkout, order status polling with session exchange, and the public plan/payment listings.
Package portal implements the guest storefront subdomain of the billing module: guest pre-orders, gateway/balance checkout, order status polling with session exchange, and the public plan/payment listings.
pricing
Package pricing decides what an order costs.
Package pricing decides what an order costs.
repo
Package repo holds the billing module's repository implementations over GORM: orders with their event outbox, payment methods, coupons, and the wallet and withdrawal rows.
Package repo holds the billing module's repository implementations over GORM: orders with their event outbox, payment methods, coupons, and the wallet and withdrawal rows.
settle
Package settle holds the one settlement primitive shared by the checkout and payment-callback subdomains: marking a gateway-verified payment as paid and enqueueing activation.
Package settle holds the one settlement primitive shared by the checkout and payment-callback subdomains: marking a gateway-verified payment as paid and enqueueing activation.
userorder
Package userorder implements the user-facing order query subdomain of the billing module.
Package userorder implements the user-facing order query subdomain of the billing module.
v2
Package v2 implements the V2 order orchestration subdomain of the billing module: idempotent create-and-checkout, guest checkout capabilities, the SSE event-stream tickets and the event stream itself.
Package v2 implements the V2 order orchestration subdomain of the billing module: idempotent create-and-checkout, guest checkout capabilities, the SSE event-stream tickets and the event stream itself.
wallet
Package wallet implements the wallet subdomain of the billing module: the user-facing commission withdrawal, balance/commission statements and affiliate earnings overview, and the wallet reads and money movements other modules request from billing (ADR-001 rules 2 and 4) — the administrator's wallet edits, cancellation refunds and quota-task gifts, each committed in a billing transaction of its own.
Package wallet implements the wallet subdomain of the billing module: the user-facing commission withdrawal, balance/commission statements and affiliate earnings overview, and the wallet reads and money movements other modules request from billing (ADR-001 rules 2 and 4) — the administrator's wallet edits, cancellation refunds and quota-task gifts, each committed in a billing transaction of its own.
transport
http
Package handler registers the billing module's payment gateway callback routes.
Package handler registers the billing module's payment gateway callback routes.
http/admin/coupon
Package coupon holds the HTTP handlers of the admin coupon API; they adapt requests to the billing facade.
Package coupon holds the HTTP handlers of the admin coupon API; they adapt requests to the billing facade.
http/admin/order
Package order holds the HTTP handlers of the admin order API; they adapt requests to the billing facade.
Package order holds the HTTP handlers of the admin order API; they adapt requests to the billing facade.
http/admin/payment
Package payment holds the HTTP handlers of the admin payment method API; they adapt requests to the billing facade.
Package payment holds the HTTP handlers of the admin payment method API; they adapt requests to the billing facade.
http/admin/withdrawal
Package withdrawal holds the HTTP handlers of the admin commission withdrawal review API; they adapt requests to the billing facade.
Package withdrawal holds the HTTP handlers of the admin commission withdrawal review API; they adapt requests to the billing facade.
http/notify
Package notify holds the HTTP handler that receives payment gateway callbacks and hands them to the billing facade to authenticate and settle.
Package notify holds the HTTP handler that receives payment gateway callbacks and hands them to the billing facade to authenticate and settle.
http/public/order
Package order holds the HTTP handlers of the user order API, V1 and the V2 create-and-checkout orchestration with its event stream; they adapt requests to the billing facade.
Package order holds the HTTP handlers of the user order API, V1 and the V2 create-and-checkout orchestration with its event stream; they adapt requests to the billing facade.
http/public/payment
Package payment holds the HTTP handler listing the payment methods a signed-in user can pay with.
Package payment holds the HTTP handler listing the payment methods a signed-in user can pay with.
http/public/portal
Package portal holds the HTTP handlers of the guest storefront API: plans, payment methods, guest orders, their checkout and status; they adapt requests to the billing facade.
Package portal holds the HTTP handlers of the guest storefront API: plans, payment methods, guest orders, their checkout and status; they adapt requests to the billing facade.
http/public/user
Package user holds the HTTP handlers of the user wallet API: commission withdrawal, balance, commission and withdrawal statements, and the affiliate overview; they adapt requests to the billing facade.
Package user holds the HTTP handlers of the user wallet API: commission withdrawal, balance, commission and withdrawal statements, and the affiliate overview; they adapt requests to the billing facade.

Jump to

Keyboard shortcuts

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