settle

package
v1.21.6 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 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

This section is empty.

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 Orders, 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 Orders added in v1.21.0

type Orders interface {
	FindOneByOrderNo(ctx context.Context, orderNo string) (*order.Order, error)
	MarkOrderPaid(ctx context.Context, orderNo, tradeNo string) (bool, error)
}

Orders is the order persistence settlement needs.

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