Documentation
¶
Overview ¶
Package v2 implements the V2 order orchestration subdomain of the billing module: idempotent create-and-checkout, guest checkout capabilities and the SSE event-stream tickets. Only the module facade may reach it.
Index ¶
- Variables
- type Deps
- type Service
- func (s *Service) AuthorizeEventStream(ctx context.Context, orderNo, ticket string) (dto.V2OrderSnapshot, time.Time, error)
- func (s *Service) Checkout(ctx context.Context, orderNo string, req *dto.V2CheckoutOrderRequest) (*dto.V2OrderResponse, error)
- func (s *Service) CreateAndCheckout(ctx context.Context, req *dto.V2CreateOrderRequest, idempotencyKey string) (*dto.V2OrderResponse, error)
- func (s *Service) EventTicket(ctx context.Context, orderNo, checkoutToken string) (*dto.V2EventTicketResponse, error)
- func (s *Service) GetOrder(ctx context.Context, orderNo, checkoutToken string) (*dto.V2OrderResponse, error)
- func (s *Service) Session(ctx context.Context, orderNo, checkoutToken string) (*dto.V2OrderSessionResponse, error)
- type V2OrderLogic
- func (l *V2OrderLogic) AuthorizeEventTicket(orderNo, ticket string) (*orderEntity.Order, error)
- func (l *V2OrderLogic) Checkout(orderNo string, req *dto.V2CheckoutOrderRequest) (*dto.V2OrderResponse, error)
- func (l *V2OrderLogic) CreateAndCheckout(req *dto.V2CreateOrderRequest, idempotencyKey string) (*dto.V2OrderResponse, error)
- func (l *V2OrderLogic) EventTicket(orderNo, checkoutToken string) (*dto.V2EventTicketResponse, error)
- func (l *V2OrderLogic) EventTicketExpiresAt(ticket string) (time.Time, error)
- func (l *V2OrderLogic) GetOrder(orderNo, checkoutToken string) (*dto.V2OrderResponse, error)
- func (l *V2OrderLogic) Session(orderNo, checkoutToken string) (*dto.V2OrderSessionResponse, error)
- func (l *V2OrderLogic) Snapshot(orderInfo *orderEntity.Order) dto.V2OrderSnapshot
Constants ¶
This section is empty.
Variables ¶
var ErrIdempotencyKeyReused = stdErrors.New("idempotency key reused with a different request")
ErrIdempotencyKeyReused is handled as HTTP 409 by the V2 handler. It is a distinct transport condition: the original order remains intact.
Functions ¶
This section is empty.
Types ¶
type Deps ¶
type Deps struct {
Orders repository.OrderRepo
Checkout *checkout.Service
Portal *portal.Service
JwtSecret string
CurrencyUnit func() string
}
Deps declares the orchestration's dependencies: sibling subdomains are invoked directly, never through the facade.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service wraps the per-request orchestration flow.
func NewService ¶
func (*Service) AuthorizeEventStream ¶
func (s *Service) AuthorizeEventStream(ctx context.Context, orderNo, ticket string) (dto.V2OrderSnapshot, time.Time, error)
AuthorizeEventStream validates the self-contained stream capability and returns the stream's initial snapshot together with the ticket expiry; the order entity never leaves the module.
func (*Service) Checkout ¶
func (s *Service) Checkout(ctx context.Context, orderNo string, req *dto.V2CheckoutOrderRequest) (*dto.V2OrderResponse, error)
func (*Service) CreateAndCheckout ¶
func (s *Service) CreateAndCheckout(ctx context.Context, req *dto.V2CreateOrderRequest, idempotencyKey string) (*dto.V2OrderResponse, error)
func (*Service) EventTicket ¶
type V2OrderLogic ¶
V2OrderLogic is the per-request orchestration state.
func (*V2OrderLogic) AuthorizeEventTicket ¶
func (l *V2OrderLogic) AuthorizeEventTicket(orderNo, ticket string) (*orderEntity.Order, error)
AuthorizeEventTicket validates the self-contained stream capability against the current order row. It deliberately does not require a long-lived bearer token in the EventSource URL.
func (*V2OrderLogic) Checkout ¶
func (l *V2OrderLogic) Checkout(orderNo string, req *dto.V2CheckoutOrderRequest) (*dto.V2OrderResponse, error)
func (*V2OrderLogic) CreateAndCheckout ¶
func (l *V2OrderLogic) CreateAndCheckout(req *dto.V2CreateOrderRequest, idempotencyKey string) (*dto.V2OrderResponse, error)
CreateAndCheckout is the V2 orchestration boundary. Existing domain creators still own pricing, inventory and coupon policy; this method only gives them an idempotency context and immediately starts checkout.
func (*V2OrderLogic) EventTicket ¶
func (l *V2OrderLogic) EventTicket(orderNo, checkoutToken string) (*dto.V2EventTicketResponse, error)
func (*V2OrderLogic) EventTicketExpiresAt ¶
func (l *V2OrderLogic) EventTicketExpiresAt(ticket string) (time.Time, error)
func (*V2OrderLogic) GetOrder ¶
func (l *V2OrderLogic) GetOrder(orderNo, checkoutToken string) (*dto.V2OrderResponse, error)
func (*V2OrderLogic) Session ¶
func (l *V2OrderLogic) Session(orderNo, checkoutToken string) (*dto.V2OrderSessionResponse, error)
Session exchanges the durable guest checkout capability for an ordinary session after activation has created the account. It is intentionally a separate JSON endpoint: a long-lived access token must never appear in a browser-visible EventSource URL or SSE event payload.
func (*V2OrderLogic) Snapshot ¶
func (l *V2OrderLogic) Snapshot(orderInfo *orderEntity.Order) dto.V2OrderSnapshot
Snapshot exposes the event-stream's current-state payload without granting access by itself; callers must authorize the ticket before using it.