settle

package
v1.20.3 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2026 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Overview

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. A single implementation keeps the callback and expiry-time settlement semantics from drifting apart.

Index

Constants

View Source
const (
	StatusPending  = uint8(1)
	StatusPaid     = uint8(2)
	StatusFinished = uint8(5)
)

Order status values of the billing state machine.

Variables

This section is empty.

Functions

func ValidateTradeNo

func ValidateTradeNo(tradeNo string) error

ValidateTradeNo rejects malformed or hostile gateway trade numbers.

func VerifiedPayment

func VerifiedPayment(ctx context.Context, orders repository.OrderRepo, queue Queue, orderInfo *order.Order, tradeNo string) error

VerifiedPayment implements settlement idempotency. A settlement may only perform Pending -> Paid. A retry for an already-paid order may recreate a previously failed queue insertion, while the deterministic activation task ID prevents concurrent settlements from activating the order twice. Callers must authenticate the gateway response and verify the order amount first.

Types

type Queue

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

Queue schedules order activation; the module's order queue port satisfies it.

Jump to

Keyboard shortcuts

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