v2

package
v1.15.16 Latest Latest
Warning

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

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

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

Constants

This section is empty.

Variables

View Source
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 NewService(deps Deps) *Service

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

func (s *Service) EventTicket(ctx context.Context, orderNo, checkoutToken string) (*dto.V2EventTicketResponse, error)

func (*Service) GetOrder

func (s *Service) GetOrder(ctx context.Context, orderNo, checkoutToken string) (*dto.V2OrderResponse, error)

func (*Service) Session

func (s *Service) Session(ctx context.Context, orderNo, checkoutToken string) (*dto.V2OrderSessionResponse, error)

type V2OrderLogic

type V2OrderLogic struct {
	logger.Logger
	// contains filtered or unexported fields
}

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.

Jump to

Keyboard shortcuts

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