All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 8m6s
49 lines
1.4 KiB
Go
49 lines
1.4 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 {
|
|
PaymentNo string
|
|
Description string
|
|
Amount int64
|
|
ExpireAt time.Time
|
|
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
|
|
PreCreate(ctx context.Context, request OnlinePaymentRequest) (OnlinePaymentResult, error)
|
|
Query(ctx context.Context, paymentNo string, config *model.WechatConfig) (OnlinePaymentQueryResult, error)
|
|
}
|