Compare commits

...

14 Commits

2
.gitignore vendored

@ -6,4 +6,4 @@
*.log
gomod.sh
*_test.go
/vendor/
/vendor/

@ -1,38 +1,25 @@
package wechatpayopen
import (
"go.dtapp.net/dorm"
"go.dtapp.net/golog"
"go.dtapp.net/gorequest"
)
// client *dorm.GormClient
type gormClientFun func() *dorm.GormClient
// client *dorm.MongoClient
// databaseName string
type mongoClientFun func() (*dorm.MongoClient, string)
// ClientConfig 实例配置
type ClientConfig struct {
SpAppid string // 服务商应用ID
SpMchId string // 服务商户号
ApiV2 string // APIv2密钥
ApiV3 string // APIv3密钥
SerialNo string // 序列号
MchSslSerialNo string // pem 证书号
MchSslCer string // pem 内容
MchSslKey string // pem key 内容
GormClientFun gormClientFun // 日志配置
MongoClientFun mongoClientFun // 日志配置
Debug bool // 日志开关
ZapLog *golog.ZapLog // 日志服务
SpAppid string // 服务商应用ID
SpMchId string // 服务商户号
ApiV2 string // APIv2密钥
ApiV3 string // APIv3密钥
SerialNo string // 序列号
MchSslSerialNo string // pem 证书号
MchSslCer string // pem 内容
MchSslKey string // pem key 内容
}
// Client 实例
type Client struct {
requestClient *gorequest.App // 请求服务
zapLog *golog.ZapLog // 日志服务
config struct {
spAppid string // 服务商应用ID
spMchId string // 服务商户号
@ -46,23 +33,16 @@ type Client struct {
mchSslKey string // pem key 内容
}
log struct {
gorm bool // 日志开关
gormClient *dorm.GormClient // 日志数据库
logGormClient *golog.ApiClient // 日志服务
mongo bool // 日志开关
mongoClient *dorm.MongoClient // 日志数据库
logMongoClient *golog.ApiClient // 日志服务
status bool // 状态
client *golog.ApiClient // 日志服务
}
}
// NewClient 创建实例化
func NewClient(config *ClientConfig) (*Client, error) {
var err error
c := &Client{}
c.zapLog = config.ZapLog
c.config.spAppid = config.SpAppid
c.config.spMchId = config.SpMchId
c.config.apiV2 = config.ApiV2
@ -74,37 +54,5 @@ func NewClient(config *ClientConfig) (*Client, error) {
c.requestClient = gorequest.NewHttp()
gormClient := config.GormClientFun()
if gormClient != nil && gormClient.Db != nil {
c.log.logGormClient, err = golog.NewApiGormClient(&golog.ApiGormClientConfig{
GormClientFun: func() (*dorm.GormClient, string) {
return gormClient, logTable
},
Debug: config.Debug,
ZapLog: c.zapLog,
})
if err != nil {
return nil, err
}
c.log.gorm = true
c.log.gormClient = gormClient
}
mongoClient, databaseName := config.MongoClientFun()
if mongoClient != nil && mongoClient.Db != nil {
c.log.logMongoClient, err = golog.NewApiMongoClient(&golog.ApiMongoClientConfig{
MongoClientFun: func() (*dorm.MongoClient, string, string) {
return mongoClient, databaseName, logTable
},
Debug: config.Debug,
ZapLog: c.zapLog,
})
if err != nil {
return nil, err
}
c.log.mongo = true
c.log.mongoClient = mongoClient
}
return c, nil
}

@ -0,0 +1,14 @@
package wechatpayopen
import (
"go.dtapp.net/golog"
)
// ConfigApiClientFun 日志配置
func (c *Client) ConfigApiClientFun(apiClientFun golog.ApiClientFun) {
apiClient := apiClientFun()
if apiClient != nil {
c.log.client = apiClient
c.log.status = true
}
}

@ -1,38 +1,15 @@
package wechatpayopen
import "time"
// 微信支付 API 地址
const (
apiUrl = "https://api.mch.weixin.qq.com"
WechatPayAPIServerBackup = "https://api2.mch.weixin.qq.com" // 微信支付 API 备份地址
)
const (
logTable = "wechatpayopen"
)
// SDK 相关信息
const (
Version = "1.0.14" // SDK 版本
UserAgentFormat = "WechatPay-Go/%s (%s) GO/%s" // UserAgent中的信息
)
// HTTP 请求报文 Header 相关常量
const (
Authorization = "Authorization" // Header 中的 Authorization 字段
Accept = "Accept" // Header 中的 Accept 字段
ContentType = "Content-Type" // Header 中的 ContentType 字段
ContentLength = "Content-Length" // Header 中的 ContentLength 字段
UserAgent = "User-Agent" // Header 中的 UserAgent 字段
)
// 常用 ContentType
const (
ApplicationJSON = "application/json"
ImageJPG = "image/jpg"
ImagePNG = "image/png"
VideoMP4 = "video/mp4"
LogTable = "wechatpayopen"
Version = "1.0.27" // SDK 版本
)
// 请求报文签名相关常量
@ -42,21 +19,6 @@ const (
HeaderAuthorizationFormat = "%s mchid=\"%s\",nonce_str=\"%s\",timestamp=\"%d\",serial_no=\"%s\",signature=\"%s\""
)
// HTTP 应答报文 Header 相关常量
const (
WechatPayTimestamp = "Wechatpay-Timestamp" // 微信支付回包时间戳
WechatPayNonce = "Wechatpay-Nonce" // 微信支付回包随机字符串
WechatPaySignature = "Wechatpay-Signature" // 微信支付回包签名信息
WechatPaySerial = "Wechatpay-Serial" // 微信支付回包平台序列号
RequestID = "Request-Id" // 微信支付回包请求ID
)
// 时间相关常量
const (
FiveMinute = 5 * 60 // 回包校验最长时间(秒)
DefaultTimeout = 30 * time.Second // HTTP 请求默认超时时间
)
func getAuthorizationType() string {
return "WECHATPAY2-" + algorithm()
}
@ -66,11 +28,26 @@ func algorithm() string {
return "SHA256-RSA2048"
}
// 接口状态
const (
CodeSuccess = "SUCCESS"
CodeSUCCESS = "SUCCESS" // 支付成功 退款成功
CodeREFUND = "REFUND" // 转入退款
CodeNOTPAY = "NOTPAY" // 未支付
CodeCLOSED = "CLOSED" // 已关闭 退款关闭
CodeREVOKED = "REVOKED" // 已撤销
CodeUSERPAYING = "USERPAYING" // 用户支付中
CodePAYERROR = "PAYERROR" // 支付失败
CodePROCESSING = "PROCESSING" // 退款处理中
CodeABNORMAL = "ABNORMAL" // 退款异常
)
type ApiError struct {
Code string `json:"code"`
Message string `json:"message"`
}
const (
MERCHANT_ID = "MERCHANT_ID"
PERSONAL_OPENID = "PERSONAL_OPENID"
PERSONAL_SUB_OPENID = "PERSONAL_SUB_OPENID"
)

@ -1,5 +1,7 @@
package wechatpayopen
import "go.dtapp.net/golog"
func (c *Client) GetSpAppid() string {
return c.config.spAppid
}
@ -23,3 +25,11 @@ func (c *Client) GetMchSslKey() string {
func (c *Client) GetMchSslSerialNo() string {
return c.config.mchSslSerialNo
}
func (c *Client) GetApiV3() string {
return c.config.apiV3
}
func (c *Client) GetLog() *golog.ApiClient {
return c.log.client
}

@ -4,11 +4,10 @@ go 1.19
require (
github.com/gin-gonic/gin v1.8.1
go.dtapp.net/dorm v1.0.32
go.dtapp.net/goip v1.0.28
go.dtapp.net/golog v1.0.67
go.dtapp.net/dorm v1.0.51
go.dtapp.net/golog v1.0.101
go.dtapp.net/gorandom v1.0.1
go.dtapp.net/gorequest v1.0.28
go.dtapp.net/gorequest v1.0.33
)
require (
@ -17,10 +16,11 @@ require (
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
github.com/gin-contrib/sse v0.1.0 // indirect
github.com/go-ole/go-ole v1.2.6 // indirect
github.com/go-playground/locales v0.14.0 // indirect
github.com/go-playground/universal-translator v0.18.0 // indirect
github.com/go-playground/validator/v10 v10.11.0 // indirect
github.com/go-redis/redis/v9 v9.0.0-beta.2 // indirect
github.com/go-playground/validator/v10 v10.11.1 // indirect
github.com/go-redis/redis/v9 v9.0.0-rc.1 // indirect
github.com/go-sql-driver/mysql v1.6.0 // indirect
github.com/goccy/go-json v0.9.11 // indirect
github.com/golang/snappy v0.0.4 // indirect
@ -36,7 +36,7 @@ require (
github.com/jinzhu/inflection v1.0.0 // indirect
github.com/jinzhu/now v1.1.5 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/compress v1.15.9 // indirect
github.com/klauspost/compress v1.15.11 // indirect
github.com/leodido/go-urn v1.2.1 // indirect
github.com/lib/pq v1.10.7 // indirect
github.com/mattn/go-isatty v0.0.16 // indirect
@ -44,14 +44,19 @@ require (
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/montanaflynn/stats v0.6.6 // indirect
github.com/natefinch/lumberjack v2.0.0+incompatible // indirect
github.com/oschwald/geoip2-golang v1.8.0 // indirect
github.com/oschwald/maxminddb-golang v1.10.0 // indirect
github.com/pelletier/go-toml/v2 v2.0.5 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/saracen/go7z v0.0.0-20191010121135-9c09b6bd7fda // indirect
github.com/saracen/solidblock v0.0.0-20190426153529-45df20abab6f // indirect
github.com/segmentio/fasthash v1.0.3 // indirect
github.com/shiena/ansicolor v0.0.0-20200904210342-c7312218db18 // indirect
github.com/shirou/gopsutil v3.21.11+incompatible // indirect
github.com/sirupsen/logrus v1.9.0 // indirect
github.com/syndtr/goleveldb v1.0.0 // indirect
github.com/tklauser/go-sysconf v0.3.10 // indirect
github.com/tklauser/numcpus v0.5.0 // indirect
github.com/tmthrgd/go-hex v0.0.0-20190904060850-447a3041c3bc // indirect
github.com/ugorji/go/codec v1.2.7 // indirect
github.com/ulikunitz/xz v0.5.10 // indirect
@ -66,25 +71,27 @@ require (
github.com/xdg-go/scram v1.1.1 // indirect
github.com/xdg-go/stringprep v1.0.3 // indirect
github.com/youmark/pkcs8 v0.0.0-20201027041543-1326539a0a0a // indirect
github.com/yusufpapurcu/wmi v1.2.2 // indirect
go.dtapp.net/goip v1.0.38 // indirect
go.dtapp.net/gostring v1.0.10 // indirect
go.dtapp.net/gotime v1.0.5 // indirect
go.dtapp.net/gotrace_id v1.0.6 // indirect
go.dtapp.net/gourl v1.0.0 // indirect
go.mongodb.org/mongo-driver v1.10.2 // indirect
go.mongodb.org/mongo-driver v1.10.3 // indirect
go.uber.org/atomic v1.10.0 // indirect
go.uber.org/multierr v1.8.0 // indirect
go.uber.org/zap v1.23.0 // indirect
golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90 // indirect
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 // indirect
golang.org/x/net v0.0.0-20220906165146-f3363e06e74c // indirect
golang.org/x/sync v0.0.0-20220819030929-7fc1605a5dde // indirect
golang.org/x/sys v0.0.0-20220906165534-d0df966e6959 // indirect
golang.org/x/text v0.3.7 // indirect
golang.org/x/crypto v0.1.0 // indirect
golang.org/x/mod v0.6.0 // indirect
golang.org/x/net v0.1.0 // indirect
golang.org/x/sync v0.1.0 // indirect
golang.org/x/sys v0.1.0 // indirect
golang.org/x/text v0.4.0 // indirect
google.golang.org/protobuf v1.28.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gorm.io/driver/mysql v1.3.6 // indirect
gorm.io/driver/postgres v1.3.9 // indirect
gorm.io/gorm v1.23.8 // indirect
gorm.io/driver/mysql v1.4.3 // indirect
gorm.io/driver/postgres v1.4.5 // indirect
gorm.io/gorm v1.24.1-0.20221019064659-5dd2bb482755 // indirect
mellium.im/sasl v0.3.0 // indirect
xorm.io/builder v0.3.12 // indirect
xorm.io/xorm v1.3.2 // indirect

@ -89,16 +89,18 @@ github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vb
github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE=
github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk=
github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A=
github.com/go-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY=
github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0=
github.com/go-playground/assert/v2 v2.0.1 h1:MsBgLAaY856+nPRTKrp3/OZK38U/wa0CcBYNjji3q3A=
github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
github.com/go-playground/locales v0.14.0 h1:u50s323jtVGugKlcYeyzC0etD1HifMjqmJqb8WugfUU=
github.com/go-playground/locales v0.14.0/go.mod h1:sawfccIbzZTqEDETgFXqTho0QybSa7l++s0DH+LDiLs=
github.com/go-playground/universal-translator v0.18.0 h1:82dyy6p4OuJq4/CByFNOn/jYrnRPArHwAcmLoJZxyho=
github.com/go-playground/universal-translator v0.18.0/go.mod h1:UvRDBj+xPUEGrFYl+lu/H90nyDXpg0fqeB/AQUGNTVA=
github.com/go-playground/validator/v10 v10.11.0 h1:0W+xRM511GY47Yy3bZUbJVitCNg2BOGlCyvTqsp/xIw=
github.com/go-playground/validator/v10 v10.11.0/go.mod h1:i+3WkQ1FvaUjjxh1kSvIA4dMGDBiPU55YFDl0WbKdWU=
github.com/go-redis/redis/v9 v9.0.0-beta.2 h1:ZSr84TsnQyKMAg8gnV+oawuQezeJR11/09THcWCQzr4=
github.com/go-redis/redis/v9 v9.0.0-beta.2/go.mod h1:Bldcd/M/bm9HbnNPi/LUtYBSD8ttcZYBMupwMXhdU0o=
github.com/go-playground/validator/v10 v10.11.1 h1:prmOlTVv+YjZjmRmNSF3VmspqJIxJWXmqUsHwfTRRkQ=
github.com/go-playground/validator/v10 v10.11.1/go.mod h1:i+3WkQ1FvaUjjxh1kSvIA4dMGDBiPU55YFDl0WbKdWU=
github.com/go-redis/redis/v9 v9.0.0-rc.1 h1:/+bS+yeUnanqAbuD3QwlejzQZ+4eqgfUtFTG4b+QnXs=
github.com/go-redis/redis/v9 v9.0.0-rc.1/go.mod h1:8et+z03j0l8N+DvsVnclzjf3Dl/pFHgRk+2Ct1qw66A=
github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w=
github.com/go-sql-driver/mysql v1.6.0 h1:BCTh4TKNUYmOmMUcQ3IipzF5prigylS7XXjEkfCHuOE=
github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
@ -193,7 +195,6 @@ github.com/jackc/pgconn v1.8.1/go.mod h1:JV6m6b6jhjdmzchES0drzCcYcAHS1OPD5xu3OZ/
github.com/jackc/pgconn v1.9.0/go.mod h1:YctiPyvzfU11JFxoXokUOOKQXQmDMoJL9vJzHH8/2JY=
github.com/jackc/pgconn v1.9.1-0.20210724152538-d89c8390a530/go.mod h1:4z2w8XhRbP1hYxkpTuBjTS3ne3J48K83+u0zoyvg2pI=
github.com/jackc/pgconn v1.11.0/go.mod h1:4z2w8XhRbP1hYxkpTuBjTS3ne3J48K83+u0zoyvg2pI=
github.com/jackc/pgconn v1.12.1/go.mod h1:ZkhRC59Llhrq3oSfrikvwQ5NaxYExr6twkdkMLaKono=
github.com/jackc/pgconn v1.13.0 h1:3L1XMNV2Zvca/8BYhzcRFS70Lr0WlDg16Di6SFGAbys=
github.com/jackc/pgconn v1.13.0/go.mod h1:AnowpAqO4CMIIJNZl2VJp+KrkAZciAkhEl0W0JIobpI=
github.com/jackc/pgio v1.0.0 h1:g12B9UwVnzGhueNavwioyEEpAmqMe1E/BN9ES+8ovkE=
@ -213,7 +214,6 @@ github.com/jackc/pgproto3/v2 v2.0.1/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwX
github.com/jackc/pgproto3/v2 v2.0.6/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA=
github.com/jackc/pgproto3/v2 v2.1.1/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA=
github.com/jackc/pgproto3/v2 v2.2.0/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA=
github.com/jackc/pgproto3/v2 v2.3.0/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA=
github.com/jackc/pgproto3/v2 v2.3.1 h1:nwj7qwf0S+Q7ISFfBndqeLwSwxs+4DPsbRFjECT1Y4Y=
github.com/jackc/pgproto3/v2 v2.3.1/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA=
github.com/jackc/pgservicefile v0.0.0-20200307190119-3430c5407db8/go.mod h1:vsD4gTJCa9TptPL8sPkXrLZ+hDuNrZCnj29CQpr4X1E=
@ -229,7 +229,6 @@ github.com/jackc/pgtype v1.7.0/go.mod h1:ZnHF+rMePVqDKaOfJVI4Q8IVvAQMryDlDkZnKOI
github.com/jackc/pgtype v1.8.0/go.mod h1:PqDKcEBtllAtk/2p6z6SHdXW5UB+MhE75tUol2OKexE=
github.com/jackc/pgtype v1.8.1-0.20210724151600-32e20a603178/go.mod h1:C516IlIV9NKqfsMCXTdChteoXmwgUceqaLfjg2e3NlM=
github.com/jackc/pgtype v1.10.0/go.mod h1:LUMuVrfsFfdKGLw+AFFVv6KtHOFMwRgDDzBt76IqCA4=
github.com/jackc/pgtype v1.11.0/go.mod h1:LUMuVrfsFfdKGLw+AFFVv6KtHOFMwRgDDzBt76IqCA4=
github.com/jackc/pgtype v1.12.0 h1:Dlq8Qvcch7kiehm8wPGIW0W3KsCCHJnRacKW0UM8n5w=
github.com/jackc/pgtype v1.12.0/go.mod h1:LUMuVrfsFfdKGLw+AFFVv6KtHOFMwRgDDzBt76IqCA4=
github.com/jackc/pgx/v4 v4.0.0-20190420224344-cc3461e65d96/go.mod h1:mdxmSJJuR08CZQyj1PVQBHy9XOp5p8/SHH6a0psbY9Y=
@ -242,7 +241,6 @@ github.com/jackc/pgx/v4 v4.11.0/go.mod h1:i62xJgdrtVDsnL3U8ekyrQXEwGNTRoG7/8r+CI
github.com/jackc/pgx/v4 v4.12.0/go.mod h1:fE547h6VulLPA3kySjfnSG/e2D861g/50JlVUa/ub60=
github.com/jackc/pgx/v4 v4.12.1-0.20210724153913-640aa07df17c/go.mod h1:1QD0+tgSXP7iUjYm9C1NxKhny7lq6ee99u/z+IHFcgs=
github.com/jackc/pgx/v4 v4.15.0/go.mod h1:D/zyOyXiaM1TmVWnOM18p0xdDtdakRBa0RsVGI3U3bw=
github.com/jackc/pgx/v4 v4.16.1/go.mod h1:SIhx0D5hoADaiXZVyv+3gSm3LCIIINTVO0PficsvWGQ=
github.com/jackc/pgx/v4 v4.17.2 h1:0Ut0rpeKwvIVbMQ1KbMBU4h6wxehBI535LK6Flheh8E=
github.com/jackc/pgx/v4 v4.17.2/go.mod h1:lcxIZN44yMIrWI78a5CpucdD14hX0SBDbNRvjDBItsw=
github.com/jackc/puddle v0.0.0-20190413234325-e4ced69a3a2b/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk=
@ -271,8 +269,8 @@ github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51/go.mod h1:C
github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk=
github.com/klauspost/compress v1.15.9 h1:wKRjX6JRtDdrE9qwa4b/Cip7ACOshUI4smpCQanqjSY=
github.com/klauspost/compress v1.15.9/go.mod h1:PhcZ0MbTNciWF3rruxRgKxI5NkcHHrHUDtV4Yw2GlzU=
github.com/klauspost/compress v1.15.11 h1:Lcadnb3RKGin4FYM/orgq0qde+nc15E5Cbqg4B9Sx9c=
github.com/klauspost/compress v1.15.11/go.mod h1:QPwzmACJjUTFsnSHH934V6woptycfrDDJnH7hvFVbGM=
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
@ -352,7 +350,7 @@ github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+W
github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE=
github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
github.com/onsi/gomega v1.20.0 h1:8W0cWlwFkflGPLltQvLRB7ZVD5HuP6ng320w2IS245Q=
github.com/onsi/gomega v1.21.1 h1:OB/euWYIExnPBohllTicTHmGTrMaqJ67nIu80j0/uEM=
github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk=
github.com/opentracing-contrib/go-observer v0.0.0-20170622124052-a52f23424492/go.mod h1:Ngi6UdF0k5OKD5t5wlmGhe/EDKPoUM3BXZSSfIuJbis=
github.com/opentracing/basictracer-go v1.0.0/go.mod h1:QfBfYuafItcjQuMwinw9GhYKwFXS9KnPs5lxoYwgW74=
@ -362,6 +360,10 @@ github.com/openzipkin-contrib/zipkin-go-opentracing v0.4.5/go.mod h1:/wsWhb9smxS
github.com/openzipkin/zipkin-go v0.1.6/go.mod h1:QgAqvLzwWbR/WpD4A3cGpPtJrZXNIiJc5AZX7/PBEpw=
github.com/openzipkin/zipkin-go v0.2.1/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnhQw8ySjnjRyN4=
github.com/openzipkin/zipkin-go v0.2.2/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnhQw8ySjnjRyN4=
github.com/oschwald/geoip2-golang v1.8.0 h1:KfjYB8ojCEn/QLqsDU0AzrJ3R5Qa9vFlx3z6SLNcKTs=
github.com/oschwald/geoip2-golang v1.8.0/go.mod h1:R7bRvYjOeaoenAp9sKRS8GX5bJWcZ0laWO5+DauEktw=
github.com/oschwald/maxminddb-golang v1.10.0 h1:Xp1u0ZhqkSuopaKmk1WwHtjF0H9Hd9181uj2MQ5Vndg=
github.com/oschwald/maxminddb-golang v1.10.0/go.mod h1:Y2ELenReaLAZ0b400URyGwvYxHV1dLIxBuyOsyYjHK0=
github.com/pact-foundation/pact-go v1.0.4/go.mod h1:uExwJY4kCzNPcHRj+hCR/HBbOOIwwtUjcrb0b5/5kLM=
github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc=
github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k=
@ -421,6 +423,8 @@ github.com/segmentio/fasthash v1.0.3 h1:EI9+KE1EwvMLBWwjpRDc+fEM+prwxDYbslddQGtr
github.com/segmentio/fasthash v1.0.3/go.mod h1:waKX8l2N8yckOgmSsXJi7x1ZfdKZ4x7KRMzBtS3oedY=
github.com/shiena/ansicolor v0.0.0-20200904210342-c7312218db18 h1:DAYUYH5869yV94zvCES9F51oYtN5oGlwjxJJz7ZCnik=
github.com/shiena/ansicolor v0.0.0-20200904210342-c7312218db18/go.mod h1:nkxAfR/5quYxwPZhyDxgasBMnRtBZd0FCEpawpjMUFg=
github.com/shirou/gopsutil v3.21.11+incompatible h1:+1+c1VGhc88SSonWP6foOcLhvnKlUeu/erjjvaPEYiI=
github.com/shirou/gopsutil v3.21.11+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA=
github.com/shopspring/decimal v0.0.0-20180709203117-cd690d0c9e24/go.mod h1:M+9NzErvs504Cn4c5DxATwIqPbtswREoFCre64PpcG4=
github.com/shopspring/decimal v0.0.0-20200227202807-02e2044944cc/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
github.com/shopspring/decimal v1.2.0 h1:abSATXmQEYyShuxI4/vyW3tV1MrKAJzCZ/0zLUXYbsQ=
@ -458,6 +462,11 @@ github.com/syndtr/goleveldb v1.0.0 h1:fBdIW9lB4Iz0n9khmH8w27SJ3QEJ7+IgjPEwGSZiFd
github.com/syndtr/goleveldb v1.0.0/go.mod h1:ZVVdQEZoIme9iO1Ch2Jdy24qqXrMMOU6lpPAyBWyWuQ=
github.com/tidwall/pretty v1.0.0 h1:HsD+QiTn7sK6flMKIvNmpqz1qrpP3Ps6jOKIKMooyg4=
github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk=
github.com/tklauser/go-sysconf v0.3.10 h1:IJ1AZGZRWbY8T5Vfk04D9WOA5WSejdflXxP03OUqALw=
github.com/tklauser/go-sysconf v0.3.10/go.mod h1:C8XykCvCb+Gn0oNCWPIlcb0RuglQTYaQ2hGm7jmxEFk=
github.com/tklauser/numcpus v0.4.0/go.mod h1:1+UI3pD8NW14VMwdgJNJ1ESk2UnwhAnz5hMwiKKqXCQ=
github.com/tklauser/numcpus v0.5.0 h1:ooe7gN0fg6myJ0EKoTAf5hebTZrH52px3New/D9iJ+A=
github.com/tklauser/numcpus v0.5.0/go.mod h1:OGzpTxpcIMNGYQdit2BYL1pvk/dSOaJWjKoflh+RQjo=
github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
github.com/tmthrgd/go-hex v0.0.0-20190904060850-447a3041c3bc h1:9lRDQMhESg+zvGYmW5DyG0UqvY96Bu5QYsTLvCHdrgo=
github.com/tmthrgd/go-hex v0.0.0-20190904060850-447a3041c3bc/go.mod h1:bciPuU6GHm1iF1pBvUfxfsH0Wmnc2VbpgvbI9ZWuIRs=
@ -493,18 +502,20 @@ github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d/go.mod h1:rHwXgn7Jul
github.com/youmark/pkcs8 v0.0.0-20201027041543-1326539a0a0a h1:fZHgsYlfvtyqToslyjUt3VOPF4J7aK/3MPcK7xp3PDk=
github.com/youmark/pkcs8 v0.0.0-20201027041543-1326539a0a0a/go.mod h1:ul22v+Nro/R083muKhosV54bj5niojjWZvU8xrevuH4=
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yusufpapurcu/wmi v1.2.2 h1:KBNDSne4vP5mbSWnJbO+51IMOXJB67QiYCSBrubbPRg=
github.com/yusufpapurcu/wmi v1.2.2/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0=
github.com/zenazn/goji v0.9.0/go.mod h1:7S9M489iMyHBNxwZnk9/EHS098H4/F6TATF2mIxtB1Q=
github.com/ziutek/mymysql v1.5.4/go.mod h1:LMSpPZ6DbqWFxNCHW77HeMg9I646SAhApZ/wKdgO/C0=
go.dtapp.net/dorm v1.0.32 h1:kMU2on0t8e87qDvXEt8DlaM1DJjLBvUOaIGc5fNsgzY=
go.dtapp.net/dorm v1.0.32/go.mod h1:ocdIcMoJCLGngRNPSAa/1Hq+Mu1JDTxT0hH2QBlL2ik=
go.dtapp.net/goip v1.0.28 h1:wZt+wbzNhOLRUJnepG4c8HhUr4V9jNXOF6wJ1h7jUvU=
go.dtapp.net/goip v1.0.28/go.mod h1:ZqPPUvpOSzdtB/dEZFiaD0CBRZmvIzjDmm3XkpMC9Bo=
go.dtapp.net/golog v1.0.67 h1:HGNrc9zq1S0yXxPazG+Odpsgtv/g5qSw7p8XbKAU+RQ=
go.dtapp.net/golog v1.0.67/go.mod h1:KIUJMiZqj8BgPwvE/CqAuiKhysreEh2cz3Tf+sdYTM4=
go.dtapp.net/dorm v1.0.51 h1:WyN/1T9h0uFLnHwDBlLgN8rzchJSeyblHpTUuwz9Aqc=
go.dtapp.net/dorm v1.0.51/go.mod h1:1Yz2YBAm2S4dPtgpBKbXPkEZ4OtYVmhEXQXuZy4I86I=
go.dtapp.net/goip v1.0.38 h1:WHIqXV0qWUM9XDtRaMIMyCKWyd9dWfSvSRdDr7vF7xU=
go.dtapp.net/goip v1.0.38/go.mod h1:N2YFFr2OO+5VQwMqyKtg7c4MVrDJOoog/QmIvYUfi1c=
go.dtapp.net/golog v1.0.101 h1:LiJzgWkbFpcLEcrJkn9QDb3cDdjZ/Y/6Z7qYLnSf44I=
go.dtapp.net/golog v1.0.101/go.mod h1:qrT804LJ4zVRx9Uo/8FZ9Y8PEcGy5kLq/nyXj1cagRg=
go.dtapp.net/gorandom v1.0.1 h1:IWfMClh1ECPvyUjlqD7MwLq4mZdUusD1qAwAdsvEJBs=
go.dtapp.net/gorandom v1.0.1/go.mod h1:ZPdgalKpvFV/ATQqR0k4ns/F/IpITAZpx6WkWirr5Y8=
go.dtapp.net/gorequest v1.0.28 h1:EehFtF5WcvyZ9rB6MAQoI2kJkhR8Wv8tVgpoxXcb3sI=
go.dtapp.net/gorequest v1.0.28/go.mod h1:Nr0BIOXhapY3Es86hL7pN2c2PgjZwImcrWdMpLzHlJE=
go.dtapp.net/gorequest v1.0.33 h1:QBz93AA+K/WeXttujUsUjUQ2Ddps67Z+Pw2bXgjbZJc=
go.dtapp.net/gorequest v1.0.33/go.mod h1:X+KbPzYpo4r5ldxkqIRuZ/EbJ15Bleu5CwLU+Q7gKpw=
go.dtapp.net/gostring v1.0.10 h1:eG+1kQehdJUitj9Hfwy79SndMHYOB7ABpWkTs7mDGeQ=
go.dtapp.net/gostring v1.0.10/go.mod h1:L4kREy89a9AraMHB5tUjjl+5rxP1gpXkDouRKKuzT50=
go.dtapp.net/gotime v1.0.5 h1:12aNgB2ULpP6QgQHEUkLilZ4ASvhpFxMFQkBwn0par8=
@ -515,8 +526,8 @@ go.dtapp.net/gourl v1.0.0 h1:Zbe0GiMFyyRy2+bjbVsYulakH5d58w3CDZkUPonlMoQ=
go.dtapp.net/gourl v1.0.0/go.mod h1:x9A/pJ3iKDTb6Gu2RtJy2iHg56IowXIcIGQdogqpGjs=
go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU=
go.etcd.io/etcd v0.0.0-20191023171146-3cf2f69b5738/go.mod h1:dnLIgRNXwCJa5e+c6mIZCrds/GIG4ncV9HhK5PX7jPg=
go.mongodb.org/mongo-driver v1.10.2 h1:4Wk3cnqOrQCn0P92L3/mmurMxzdvWWs5J9jinAVKD+k=
go.mongodb.org/mongo-driver v1.10.2/go.mod h1:z4XpeoU6w+9Vht+jAFyLgVrD+jGSQQe0+CBWFHNiHt8=
go.mongodb.org/mongo-driver v1.10.3 h1:XDQEvmh6z1EUsXuIkXE9TaVeqHw6SwS1uf93jFs0HBA=
go.mongodb.org/mongo-driver v1.10.3/go.mod h1:z4XpeoU6w+9Vht+jAFyLgVrD+jGSQQe0+CBWFHNiHt8=
go.opencensus.io v0.20.1/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk=
go.opencensus.io v0.20.2/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk=
go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
@ -556,13 +567,12 @@ golang.org/x/crypto v0.0.0-20201203163018-be400aefbc4c/go.mod h1:jdWPYTVW3xRLrWP
golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4=
golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/crypto v0.0.0-20220307211146-efcb8507fb70/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90 h1:Y/gsMcFOcR+6S6f3YeMKl5g+dZMEWqcz5Czj/GWYbkM=
golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/crypto v0.1.0 h1:MDRAIl0xIo9Io2xV565hzXHw3zVseKrJKodhohM5CjU=
golang.org/x/crypto v0.1.0/go.mod h1:RecgLatLF4+eUMCP1PoPZQb+cVrJcOPbHkTkbkB9sbw=
golang.org/x/exp v0.0.0-20181106170214-d68db9428509/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
@ -573,8 +583,8 @@ golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHl
golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc=
golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 h1:6zppjxzCulZykYSLyVDYbneBfbaBIQPYMevg0bEwv2s=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/mod v0.6.0 h1:b9gGHsz9/HhJ3HF5DHQytPpuwocVTChQJK3AvoLRD5I=
golang.org/x/mod v0.6.0/go.mod h1:4mET923SAdbXp2ki8ey+zGs1SLqsuM2Y0uvdZR/fUNI=
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
@ -594,8 +604,8 @@ golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7/go.mod h1:z5CRVTTTmAJ677TzLL
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.0.0-20220906165146-f3363e06e74c h1:yKufUcDwucU5urd+50/Opbt4AYpqthk7wHpHok8f1lo=
golang.org/x/net v0.0.0-20220906165146-f3363e06e74c/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk=
golang.org/x/net v0.1.0 h1:hZ/3BUoy5aId7sCpA/Tc5lt8DkFgdVS2onTpJsZ/fl0=
golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
@ -606,8 +616,8 @@ golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJ
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220819030929-7fc1605a5dde h1:ejfdSekXMDxDLbRrJMwUk6KnSLZ2McaUCVcIKM+N6jc=
golang.org/x/sync v0.0.0-20220819030929-7fc1605a5dde/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o=
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
@ -625,6 +635,7 @@ golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190826190057-c7b8b68b1456/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191220142924-d4481acd189f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
@ -639,10 +650,12 @@ golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20210902050250-f475640dd07b/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20211210111614-af8b64212486/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220128215802-99c3d69c2c27/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220906165534-d0df966e6959 h1:qSa+Hg9oBe6UJXrznE+yYvW51V9UbyIj/nj/KpDigo8=
golang.org/x/sys v0.0.0-20220906165534-d0df966e6959/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.1.0 h1:kunALQeHf1/185U1i0GOB/fy1IPRDDpuoOOqRReG57U=
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
@ -650,8 +663,9 @@ golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.4.0 h1:BrVqGRd7+k1DiOgtnFvAkoQEWQvBc25ouMJM6429SFg=
golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
@ -671,7 +685,7 @@ golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtn
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20200103221440-774c71fcf114/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
golang.org/x/tools v0.0.0-20201124115921-2c860bdd6e78/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/tools v0.1.11 h1:loJ25fNOEhSXfHrpoGj91eCUThwdNX6u24rO1xnNteY=
golang.org/x/tools v0.1.12 h1:VveCTK38A2rkS8ZqFY25HIDFscX5X9OoEhJd3quQmXU=
golang.org/x/xerrors v0.0.0-20190410155217-1f06c39b4373/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20190513163551-3ee3066db522/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
@ -725,13 +739,13 @@ gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gorm.io/driver/mysql v1.3.6 h1:BhX1Y/RyALb+T9bZ3t07wLnPZBukt+IRkMn8UZSNbGM=
gorm.io/driver/mysql v1.3.6/go.mod h1:sSIebwZAVPiT+27jK9HIwvsqOGKx3YMPmrA3mBJR10c=
gorm.io/driver/postgres v1.3.9 h1:lWGiVt5CijhQAg0PWB7Od1RNcBw/jS4d2cAScBcSDXg=
gorm.io/driver/postgres v1.3.9/go.mod h1:qw/FeqjxmYqW5dBcYNBsnhQULIApQdk7YuuDPktVi1U=
gorm.io/gorm v1.23.7/go.mod h1:l2lP/RyAtc1ynaTjFksBde/O8v9oOGIApu2/xRitmZk=
gorm.io/gorm v1.23.8 h1:h8sGJ+biDgBA1AD1Ha9gFCx7h8npU7AsLdlkX0n2TpE=
gorm.io/driver/mysql v1.4.3 h1:/JhWJhO2v17d8hjApTltKNADm7K7YI2ogkR7avJUL3k=
gorm.io/driver/mysql v1.4.3/go.mod h1:sSIebwZAVPiT+27jK9HIwvsqOGKx3YMPmrA3mBJR10c=
gorm.io/driver/postgres v1.4.5 h1:mTeXTTtHAgnS9PgmhN2YeUbazYpLhUI1doLnw42XUZc=
gorm.io/driver/postgres v1.4.5/go.mod h1:GKNQYSJ14qvWkvPwXljMGehpKrhlDNsqYRr5HnYGncg=
gorm.io/gorm v1.23.8/go.mod h1:l2lP/RyAtc1ynaTjFksBde/O8v9oOGIApu2/xRitmZk=
gorm.io/gorm v1.24.1-0.20221019064659-5dd2bb482755 h1:7AdrbfcvKnzejfqP5g37fdSZOXH/JvaPIzBIHTOqXKk=
gorm.io/gorm v1.24.1-0.20221019064659-5dd2bb482755/go.mod h1:DVrVomtaYTbqs7gB/x2uVvqnXzv0nqjB396B8cG4dBA=
honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=

@ -14,14 +14,15 @@ type MerchantFundBalanceResponse struct {
}
type MerchantFundBalanceResult struct {
Result MerchantFundBalanceResponse // 结果
Body []byte // 内容
Http gorequest.Response // 请求
Err error // 错误
Result MerchantFundBalanceResponse // 结果
Body []byte // 内容
Http gorequest.Response // 请求
Err error // 错误
ApiError ApiError // 接口错误
}
func newMerchantFundBalanceResult(result MerchantFundBalanceResponse, body []byte, http gorequest.Response, err error) *MerchantFundBalanceResult {
return &MerchantFundBalanceResult{Result: result, Body: body, Http: http, Err: err}
func newMerchantFundBalanceResult(result MerchantFundBalanceResponse, body []byte, http gorequest.Response, err error, apiError ApiError) *MerchantFundBalanceResult {
return &MerchantFundBalanceResult{Result: result, Body: body, Http: http, Err: err, ApiError: apiError}
}
// MerchantFundBalance 查询电商平台账户实时余额API
@ -33,10 +34,13 @@ func (c *Client) MerchantFundBalance(ctx context.Context, accountType string) *M
// 请求
request, err := c.request(ctx, fmt.Sprintf(apiUrl+"/v3/merchant/fund/balance/%s", accountType), params, http.MethodGet)
if err != nil {
return newMerchantFundBalanceResult(MerchantFundBalanceResponse{}, request.ResponseBody, request, err)
return newMerchantFundBalanceResult(MerchantFundBalanceResponse{}, request.ResponseBody, request, err, ApiError{})
}
// 定义
var response MerchantFundBalanceResponse
err = json.Unmarshal(request.ResponseBody, &response)
return newMerchantFundBalanceResult(response, request.ResponseBody, request, err)
// 错误
var apiError ApiError
err = json.Unmarshal(request.ResponseBody, &apiError)
return newMerchantFundBalanceResult(response, request.ResponseBody, request, err, apiError)
}

@ -14,14 +14,15 @@ type MerchantFundDayEndBalanceResponse struct {
}
type MerchantFundDayEndBalanceResult struct {
Result MerchantFundDayEndBalanceResponse // 结果
Body []byte // 内容
Http gorequest.Response // 请求
Err error // 错误
Result MerchantFundDayEndBalanceResponse // 结果
Body []byte // 内容
Http gorequest.Response // 请求
Err error // 错误
ApiError ApiError // 接口错误
}
func newMerchantFundDayEndBalanceResult(result MerchantFundDayEndBalanceResponse, body []byte, http gorequest.Response, err error) *MerchantFundDayEndBalanceResult {
return &MerchantFundDayEndBalanceResult{Result: result, Body: body, Http: http, Err: err}
func newMerchantFundDayEndBalanceResult(result MerchantFundDayEndBalanceResponse, body []byte, http gorequest.Response, err error, apiError ApiError) *MerchantFundDayEndBalanceResult {
return &MerchantFundDayEndBalanceResult{Result: result, Body: body, Http: http, Err: err, ApiError: apiError}
}
// MerchantFundDayEndBalance 查询电商平台账户日终余额API
@ -34,10 +35,13 @@ func (c *Client) MerchantFundDayEndBalance(ctx context.Context, accountType, dat
// 请求
request, err := c.request(ctx, fmt.Sprintf(apiUrl+"/v3/merchant/fund/dayendbalance/%s?date=%s", accountType, date), params, http.MethodGet)
if err != nil {
return newMerchantFundDayEndBalanceResult(MerchantFundDayEndBalanceResponse{}, request.ResponseBody, request, err)
return newMerchantFundDayEndBalanceResult(MerchantFundDayEndBalanceResponse{}, request.ResponseBody, request, err, ApiError{})
}
// 定义
var response MerchantFundDayEndBalanceResponse
err = json.Unmarshal(request.ResponseBody, &response)
return newMerchantFundDayEndBalanceResult(response, request.ResponseBody, request, err)
// 错误
var apiError ApiError
err = json.Unmarshal(request.ResponseBody, &apiError)
return newMerchantFundDayEndBalanceResult(response, request.ResponseBody, request, err, apiError)
}

@ -53,14 +53,15 @@ type PayPartnerTransactionsIdResponse struct {
}
type PayPartnerTransactionsIdResult struct {
Result PayPartnerTransactionsIdResponse // 结果
Body []byte // 内容
Http gorequest.Response // 请求
Err error // 错误
Result PayPartnerTransactionsIdResponse // 结果
Body []byte // 内容
Http gorequest.Response // 请求
Err error // 错误
ApiError ApiError // 接口错误
}
func newPayPartnerTransactionsIdResult(result PayPartnerTransactionsIdResponse, body []byte, http gorequest.Response, err error) *PayPartnerTransactionsIdResult {
return &PayPartnerTransactionsIdResult{Result: result, Body: body, Http: http, Err: err}
func newPayPartnerTransactionsIdResult(result PayPartnerTransactionsIdResponse, body []byte, http gorequest.Response, err error, apiError ApiError) *PayPartnerTransactionsIdResult {
return &PayPartnerTransactionsIdResult{Result: result, Body: body, Http: http, Err: err, ApiError: apiError}
}
// PayPartnerTransactionsId 微信支付订单号查询
@ -71,10 +72,13 @@ func (c *Client) PayPartnerTransactionsId(ctx context.Context, transactionId str
// 请求
request, err := c.request(ctx, fmt.Sprintf(apiUrl+"/v3/pay/partner/transactions/id/%s?sp_mchid=%s&sub_mchid=%s", transactionId, c.GetSpMchId(), c.GetSubMchId()), params, http.MethodGet)
if err != nil {
return newPayPartnerTransactionsIdResult(PayPartnerTransactionsIdResponse{}, request.ResponseBody, request, err)
return newPayPartnerTransactionsIdResult(PayPartnerTransactionsIdResponse{}, request.ResponseBody, request, err, ApiError{})
}
// 定义
var response PayPartnerTransactionsIdResponse
err = json.Unmarshal(request.ResponseBody, &response)
return newPayPartnerTransactionsIdResult(response, request.ResponseBody, request, err)
// 错误
var apiError ApiError
err = json.Unmarshal(request.ResponseBody, &apiError)
return newPayPartnerTransactionsIdResult(response, request.ResponseBody, request, err, apiError)
}

@ -2,10 +2,12 @@ package wechatpayopen
import (
"context"
"encoding/json"
"github.com/gin-gonic/gin"
)
type ResponsePayPartnerTransactionsJsapiNotifyGin struct {
// PayPartnerTransactionsJsapiNotifyGinRequest JSAPI下单 - 回调通知 - 请求参数
type PayPartnerTransactionsJsapiNotifyGinRequest struct {
Id string `form:"id" json:"status" xml:"id" uri:"id" binding:"required"` // 通知ID
CreateTime string `form:"create_time" json:"create_time" xml:"create_time" uri:"create_time" binding:"required"` // 通知创建时间
EventType string `form:"event_type" json:"event_type" xml:"event_type" uri:"event_type" binding:"required"` // 通知类型
@ -22,25 +24,66 @@ type ResponsePayPartnerTransactionsJsapiNotifyGin struct {
// PayPartnerTransactionsJsapiNotifyGin JSAPI下单 - 回调通知
// https://pay.weixin.qq.com/wiki/doc/apiv3_partner/apis/chapter4_1_5.shtml
func (c *Client) PayPartnerTransactionsJsapiNotifyGin(ctx context.Context, ginCtx *gin.Context) (ResponsePayPartnerTransactionsJsapiNotifyGin, error) {
// 声明接收的变量
var validateJson struct {
Id string `form:"id" json:"status" xml:"id" uri:"id" binding:"required"` // 通知ID
CreateTime string `form:"create_time" json:"create_time" xml:"create_time" uri:"create_time" binding:"required"` // 通知创建时间
EventType string `form:"event_type" json:"event_type" xml:"event_type" uri:"event_type" binding:"required"` // 通知类型
ResourceType string `form:"resource_type" json:"resource_type" xml:"resource_type" uri:"resource_type" binding:"required"` // 通知数据类型
Resource struct {
Algorithm string `form:"algorithm" json:"algorithm" xml:"algorithm" uri:"algorithm" binding:"required"` // 加密算法类型
Ciphertext string `form:"ciphertext" json:"ciphertext" xml:"ciphertext" uri:"ciphertext" binding:"required"` // 数据密文
AssociatedData string `form:"associated_data" json:"associated_data" xml:"associated_data" uri:"associated_data" binding:"omitempty"` // 附加数据
OriginalType string `form:"original_type" json:"original_type" xml:"original_type" uri:"original_type" binding:"required"` // 原始类型
Nonce string `form:"nonce" json:"nonce" xml:"nonce" uri:"nonce" binding:"required"` // 随机串
} `form:"resource" json:"resource" xml:"resource" uri:"resource" binding:"required"` // 通知数据
Summary string `form:"summary" json:"summary" xml:"summary" uri:"summary" binding:"required"` // 回调摘要
func (c *Client) PayPartnerTransactionsJsapiNotifyGin(ctx context.Context, ginCtx *gin.Context) (validateJson PayPartnerTransactionsJsapiNotifyGinRequest, response PayPartnerTransactionsJsapiNotifyGinResponse, gcm []byte, err error) {
// 解析
err = ginCtx.ShouldBind(&validateJson)
gcm, err = c.decryptGCM(c.GetApiV3(), validateJson.Resource.Nonce, validateJson.Resource.Ciphertext, validateJson.Resource.AssociatedData)
if err != nil {
return validateJson, response, gcm, err
}
err := ginCtx.ShouldBind(&validateJson)
err = json.Unmarshal(gcm, &response)
return validateJson, response, gcm, err
}
return validateJson, err
// PayPartnerTransactionsJsapiNotifyGinResponse JSAPI下单 - 回调通知 - 解密后数据
type PayPartnerTransactionsJsapiNotifyGinResponse struct {
SpAppid string `json:"sp_appid"` // 服务商应用ID
SpMchid string `json:"sp_mchid"` // 服务商户号
SubAppid string `json:"sub_appid,omitempty"` // 子商户应用ID
SubMchid string `json:"sub_mchid"` // 子商户号
OutTradeNo string `json:"out_trade_no"` // 商户订单号
TransactionId string `json:"transaction_id"` // 微信支付订单号
TradeType string `json:"trade_type"` // 交易类型
TradeState string `json:"trade_state"` // 交易状态
TradeStateDesc string `json:"trade_state_desc"` // 交易状态描述
BankType string `json:"bank_type"` // 付款银行
Attach string `json:"attach,omitempty"` // 附加数据
SuccessTime string `json:"success_time"` // 支付完成时间
Payer struct {
Openid string `json:"openid"` // 用户服务标识
SpOpenid string `json:"sp_openid,omitempty"` // 用户服务标识
SubOpenid string `json:"sub_openid,omitempty"` // 用户子标识
} `json:"payer"` // -支付者
Amount struct {
Total int `json:"total"` // 总金额
PayerTotal int `json:"payer_total"` // 用户支付金额
Currency string `json:"currency"` // 货币类型
PayerCurrency string `json:"payer_currency"` // 用户支付币种
} `json:"amount"` // 订单金额
SceneInfo struct {
DeviceId string `json:"device_id,omitempty"` //商户端设备号
} `json:"scene_info,omitempty"` // 场景信息
PromotionDetail []struct {
CouponId string `json:"coupon_id"` // 券ID
Name string `json:"name,omitempty"` // 优惠名称
Scope string `json:"scope,omitempty"` // 优惠范围
Type string `json:"type,omitempty"` // 优惠类型
Amount int `json:"amount"` // 优惠券面额
StockId string `json:"stock_id,omitempty"` // 活动ID
WechatpayContribute int `json:"wechatpay_contribute,omitempty"` // 微信出资
MerchantContribute int `json:"merchant_contribute,omitempty"` // 商户出资
OtherContribute int `json:"other_contribute,omitempty"` // 其他出资
Currency string `json:"currency,omitempty"` // 优惠币种
GoodsDetail []struct {
GoodsId string `json:"goods_id"` // 商品编码
Quantity int `json:"quantity"` // 商品数量
UnitPrice int `json:"unit_price"` // 商品单价
DiscountAmount int `json:"discount_amount"` // 商品优惠金额
GoodsRemark string `json:"goods_remark,omitempty"` // 商品备注
} `json:"goods_detail,omitempty"` // 单品列表
} `json:"promotion_detail,omitempty"` // 优惠功能
}

@ -0,0 +1,44 @@
package wechatpayopen
import (
"context"
"encoding/json"
"go.dtapp.net/gorequest"
"net/http"
)
type ProfitSharingMerchantConfigsResponse struct {
SubMchid string `json:"sub_mchid"` // 子商户号
MaxRatio int `json:"max_ratio"` // 最大分账比例
}
type ProfitSharingMerchantConfigsResult struct {
Result ProfitSharingMerchantConfigsResponse // 结果
Body []byte // 内容
Http gorequest.Response // 请求
Err error // 错误
ApiError ApiError // 接口错误
}
func newProfitSharingMerchantConfigsResult(result ProfitSharingMerchantConfigsResponse, body []byte, http gorequest.Response, err error, apiError ApiError) *ProfitSharingMerchantConfigsResult {
return &ProfitSharingMerchantConfigsResult{Result: result, Body: body, Http: http, Err: err, ApiError: apiError}
}
// ProfitSharingMerchantConfigs 查询最大分账比例API
// https://pay.weixin.qq.com/wiki/doc/apiv3_partner/apis/chapter8_1_7.shtml
func (c *Client) ProfitSharingMerchantConfigs(ctx context.Context) *ProfitSharingMerchantConfigsResult {
// 参数
params := gorequest.NewParams()
// 请求
request, err := c.request(ctx, apiUrl+"/v3/profitsharing/merchant-configs/"+c.GetSubMchId(), params, http.MethodGet)
if err != nil {
return newProfitSharingMerchantConfigsResult(ProfitSharingMerchantConfigsResponse{}, request.ResponseBody, request, err, ApiError{})
}
// 定义
var response ProfitSharingMerchantConfigsResponse
err = json.Unmarshal(request.ResponseBody, &response)
// 错误
var apiError ApiError
err = json.Unmarshal(request.ResponseBody, &apiError)
return newProfitSharingMerchantConfigsResult(response, request.ResponseBody, request, err, apiError)
}

@ -0,0 +1,61 @@
package wechatpayopen
import (
"context"
"encoding/json"
"go.dtapp.net/gorequest"
"net/http"
)
type ProfitSharingOrdersResponse struct {
SubMchid string `json:"sub_mchid"` // 子商户号
TransactionId string `json:"transaction_id"` // 微信订单号
OutOrderNo string `json:"out_order_no"` // 商户分账单号
OrderId string `json:"order_id"` // 微信分账单号
State string `json:"state"` // 分账单状态
Receivers []struct {
Amount int `json:"amount"` // 分账金额
Description string `json:"description"` // 分账描述
Type string `json:"type"` // 分账接收方类型
Account string `json:"account"` // 分账接收方账号
Result string `json:"result"` // 分账结果
FailReason string `json:"fail_reason"` // 分账失败原因
DetailId string `json:"detail_id"` // 分账明细单号
CreateTime string `json:"create_time"` // 分账创建时间
FinishTime string `json:"finish_time"` // 分账完成时间
} `json:"receivers,omitempty"` // 分账接收方列表
}
type ProfitSharingOrdersResult struct {
Result ProfitSharingOrdersResponse // 结果
Body []byte // 内容
Http gorequest.Response // 请求
Err error // 错误
ApiError ApiError // 接口错误
}
func newProfitSharingOrdersResult(result ProfitSharingOrdersResponse, body []byte, http gorequest.Response, err error, apiError ApiError) *ProfitSharingOrdersResult {
return &ProfitSharingOrdersResult{Result: result, Body: body, Http: http, Err: err, ApiError: apiError}
}
// ProfitSharingOrders 请求分账API
// https://pay.weixin.qq.com/wiki/doc/apiv3_partner/apis/chapter8_1_1.shtml
func (c *Client) ProfitSharingOrders(ctx context.Context, notMustParams ...gorequest.Params) *ProfitSharingOrdersResult {
// 参数
params := gorequest.NewParamsWith(notMustParams...)
params.Set("sub_mchid", c.GetSubMchId()) // 子商户号
params.Set("appid", c.GetSpAppid()) // 应用ID
params.Set("sub_appid", c.GetSubAppid()) // 子商户应用ID
// 请求
request, err := c.request(ctx, apiUrl+"/v3/profitsharing/orders", params, http.MethodPost)
if err != nil {
return newProfitSharingOrdersResult(ProfitSharingOrdersResponse{}, request.ResponseBody, request, err, ApiError{})
}
// 定义
var response ProfitSharingOrdersResponse
err = json.Unmarshal(request.ResponseBody, &response)
// 错误
var apiError ApiError
err = json.Unmarshal(request.ResponseBody, &apiError)
return newProfitSharingOrdersResult(response, request.ResponseBody, request, err, apiError)
}

@ -0,0 +1,61 @@
package wechatpayopen
import (
"context"
"encoding/json"
"go.dtapp.net/gorequest"
"net/http"
)
type ProfitSharingOrdersOutOrderNoResponse struct {
SubMchid string `json:"sub_mchid"` // 子商户号
TransactionId string `json:"transaction_id"` // 微信订单号
OutOrderNo string `json:"out_order_no"` // 商户分账单号
OrderId string `json:"order_id"` // 微信分账单号
State string `json:"state"` // 分账单状态
Receivers []struct {
Amount int `json:"amount"` // 分账金额
Description string `json:"description"` // 分账描述
Type string `json:"type"` // 分账接收方类型
Account string `json:"account"` // 分账接收方账号
Result string `json:"result"` // 分账结果
FailReason string `json:"fail_reason"` // 分账失败原因
DetailId string `json:"detail_id"` // 分账明细单号
CreateTime string `json:"create_time"` // 分账创建时间
FinishTime string `json:"finish_time"` // 分账完成时间
} `json:"receivers,omitempty"` // 分账接收方列表
}
type ProfitSharingOrdersOutOrderNoResult struct {
Result ProfitSharingOrdersOutOrderNoResponse // 结果
Body []byte // 内容
Http gorequest.Response // 请求
Err error // 错误
ApiError ApiError // 接口错误
}
func newProfitSharingOrdersOutOrderNoResult(result ProfitSharingOrdersOutOrderNoResponse, body []byte, http gorequest.Response, err error, apiError ApiError) *ProfitSharingOrdersOutOrderNoResult {
return &ProfitSharingOrdersOutOrderNoResult{Result: result, Body: body, Http: http, Err: err, ApiError: apiError}
}
// ProfitSharingOrdersOutOrderNo 查询分账结果API
// https://pay.weixin.qq.com/wiki/doc/apiv3_partner/apis/chapter8_1_2.shtml
func (c *Client) ProfitSharingOrdersOutOrderNo(ctx context.Context, transactionId, outOrderNo string) *ProfitSharingOrdersOutOrderNoResult {
// 参数
params := gorequest.NewParams()
params.Set("sub_mchid", c.GetSubMchId()) // 子商户号
params.Set("transaction_id", transactionId) // 微信订单号
params.Set("out_order_no", outOrderNo) // 商户分账单号
// 请求
request, err := c.request(ctx, apiUrl+"/v3/profitsharing/orders/"+outOrderNo, params, http.MethodGet)
if err != nil {
return newProfitSharingOrdersOutOrderNoResult(ProfitSharingOrdersOutOrderNoResponse{}, request.ResponseBody, request, err, ApiError{})
}
// 定义
var response ProfitSharingOrdersOutOrderNoResponse
err = json.Unmarshal(request.ResponseBody, &response)
// 错误
var apiError ApiError
err = json.Unmarshal(request.ResponseBody, &apiError)
return newProfitSharingOrdersOutOrderNoResult(response, request.ResponseBody, request, err, apiError)
}

@ -0,0 +1,62 @@
package wechatpayopen
import (
"context"
"encoding/json"
"go.dtapp.net/gorequest"
"net/http"
)
type ProfitSharingOrdersUnfreezeResponse struct {
SubMchid string `json:"sub_mchid"` // 子商户号
TransactionId string `json:"transaction_id"` // 微信订单号
OutOrderNo string `json:"out_order_no"` // 商户分账单号
OrderId string `json:"order_id"` // 微信分账单号
State string `json:"state"` // 分账单状态
Receivers []struct {
Amount int `json:"amount"` // 分账金额
Description string `json:"description"` // 分账描述
Type string `json:"type"` // 分账接收方类型
Account string `json:"account"` // 分账接收方账号
Result string `json:"result"` // 分账结果
FailReason string `json:"fail_reason"` // 分账失败原因
DetailId string `json:"detail_id"` // 分账明细单号
CreateTime string `json:"create_time"` // 分账创建时间
FinishTime string `json:"finish_time"` // 分账完成时间
} `json:"receivers,omitempty"` // 分账接收方列表
}
type ProfitSharingOrdersUnfreezeResult struct {
Result ProfitSharingOrdersUnfreezeResponse // 结果
Body []byte // 内容
Http gorequest.Response // 请求
Err error // 错误
ApiError ApiError // 接口错误
}
func newProfitSharingOrdersUnfreezeResult(result ProfitSharingOrdersUnfreezeResponse, body []byte, http gorequest.Response, err error, apiError ApiError) *ProfitSharingOrdersUnfreezeResult {
return &ProfitSharingOrdersUnfreezeResult{Result: result, Body: body, Http: http, Err: err, ApiError: apiError}
}
// ProfitSharingOrdersUnfreeze 解冻剩余资金API
// https://pay.weixin.qq.com/wiki/doc/apiv3_partner/apis/chapter8_1_5.shtml
func (c *Client) ProfitSharingOrdersUnfreeze(ctx context.Context, transactionId, outOrderNo, description string) *ProfitSharingOrdersUnfreezeResult {
// 参数
params := gorequest.NewParams()
params.Set("sub_mchid", c.GetSubMchId()) // 子商户号
params.Set("transaction_id", transactionId) // 微信订单号
params.Set("out_order_no", outOrderNo) // 商户分账单号
params.Set("description", description) // 分账描述
// 请求
request, err := c.request(ctx, apiUrl+"/v3/profitsharing/orders/unfreeze", params, http.MethodPost)
if err != nil {
return newProfitSharingOrdersUnfreezeResult(ProfitSharingOrdersUnfreezeResponse{}, request.ResponseBody, request, err, ApiError{})
}
// 定义
var response ProfitSharingOrdersUnfreezeResponse
err = json.Unmarshal(request.ResponseBody, &response)
// 错误
var apiError ApiError
err = json.Unmarshal(request.ResponseBody, &apiError)
return newProfitSharingOrdersUnfreezeResult(response, request.ResponseBody, request, err, apiError)
}

@ -0,0 +1,68 @@
package wechatpayopen
import (
"context"
"encoding/json"
"go.dtapp.net/gorequest"
"net/http"
)
type ProfitSharingReceiversAddResponse struct {
SubMchid string `json:"sub_mchid"` // 子商户号
Type string `json:"type"` // 分账接收方类型
Account string `json:"account"` // 分账接收方账号
Name string `json:"name,omitempty"` // 分账接收方全称
RelationType string `json:"relation_type"` // 与分账方的关系类型
CustomRelation string `json:"custom_relation,omitempty"` // 自定义的分账关系
}
type ProfitSharingReceiversAddResult struct {
Result ProfitSharingReceiversAddResponse // 结果
Body []byte // 内容
Http gorequest.Response // 请求
Err error // 错误
ApiError ApiError // 接口错误
}
func newProfitSharingReceiversAddResult(result ProfitSharingReceiversAddResponse, body []byte, http gorequest.Response, err error, apiError ApiError) *ProfitSharingReceiversAddResult {
return &ProfitSharingReceiversAddResult{Result: result, Body: body, Http: http, Err: err, ApiError: apiError}
}
// ProfitSharingReceiversAdd 添加分账接收方API
// https://pay.weixin.qq.com/wiki/doc/apiv3_partner/apis/chapter8_1_8.shtml
func (c *Client) ProfitSharingReceiversAdd(ctx context.Context, Type, account, name, relationType, customRelation string) *ProfitSharingReceiversAddResult {
// 参数
params := gorequest.NewParams()
params.Set("sub_mchid", c.GetSubMchId()) // 子商户号
params.Set("appid", c.GetSpAppid()) // 应用ID
params.Set("sub_appid", c.GetSubAppid()) // 子商户应用ID
params.Set("type", Type) // 分账接收方类型
if Type == MERCHANT_ID {
params.Set("account", account) // 商户号
params.Set("name", name) // 商户全称
}
if Type == PERSONAL_OPENID && name != "" {
params.Set("account", account) // 个人openid
params.Set("name", name) // 个人姓名
}
if Type == PERSONAL_SUB_OPENID && name != "" {
params.Set("account", account) // 个人sub_openid
params.Set("name", name) // 个人姓名
}
params.Set("relation_type", relationType) // 与分账方的关系类型
if relationType == "CUSTOM" {
params.Set("custom_relation", customRelation) // 自定义的分账关系
}
// 请求
request, err := c.request(ctx, apiUrl+"/v3/profitsharing/receivers/delete", params, http.MethodPost)
if err != nil {
return newProfitSharingReceiversAddResult(ProfitSharingReceiversAddResponse{}, request.ResponseBody, request, err, ApiError{})
}
// 定义
var response ProfitSharingReceiversAddResponse
err = json.Unmarshal(request.ResponseBody, &response)
// 错误
var apiError ApiError
err = json.Unmarshal(request.ResponseBody, &apiError)
return newProfitSharingReceiversAddResult(response, request.ResponseBody, request, err, apiError)
}

@ -0,0 +1,58 @@
package wechatpayopen
import (
"context"
"encoding/json"
"go.dtapp.net/gorequest"
"net/http"
)
type ProfitSharingReceiversDeleteResponse struct {
SubMchid string `json:"sub_mchid"` // 子商户号
Type string `json:"type"` // 分账接收方类型
Account string `json:"account"` // 分账接收方账号
}
type ProfitSharingReceiversDeleteResult struct {
Result ProfitSharingReceiversDeleteResponse // 结果
Body []byte // 内容
Http gorequest.Response // 请求
Err error // 错误
ApiError ApiError // 接口错误
}
func newProfitSharingReceiversDeleteResult(result ProfitSharingReceiversDeleteResponse, body []byte, http gorequest.Response, err error, apiError ApiError) *ProfitSharingReceiversDeleteResult {
return &ProfitSharingReceiversDeleteResult{Result: result, Body: body, Http: http, Err: err, ApiError: apiError}
}
// ProfitSharingReceiversDelete 删除分账接收方API
// https://pay.weixin.qq.com/wiki/doc/apiv3_partner/apis/chapter8_1_9.shtml
func (c *Client) ProfitSharingReceiversDelete(ctx context.Context, Type, account string) *ProfitSharingReceiversDeleteResult {
// 参数
params := gorequest.NewParams()
params.Set("sub_mchid", c.GetSubMchId()) // 子商户号
params.Set("appid", c.GetSpAppid()) // 应用ID
params.Set("sub_appid", c.GetSubAppid()) // 子商户应用ID
params.Set("type", Type) // 分账接收方类型
if Type == MERCHANT_ID {
params.Set("account", account) // 商户号
}
if Type == PERSONAL_OPENID {
params.Set("account", account) // 个人openid
}
if Type == PERSONAL_SUB_OPENID {
params.Set("account", account) // 个人sub_openid
}
// 请求
request, err := c.request(ctx, apiUrl+"/v3/profitsharing/receivers/delete", params, http.MethodPost)
if err != nil {
return newProfitSharingReceiversDeleteResult(ProfitSharingReceiversDeleteResponse{}, request.ResponseBody, request, err, ApiError{})
}
// 定义
var response ProfitSharingReceiversDeleteResponse
err = json.Unmarshal(request.ResponseBody, &response)
// 错误
var apiError ApiError
err = json.Unmarshal(request.ResponseBody, &apiError)
return newProfitSharingReceiversDeleteResult(response, request.ResponseBody, request, err, apiError)
}

@ -0,0 +1,56 @@
package wechatpayopen
import (
"context"
"encoding/json"
"github.com/gin-gonic/gin"
)
// ProfitSharingReceiversNotifyGinRequest 分账动账通知API - 回调通知 - 请求参数
type ProfitSharingReceiversNotifyGinRequest struct {
Id string `form:"id" json:"status" xml:"id" uri:"id" binding:"required"` // 通知ID
CreateTime string `form:"create_time" json:"create_time" xml:"create_time" uri:"create_time" binding:"required"` // 通知创建时间
EventType string `form:"event_type" json:"event_type" xml:"event_type" uri:"event_type" binding:"required"` // 通知类型
Summary string `form:"summary" json:"summary" xml:"summary" uri:"summary" binding:"required"` // 通知简要说明
ResourceType string `form:"resource_type" json:"resource_type" xml:"resource_type" uri:"resource_type" binding:"required"` // 通知数据类型
Resource struct {
Algorithm string `form:"algorithm" json:"algorithm" xml:"algorithm" uri:"algorithm" binding:"required"` // 加密算法类型
Ciphertext string `form:"ciphertext" json:"ciphertext" xml:"ciphertext" uri:"ciphertext" binding:"required"` // 数据密文
AssociatedData string `form:"associated_data" json:"associated_data" xml:"associated_data" uri:"associated_data" binding:"omitempty"` // 附加数据
OriginalType string `form:"original_type" json:"original_type" xml:"original_type" uri:"original_type" binding:"required"` // 原始类型
Nonce string `form:"nonce" json:"nonce" xml:"nonce" uri:"nonce" binding:"required"` // 随机串
} `form:"resource" json:"resource" xml:"resource" uri:"resource" binding:"required"` // 通知数据
}
// ProfitSharingReceiversNotifyGin 分账动账通知API - 回调通知
// https://pay.weixin.qq.com/wiki/doc/apiv3_partner/apis/chapter4_1_5.shtml
func (c *Client) ProfitSharingReceiversNotifyGin(ctx context.Context, ginCtx *gin.Context) (validateJson ProfitSharingReceiversNotifyGinRequest, response ProfitSharingReceiversNotifyGinResponse, gcm []byte, err error) {
// 解析
err = ginCtx.ShouldBind(&validateJson)
gcm, err = c.decryptGCM(c.GetApiV3(), validateJson.Resource.Nonce, validateJson.Resource.Ciphertext, validateJson.Resource.AssociatedData)
if err != nil {
return validateJson, response, gcm, err
}
err = json.Unmarshal(gcm, &response)
return validateJson, response, gcm, err
}
// ProfitSharingReceiversNotifyGinResponse 分账动账通知API - 回调通知 - 解密后数据
type ProfitSharingReceiversNotifyGinResponse struct {
SpMchid string `json:"sp_mchid"` // 服务商商户号
SubMchid string `json:"sub_mchid"` // 子商户号
TransactionId string `json:"transaction_id"` // 微信订单号
OrderId string `json:"order_id"` // 微信分账/回退单号
OutOrderNo string `json:"out_order_no"` // 商户分账/回退单号
Receiver struct {
Type string `json:"type"` // 分账接收方类型
Account string `json:"account"` // 分账接收方账号
Amount int `json:"amount"` // 分账动账金额
Description string `json:"description"` // 分账/回退描述
} `json:"receiver"` // 分账接收方列表
SuccessTime string `json:"success_time"` // 成功时间
}

@ -0,0 +1,55 @@
package wechatpayopen
import (
"context"
"encoding/json"
"go.dtapp.net/gorequest"
"net/http"
)
type ProfitSharingReturnOrdersResponse struct {
SubMchid string `json:"sub_mchid"` // 子商户号
OrderId string `json:"order_id"` // 微信分账单号
OutOrderNo string `json:"out_order_no"` // 商户分账单号
OutReturnNo string `json:"out_return_no"` // 商户回退单号
ReturnId string `json:"return_id"` // 微信回退单号
ReturnMchid string `json:"return_mchid"` // 回退商户号
Amount int `json:"amount"` // 回退金额
Description string `json:"description"` // 回退描述
Result string `json:"result"` // 回退结果
FailReason string `json:"fail_reason"` // 失败原因
CreateTime string `json:"create_time"` // 创建时间
FinishTime string `json:"finish_time"` // 完成时间
}
type ProfitSharingReturnOrdersResult struct {
Result ProfitSharingReturnOrdersResponse // 结果
Body []byte // 内容
Http gorequest.Response // 请求
Err error // 错误
ApiError ApiError // 接口错误
}
func newProfitSharingReturnOrdersResult(result ProfitSharingReturnOrdersResponse, body []byte, http gorequest.Response, err error, apiError ApiError) *ProfitSharingReturnOrdersResult {
return &ProfitSharingReturnOrdersResult{Result: result, Body: body, Http: http, Err: err, ApiError: apiError}
}
// ProfitSharingReturnOrders 请求分账回退API
// https://pay.weixin.qq.com/wiki/doc/apiv3_partner/apis/chapter8_1_3.shtml
func (c *Client) ProfitSharingReturnOrders(ctx context.Context, notMustParams ...gorequest.Params) *ProfitSharingReturnOrdersResult {
// 参数
params := gorequest.NewParamsWith(notMustParams...)
params.Set("sub_mchid", c.GetSubMchId()) // 子商户号
// 请求
request, err := c.request(ctx, apiUrl+"/v3/profitsharing/return-orders", params, http.MethodPost)
if err != nil {
return newProfitSharingReturnOrdersResult(ProfitSharingReturnOrdersResponse{}, request.ResponseBody, request, err, ApiError{})
}
// 定义
var response ProfitSharingReturnOrdersResponse
err = json.Unmarshal(request.ResponseBody, &response)
// 错误
var apiError ApiError
err = json.Unmarshal(request.ResponseBody, &apiError)
return newProfitSharingReturnOrdersResult(response, request.ResponseBody, request, err, apiError)
}

@ -0,0 +1,57 @@
package wechatpayopen
import (
"context"
"encoding/json"
"go.dtapp.net/gorequest"
"net/http"
)
type ProfitSharingReturnOrdersOutReturnNoResponse struct {
SubMchid string `json:"sub_mchid"` // 子商户号
OrderId string `json:"order_id"` // 微信分账单号
OutOrderNo string `json:"out_order_no"` // 商户分账单号
OutReturnNo string `json:"out_return_no"` // 商户回退单号
ReturnId string `json:"return_id"` // 微信回退单号
ReturnMchid string `json:"return_mchid"` // 回退商户号
Amount int `json:"amount"` // 回退金额
Description string `json:"description"` // 回退描述
Result string `json:"result"` // 回退结果
FailReason string `json:"fail_reason"` // 失败原因
CreateTime string `json:"create_time"` // 创建时间
FinishTime string `json:"finish_time"` // 完成时间
}
type ProfitSharingReturnOrdersOutReturnNoResult struct {
Result ProfitSharingReturnOrdersOutReturnNoResponse // 结果
Body []byte // 内容
Http gorequest.Response // 请求
Err error // 错误
ApiError ApiError // 接口错误
}
func newProfitSharingReturnOrdersOutReturnNoResult(result ProfitSharingReturnOrdersOutReturnNoResponse, body []byte, http gorequest.Response, err error, apiError ApiError) *ProfitSharingReturnOrdersOutReturnNoResult {
return &ProfitSharingReturnOrdersOutReturnNoResult{Result: result, Body: body, Http: http, Err: err, ApiError: apiError}
}
// ProfitSharingReturnOrdersOutReturnNo 查询分账回退结果API
// https://pay.weixin.qq.com/wiki/doc/apiv3_partner/apis/chapter8_1_4.shtml
func (c *Client) ProfitSharingReturnOrdersOutReturnNo(ctx context.Context, outReturnNo, outOrderNo string) *ProfitSharingReturnOrdersOutReturnNoResult {
// 参数
params := gorequest.NewParams()
params.Set("sub_mchid", c.GetSubMchId()) // 子商户号
params.Set("out_return_no", outReturnNo) // 商户回退单号
params.Set("out_order_no", outOrderNo) // 商户分账单号
// 请求
request, err := c.request(ctx, apiUrl+"/v3/profitsharing/return-orders/"+outReturnNo, params, http.MethodGet)
if err != nil {
return newProfitSharingReturnOrdersOutReturnNoResult(ProfitSharingReturnOrdersOutReturnNoResponse{}, request.ResponseBody, request, err, ApiError{})
}
// 定义
var response ProfitSharingReturnOrdersOutReturnNoResponse
err = json.Unmarshal(request.ResponseBody, &response)
// 错误
var apiError ApiError
err = json.Unmarshal(request.ResponseBody, &apiError)
return newProfitSharingReturnOrdersOutReturnNoResult(response, request.ResponseBody, request, err, apiError)
}

@ -0,0 +1,44 @@
package wechatpayopen
import (
"context"
"encoding/json"
"go.dtapp.net/gorequest"
"net/http"
)
type ProfitSharingTransactionsAmountsResponse struct {
TransactionId string `json:"transaction_id"` // 微信订单号
UnsplitAmount int `json:"unsplit_amount"` // 订单剩余待分金额
}
type ProfitSharingTransactionsAmountsResult struct {
Result ProfitSharingTransactionsAmountsResponse // 结果
Body []byte // 内容
Http gorequest.Response // 请求
Err error // 错误
ApiError ApiError // 接口错误
}
func newProfitSharingTransactionsAmountsResult(result ProfitSharingTransactionsAmountsResponse, body []byte, http gorequest.Response, err error, apiError ApiError) *ProfitSharingTransactionsAmountsResult {
return &ProfitSharingTransactionsAmountsResult{Result: result, Body: body, Http: http, Err: err, ApiError: apiError}
}
// ProfitSharingTransactionsAmounts 查询剩余待分金额API
// https://pay.weixin.qq.com/wiki/doc/apiv3_partner/apis/chapter8_1_6.shtml
func (c *Client) ProfitSharingTransactionsAmounts(ctx context.Context, transactionId string) *ProfitSharingTransactionsAmountsResult {
// 参数
params := gorequest.NewParams()
// 请求
request, err := c.request(ctx, apiUrl+"/v3/profitsharing/transactions/"+transactionId, params, http.MethodGet)
if err != nil {
return newProfitSharingTransactionsAmountsResult(ProfitSharingTransactionsAmountsResponse{}, request.ResponseBody, request, err, ApiError{})
}
// 定义
var response ProfitSharingTransactionsAmountsResponse
err = json.Unmarshal(request.ResponseBody, &response)
// 错误
var apiError ApiError
err = json.Unmarshal(request.ResponseBody, &apiError)
return newProfitSharingTransactionsAmountsResult(response, request.ResponseBody, request, err, apiError)
}

@ -51,14 +51,15 @@ type RefundDomesticRefundsResponse struct {
}
type RefundDomesticRefundsResult struct {
Result RefundDomesticRefundsResponse // 结果
Body []byte // 内容
Http gorequest.Response // 请求
Err error // 错误
Result RefundDomesticRefundsResponse // 结果
Body []byte // 内容
Http gorequest.Response // 请求
Err error // 错误
ApiError ApiError // 接口错误
}
func newRefundDomesticRefundsResult(result RefundDomesticRefundsResponse, body []byte, http gorequest.Response, err error) *RefundDomesticRefundsResult {
return &RefundDomesticRefundsResult{Result: result, Body: body, Http: http, Err: err}
func newRefundDomesticRefundsResult(result RefundDomesticRefundsResponse, body []byte, http gorequest.Response, err error, apiError ApiError) *RefundDomesticRefundsResult {
return &RefundDomesticRefundsResult{Result: result, Body: body, Http: http, Err: err, ApiError: apiError}
}
// RefundDomesticRefunds 申请退款API
@ -70,10 +71,13 @@ func (c *Client) RefundDomesticRefunds(ctx context.Context, notMustParams ...gor
// 请求
request, err := c.request(ctx, apiUrl+"/v3/refund/domestic/refunds", params, http.MethodPost)
if err != nil {
return newRefundDomesticRefundsResult(RefundDomesticRefundsResponse{}, request.ResponseBody, request, err)
return newRefundDomesticRefundsResult(RefundDomesticRefundsResponse{}, request.ResponseBody, request, err, ApiError{})
}
// 定义
var response RefundDomesticRefundsResponse
err = json.Unmarshal(request.ResponseBody, &response)
return newRefundDomesticRefundsResult(response, request.ResponseBody, request, err)
// 错误
var apiError ApiError
err = json.Unmarshal(request.ResponseBody, &apiError)
return newRefundDomesticRefundsResult(response, request.ResponseBody, request, err, apiError)
}

@ -2,10 +2,12 @@ package wechatpayopen
import (
"context"
"encoding/json"
"github.com/gin-gonic/gin"
)
type ResponseRefundDomesticRefundsNoNotifyGin struct {
// RefundDomesticRefundsNoNotifyGinRequest 申请退款API - 回调通知 - 请求参数
type RefundDomesticRefundsNoNotifyGinRequest struct {
Id string `form:"id" json:"status" xml:"id" uri:"id" binding:"required"` // 通知ID
CreateTime string `form:"create_time" json:"create_time" xml:"create_time" uri:"create_time" binding:"required"` // 通知创建时间
EventType string `form:"event_type" json:"event_type" xml:"event_type" uri:"event_type" binding:"required"` // 通知类型
@ -22,25 +24,36 @@ type ResponseRefundDomesticRefundsNoNotifyGin struct {
// RefundDomesticRefundsNoNotifyGin 申请退款API - 回调通知
// https://pay.weixin.qq.com/wiki/doc/apiv3_partner/apis/chapter4_1_11.shtml
func (c *Client) RefundDomesticRefundsNoNotifyGin(ctx context.Context, ginCtx *gin.Context) (ResponseRefundDomesticRefundsNoNotifyGin, error) {
// 声明接收的变量
var validateJson struct {
Id string `form:"id" json:"status" xml:"id" uri:"id" binding:"required"` // 通知ID
CreateTime string `form:"create_time" json:"create_time" xml:"create_time" uri:"create_time" binding:"required"` // 通知创建时间
EventType string `form:"event_type" json:"event_type" xml:"event_type" uri:"event_type" binding:"required"` // 通知类型
Summary string `form:"summary" json:"summary" xml:"summary" uri:"summary" binding:"required"` // 通知简要说明
ResourceType string `form:"resource_type" json:"resource_type" xml:"resource_type" uri:"resource_type" binding:"required"` // 通知数据类型
Resource struct {
Algorithm string `form:"algorithm" json:"algorithm" xml:"algorithm" uri:"algorithm" binding:"required"` // 加密算法类型
Ciphertext string `form:"ciphertext" json:"ciphertext" xml:"ciphertext" uri:"ciphertext" binding:"required"` // 数据密文
AssociatedData string `form:"associated_data" json:"associated_data" xml:"associated_data" uri:"associated_data" binding:"omitempty"` // 附加数据
OriginalType string `form:"original_type" json:"original_type" xml:"original_type" uri:"original_type" binding:"required"` // 原始类型
Nonce string `form:"nonce" json:"nonce" xml:"nonce" uri:"nonce" binding:"required"` // 随机串
} `form:"resource" json:"resource" xml:"resource" uri:"resource" binding:"required"` // 通知数据
func (c *Client) RefundDomesticRefundsNoNotifyGin(ctx context.Context, ginCtx *gin.Context) (validateJson RefundDomesticRefundsNoNotifyGinRequest, response RefundDomesticRefundsNoNotifyGinResponse, gcm []byte, err error) {
// 解析
err = ginCtx.ShouldBind(&validateJson)
gcm, err = c.decryptGCM(c.GetApiV3(), validateJson.Resource.Nonce, validateJson.Resource.Ciphertext, validateJson.Resource.AssociatedData)
if err != nil {
return validateJson, response, gcm, err
}
err := ginCtx.ShouldBind(&validateJson)
err = json.Unmarshal(gcm, &response)
return validateJson, response, gcm, err
}
return validateJson, err
// RefundDomesticRefundsNoNotifyGinResponse 申请退款API - 回调通知 - 解密后数据
type RefundDomesticRefundsNoNotifyGinResponse struct {
SpMchid string `json:"sp_mchid"` // 服务商户号
SubMchid string `json:"sub_mchid"` // 子商户号
OutTradeNo string `json:"out_trade_no"` // 商户订单号
TransactionId string `json:"transaction_id"` // 微信支付订单号
OutRefundNo string `json:"out_refund_no"` // 商户退款单号
RefundId string `json:"refund_id"` // 微信支付退款单号
RefundStatus string `json:"refund_status"` // 退款状态
SuccessTime string `json:"success_time"` // 退款成功时间
UserReceivedAccount string `json:"user_received_account"` // 退款入账账户
Amount struct {
Total int `json:"total"` // 订单金额
Refund int `json:"refund"` // 退款金额
PayerTotal int `json:"payer_total"` // 用户支付金额
PayerRefund int `json:"payer_refund"` // 用户退款金额
} `json:"amount"` // 金额信息
}

@ -51,14 +51,15 @@ type RefundDomesticRefundsOutRefundNoResponse struct {
}
type RefundDomesticRefundsOutRefundNoResult struct {
Result RefundDomesticRefundsOutRefundNoResponse // 结果
Body []byte // 内容
Http gorequest.Response // 请求
Err error // 错误
Result RefundDomesticRefundsOutRefundNoResponse // 结果
Body []byte // 内容
Http gorequest.Response // 请求
Err error // 错误
ApiError ApiError // 接口错误
}
func newRefundDomesticRefundsOutRefundNoResult(result RefundDomesticRefundsOutRefundNoResponse, body []byte, http gorequest.Response, err error) *RefundDomesticRefundsOutRefundNoResult {
return &RefundDomesticRefundsOutRefundNoResult{Result: result, Body: body, Http: http, Err: err}
func newRefundDomesticRefundsOutRefundNoResult(result RefundDomesticRefundsOutRefundNoResponse, body []byte, http gorequest.Response, err error, apiError ApiError) *RefundDomesticRefundsOutRefundNoResult {
return &RefundDomesticRefundsOutRefundNoResult{Result: result, Body: body, Http: http, Err: err, ApiError: apiError}
}
// RefundDomesticRefundsOutRefundNo 查询单笔退款API
@ -69,10 +70,13 @@ func (c *Client) RefundDomesticRefundsOutRefundNo(ctx context.Context, outRefund
// 请求
request, err := c.request(ctx, apiUrl+"/v3/refund/domestic/refunds/"+outRefundNo+"?sub_mchid="+c.GetSubMchId(), params, http.MethodGet)
if err != nil {
return newRefundDomesticRefundsOutRefundNoResult(RefundDomesticRefundsOutRefundNoResponse{}, request.ResponseBody, request, err)
return newRefundDomesticRefundsOutRefundNoResult(RefundDomesticRefundsOutRefundNoResponse{}, request.ResponseBody, request, err, ApiError{})
}
// 定义
var response RefundDomesticRefundsOutRefundNoResponse
err = json.Unmarshal(request.ResponseBody, &response)
return newRefundDomesticRefundsOutRefundNoResult(response, request.ResponseBody, request, err)
// 错误
var apiError ApiError
err = json.Unmarshal(request.ResponseBody, &apiError)
return newRefundDomesticRefundsOutRefundNoResult(response, request.ResponseBody, request, err, apiError)
}

@ -42,13 +42,9 @@ func (c *Client) request(ctx context.Context, url string, params map[string]inte
return gorequest.Response{}, err
}
// 日志
if c.log.gorm {
go c.log.logGormClient.GormMiddleware(ctx, request, Version)
// 记录日志
if c.log.status {
go c.log.client.Middleware(ctx, request, Version)
}
if c.log.mongo {
go c.log.logMongoClient.MongoMiddleware(ctx, request, Version)
}
return request, err
}

@ -0,0 +1,5 @@
package wechatpayopen
func (c *Client) SignDecrypt(aesKey, associatedData, nonce, ciphertext string) ([]byte, error) {
return c.decryptGCM(aesKey, nonce, ciphertext, associatedData)
}
Loading…
Cancel
Save