Files
junhong_cmp_fiber/internal/application/agentrecharge/online_payment.go
break 8fc667daee
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 8m7s
让代理充值复用现有网页支付能力
微信按当前 v2/v3 配置分别生成 MWEB/H5 链接,支付宝复用 C 端 WAP 链接,并让可用支付方式基于生效配置判断。

Constraint: 支付链接统一通过 qr_content 返回,由前端渲染二维码;按要求不运行测试

Rejected: 微信 Native 与支付宝当面付 | 会引入非当前商户配置所需的额外产品开通

Confidence: high

Scope-risk: moderate

Directive: 微信 H5/MWEB 二维码仅承诺系统相机或外部浏览器扫码链路

Tested: 相关 Go 包编译通过;gofmt 与 git diff --check 通过

Not-tested: 按用户要求未运行自动化测试及真实支付联调
2026-07-30 11:41:50 +08:00

52 lines
1.5 KiB
Go

package agentrecharge
import (
"context"
"time"
"github.com/break/junhong_cmp_fiber/internal/model"
)
const (
// OnlinePaymentStatePending 表示渠道仍在等待付款。
OnlinePaymentStatePending = "pending"
// OnlinePaymentStatePaid 表示渠道已确认收款。
OnlinePaymentStatePaid = "paid"
// OnlinePaymentStateClosed 表示渠道订单已明确关闭。
OnlinePaymentStateClosed = "closed"
// OnlinePaymentStateUnknown 表示渠道状态暂时无法确定。
OnlinePaymentStateUnknown = "unknown"
)
// OnlinePaymentRequest 描述生成支付链接与主动查单所需的最小事实。
type OnlinePaymentRequest struct {
PaymentID uint
PaymentNo string
CorrelationID string
Description string
Amount int64
ExpireAt time.Time
PayerClientIP string
Config *model.WechatConfig
}
// OnlinePaymentResult 描述渠道返回的支付链接。
type OnlinePaymentResult struct {
QRContent string
}
// OnlinePaymentQueryResult 描述统一后的渠道支付状态。
type OnlinePaymentQueryResult struct {
State string
ThirdPartyTradeNo string
Amount int64
PaidAt *time.Time
}
// OnlinePaymentPort 定义代理在线充值需要的最小渠道能力。
type OnlinePaymentPort interface {
Available(config *model.WechatConfig) bool
CreatePaymentURL(ctx context.Context, request OnlinePaymentRequest) (OnlinePaymentResult, error)
Query(ctx context.Context, request OnlinePaymentRequest) (OnlinePaymentQueryResult, error)
}