diff --git a/const.go b/const.go index 7d35536..0f3fd83 100644 --- a/const.go +++ b/const.go @@ -3,5 +3,5 @@ package wechatpayapiv2 const ( apiUrl = "https://api.mch.weixin.qq.com" logTable = "wechatpayapiv2" - Version = "1.0.6" + Version = "1.0.7" ) diff --git a/go.mod b/go.mod index b18f9f7..0200a01 100644 --- a/go.mod +++ b/go.mod @@ -3,9 +3,10 @@ module go.dtapp.net/wechatpayapiv2 go 1.19 require ( - go.dtapp.net/dorm v1.0.30 + github.com/gin-gonic/gin v1.8.1 + go.dtapp.net/dorm v1.0.32 go.dtapp.net/gojson v1.0.1 - go.dtapp.net/golog v1.0.55 + go.dtapp.net/golog v1.0.68 go.dtapp.net/gomd5 v1.0.1 go.dtapp.net/gorandom v1.0.1 go.dtapp.net/gorequest v1.0.28 @@ -18,7 +19,6 @@ 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/gin-gonic/gin v1.8.1 // 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 @@ -41,7 +41,7 @@ require ( github.com/json-iterator/go v1.1.12 // indirect github.com/klauspost/compress v1.15.9 // indirect github.com/leodido/go-urn v1.2.1 // indirect - github.com/lib/pq v1.10.6 // indirect + github.com/lib/pq v1.10.7 // indirect github.com/mattn/go-isatty v0.0.16 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect @@ -51,13 +51,14 @@ require ( 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/sirupsen/logrus v1.9.0 // indirect github.com/syndtr/goleveldb v1.0.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 - github.com/upper/db/v4 v4.5.4 // indirect + github.com/upper/db/v4 v4.6.0 // indirect github.com/uptrace/bun v1.1.8 // indirect github.com/uptrace/bun/dialect/mysqldialect v1.1.8 // indirect github.com/uptrace/bun/dialect/pgdialect v1.1.8 // indirect @@ -73,16 +74,15 @@ require ( 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.dtapp.net/goxml v1.0.1 // indirect - go.mongodb.org/mongo-driver v1.10.1 // indirect + go.mongodb.org/mongo-driver v1.10.2 // 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-20220826154423-83b083e8dc8b // 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-20220829200755-d48e67d00261 // indirect + golang.org/x/sys v0.0.0-20220907062415-87db552b00fd // indirect golang.org/x/text v0.3.7 // indirect google.golang.org/protobuf v1.28.1 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect diff --git a/go.sum b/go.sum index ed7137a..4139a79 100644 --- a/go.sum +++ b/go.sum @@ -63,8 +63,8 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/denisenkom/go-mssqldb v0.10.0/go.mod h1:xbL0rPBG9cCiLr28tMa8zpbdarY27NDyej4t/EjAShU= github.com/denisenkom/go-mssqldb v0.11.0/go.mod h1:xbL0rPBG9cCiLr28tMa8zpbdarY27NDyej4t/EjAShU= +github.com/denisenkom/go-mssqldb v0.12.0 h1:VtrkII767ttSPNRfFekePK3sctr+joXgO58stqQbtUA= github.com/denisenkom/go-mssqldb v0.12.0/go.mod h1:iiK0YP1ZeepvmBQk/QpLEhhTNJgfzrpArPY/aFvc9yU= -github.com/denisenkom/go-mssqldb v0.12.2 h1:1OcPn5GBIobjWNd+8yjfHNIaFX14B1pWI3F9HZy5KXw= github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78= github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc= @@ -304,8 +304,8 @@ github.com/lib/pq v1.2.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= github.com/lib/pq v1.3.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= github.com/lib/pq v1.10.2/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= github.com/lib/pq v1.10.4/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= -github.com/lib/pq v1.10.6 h1:jbk+ZieJ0D7EVGJYpL9QTz7/YW6UHbmdnZWYyK5cdBs= -github.com/lib/pq v1.10.6/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= +github.com/lib/pq v1.10.7 h1:p7ZhMD+KsSRozJr34udlUrhboJwWAgCg34+/ZZNvZZw= +github.com/lib/pq v1.10.7/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= github.com/lightstep/lightstep-tracer-common/golang/gogo v0.0.0-20190605223551-bc2310a04743/go.mod h1:qklhhLq1aX+mtWk9cPHPzaBjWImj5ULL6C7HFJtXQMM= github.com/lightstep/lightstep-tracer-go v0.18.1/go.mod h1:jlF1pusYV4pidLvZ+XD0UBX0ZE6WURAspgAczcDHrL4= github.com/lyft/protoc-gen-validate v0.0.13/go.mod h1:XbGvPuh87YZc5TdIa2/I4pLk0QoUACkjt2znoq26NVQ= @@ -332,6 +332,7 @@ github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceT github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= github.com/mitchellh/go-testing-interface v1.0.0/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI= github.com/mitchellh/gox v0.4.0/go.mod h1:Sd9lOJ0+aimLBi73mGofS1ycjY8lL3uZM3JPS42BGNg= +github.com/mitchellh/hashstructure/v2 v2.0.2/go.mod h1:MG3aRVU/N29oo/V/IhBX8GR/zz4kQkprJgF2EVszyDE= github.com/mitchellh/iochan v1.0.0/go.mod h1:JwYml1nuB7xOzsp52dPpHFffvOCDupsG0QubkSMEySY= github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= @@ -430,6 +431,8 @@ github.com/saracen/solidblock v0.0.0-20190426153529-45df20abab6f h1:1cJITU3JUI8q github.com/saracen/solidblock v0.0.0-20190426153529-45df20abab6f/go.mod h1:LyBTue+RWeyIfN3ZJ4wVxvDuvlGJtDgCLgCb6HCPgps= github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= +github.com/segmentio/fasthash v1.0.3 h1:EI9+KE1EwvMLBWwjpRDc+fEM+prwxDYbslddQGtrmhM= +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/shopspring/decimal v0.0.0-20180709203117-cd690d0c9e24/go.mod h1:M+9NzErvs504Cn4c5DxATwIqPbtswREoFCre64PpcG4= @@ -477,8 +480,8 @@ github.com/ugorji/go/codec v1.2.7 h1:YPXUKf7fYbp/y8xloBqZOw2qaVggbfwMlI8WM3wZUJ0 github.com/ugorji/go/codec v1.2.7/go.mod h1:WGN1fab3R1fzQlVQTkfxVtIBhWDRqOviHU95kRgeqEY= github.com/ulikunitz/xz v0.5.10 h1:t92gobL9l3HE202wg3rlk19F6X+JOxl9BBrCCMYEYd8= github.com/ulikunitz/xz v0.5.10/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14= -github.com/upper/db/v4 v4.5.4 h1:Hxho4jSx4E+3fxlFgdH4wQTRKygtL0YQPDLQPCUu9wg= -github.com/upper/db/v4 v4.5.4/go.mod h1:wyu5BM5Y2gowOt4i6C4LbxftH9QeUF338XVGH4uk+Eo= +github.com/upper/db/v4 v4.6.0 h1:0VmASnqrl/XN8Ehoq++HBgZ4zRD5j3GXygW8FhP0C5I= +github.com/upper/db/v4 v4.6.0/go.mod h1:2mnRcPf+RcCXmVcD+o04LYlyu3UuF7ubamJia7CkN6s= github.com/uptrace/bun v1.1.8 h1:slxuaP4LYWFbPRUmTtQhfJN+6eX/6ar2HDKYTcI50SA= github.com/uptrace/bun v1.1.8/go.mod h1:iT89ESdV3uMupD9ixt6Khidht+BK0STabK/LeZE+B84= github.com/uptrace/bun/dialect/mysqldialect v1.1.8 h1:gcL5iy0yUbuJJLkE+0G3vAUS/6GjPLkqFTtN2+tx7XU= @@ -506,14 +509,14 @@ github.com/youmark/pkcs8 v0.0.0-20201027041543-1326539a0a0a/go.mod h1:ul22v+Nro/ github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= 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.30 h1:B2gwSe1ov4S+LPUv1ijFm4XE2KEeNn85eCP4WLilsCU= -go.dtapp.net/dorm v1.0.30/go.mod h1:7ysGN47mW3u0EDAzXI3oUYZZHA3uasf2spugHeANPW8= +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/gojson v1.0.1 h1:MHeSGlq1KxzL7rCkm18fhwW4GNORHohdDMmxY5PupKY= go.dtapp.net/gojson v1.0.1/go.mod h1:TkkpTNxHBKxul0e7gC5MrL1K4ICFB9mQ7wHzjBah3/k= -go.dtapp.net/golog v1.0.55 h1:GSxajhpLbssXF4kRlGVArLBMjTCqunttLVipfmkBWbo= -go.dtapp.net/golog v1.0.55/go.mod h1:5xs4w/9Aq1gfuauj2KCRGegCjaiyHmiJ3Deb3xy8tDY= +go.dtapp.net/golog v1.0.68 h1:rCXd1PLhfzKRkv+qS/XjERpv2sOHkcw9gPOIb0KCmgk= +go.dtapp.net/golog v1.0.68/go.mod h1:S0LEEBp9Eq7WvXG2LadXsPm6II4pMfv5KOCnrcUIBzI= go.dtapp.net/gomd5 v1.0.1 h1:fFfdPjnGyLGC8K4LxP7beZ0pVCGiORmii7LXmTJzksM= go.dtapp.net/gomd5 v1.0.1/go.mod h1:orBj05S7c2+4p7ENlI3eOULl19ad5vLbFZoT3LRDNAM= go.dtapp.net/gorandom v1.0.1 h1:IWfMClh1ECPvyUjlqD7MwLq4mZdUusD1qAwAdsvEJBs= @@ -528,12 +531,10 @@ go.dtapp.net/gotrace_id v1.0.6 h1:q6s8jy50vt1820b69JKQaFqbhGS5yJGMVtocwOGOPO0= go.dtapp.net/gotrace_id v1.0.6/go.mod h1:o5kSzNK4s3GrrKpkRKXtAhArtBG1e5N5O5KGPlBlWG4= go.dtapp.net/gourl v1.0.0 h1:Zbe0GiMFyyRy2+bjbVsYulakH5d58w3CDZkUPonlMoQ= go.dtapp.net/gourl v1.0.0/go.mod h1:x9A/pJ3iKDTb6Gu2RtJy2iHg56IowXIcIGQdogqpGjs= -go.dtapp.net/goxml v1.0.1 h1:WODsjNpmHTtoeLsXgOjC81qRbu4aXZ3LKBHApNGaPjY= -go.dtapp.net/goxml v1.0.1/go.mod h1:duD2uvBofiu/Rer1XQH2FyUhIkj6Zjapp4NDwRvoiQE= 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.1 h1:NujsPveKwHaWuKUer/ceo9DzEe7HIj1SlJ6uvXZG0S4= -go.mongodb.org/mongo-driver v1.10.1/go.mod h1:z4XpeoU6w+9Vht+jAFyLgVrD+jGSQQe0+CBWFHNiHt8= +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.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= @@ -614,8 +615,8 @@ golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwY golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210610132358-84b48f89b13b/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20220826154423-83b083e8dc8b h1:ZmngSVLe/wycRns9MKikG9OWIEjGcGAkacif7oYQaUY= -golang.org/x/net v0.0.0-20220826154423-83b083e8dc8b/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk= +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/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= @@ -661,8 +662,8 @@ golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20211210111614-af8b64212486/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-20220829200755-d48e67d00261 h1:v6hYoSR9T5oet+pMXwUWkbiVqx/63mlHjefrHmxwfeY= -golang.org/x/sys v0.0.0-20220829200755-d48e67d00261/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220907062415-87db552b00fd h1:AZeIEzg+8RCELJYq8w+ODLVxFgLMMigSwO/ffKPEd9U= +golang.org/x/sys v0.0.0-20220907062415-87db552b00fd/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= @@ -754,10 +755,10 @@ gorm.io/driver/mysql v1.3.6/go.mod h1:sSIebwZAVPiT+27jK9HIwvsqOGKx3YMPmrA3mBJR10 gorm.io/driver/postgres v1.3.4/go.mod h1:y0vEuInFKJtijuSGu9e5bs5hzzSzPK+LancpKpvbRBw= gorm.io/driver/postgres v1.3.9 h1:lWGiVt5CijhQAg0PWB7Od1RNcBw/jS4d2cAScBcSDXg= gorm.io/driver/postgres v1.3.9/go.mod h1:qw/FeqjxmYqW5dBcYNBsnhQULIApQdk7YuuDPktVi1U= +gorm.io/driver/sqlite v1.3.1 h1:bwfE+zTEWklBYoEodIOIBwuWHpnx52Z9zJFW5F33WLk= gorm.io/driver/sqlite v1.3.1/go.mod h1:wJx0hJspfycZ6myN38x1O/AqLtNS6c5o9TndewFbELg= -gorm.io/driver/sqlite v1.3.6 h1:Fi8xNYCUplOqWiPa3/GuCeowRNBRGTf62DEmhMDHeQQ= +gorm.io/driver/sqlserver v1.3.1 h1:F5t6ScMzOgy1zukRTIZgLZwKahgt3q1woAILVolKpOI= gorm.io/driver/sqlserver v1.3.1/go.mod h1:w25Vrx2BG+CJNUu/xKbFhaKlGxT/nzRkhWCCoptX8tQ= -gorm.io/driver/sqlserver v1.3.2 h1:yYt8f/xdAKLY7lCCyXxIUEgZ/WsURos3dHrx8MKFGAk= gorm.io/gorm v1.23.1/go.mod h1:l2lP/RyAtc1ynaTjFksBde/O8v9oOGIApu2/xRitmZk= gorm.io/gorm v1.23.6/go.mod h1:l2lP/RyAtc1ynaTjFksBde/O8v9oOGIApu2/xRitmZk= gorm.io/gorm v1.23.7/go.mod h1:l2lP/RyAtc1ynaTjFksBde/O8v9oOGIApu2/xRitmZk= diff --git a/mmpaymkttransfers.gettransferinfo.go b/mmpaymkttransfers.gettransferinfo.go index 1a0bddb..26ee3f4 100644 --- a/mmpaymkttransfers.gettransferinfo.go +++ b/mmpaymkttransfers.gettransferinfo.go @@ -8,11 +8,13 @@ import ( ) type TransfersQueryResponse struct { - ReturnCode string `json:"return_code" xml:"return_code"` // 返回状态码 - ReturnMsg string `json:"return_msg,omitempty" xml:"return_msg,omitempty"` // 返回信息 - ResultCode string `json:"result_code" xml:"result_code"` // 业务结果 - ErrCode string `json:"err_code,omitempty" xml:"err_code,omitempty"` // 错误代码 - ErrCodeDes string `json:"err_code_des,omitempty" xml:"err_code_des,omitempty"` // 错误代码描述 + ReturnCode string `json:"return_code" xml:"return_code"` // 返回状态码 + ReturnMsg string `json:"return_msg,omitempty" xml:"return_msg,omitempty"` // 返回信息 + + ResultCode string `json:"result_code" xml:"result_code"` // 业务结果 + ErrCode string `json:"err_code,omitempty" xml:"err_code,omitempty"` // 错误代码 + ErrCodeDes string `json:"err_code_des,omitempty" xml:"err_code_des,omitempty"` // 错误代码描述 + PartnerTradeNo string `json:"partner_trade_no" xml:"partner_trade_no"` // 商户单号 Appid string `json:"appid" xml:"appid"` // Appid MchId string `json:"mch_id" xml:"mch_id"` // 商户号 @@ -40,6 +42,7 @@ func newTransfersQueryResult(result TransfersQueryResponse, body []byte, http go // TransfersQuery // 付款到零钱 - 查询付款 +// 需要证书 // https://pay.weixin.qq.com/wiki/doc/api/tools/mch_pay.php?chapter=14_3 func (c *Client) TransfersQuery(ctx context.Context, partnerTradeNo string) *TransfersQueryResult { cert, err := c.P12ToPem() @@ -52,7 +55,7 @@ func (c *Client) TransfersQuery(ctx context.Context, partnerTradeNo string) *Tra // 签名 params.Set("sign", c.getMd5Sign(params)) // 请求 - request, err := c.request(ctx, apiUrl+"/mmpaymkttransfers/gettransferinfo", params, cert) + request, err := c.request(ctx, apiUrl+"/mmpaymkttransfers/gettransferinfo", params, true, cert) // 定义 var response TransfersQueryResponse err = xml.Unmarshal(request.ResponseBody, &response) diff --git a/mmpaymkttransfers.promotion.transfers.go b/mmpaymkttransfers.promotion.transfers.go index a666263..7531c76 100644 --- a/mmpaymkttransfers.promotion.transfers.go +++ b/mmpaymkttransfers.promotion.transfers.go @@ -8,18 +8,20 @@ import ( ) type TransfersResponse struct { - ReturnCode string `json:"return_code" xml:"return_code"` // 返回状态码 - ReturnMsg string `json:"return_msg,omitempty" xml:"return_msg,omitempty"` // 返回信息 - MchAppid string `json:"mch_appid" xml:"mch_appid"` // 商户appid - Mchid string `json:"mchid" xml:"mchid"` // 商户号 - DeviceInfo string `json:"device_info,omitempty" xml:"device_info,omitempty"` // 设备号 - NonceStr string `json:"nonce_str" xml:"nonce_str"` // 随机字符串 - ResultCode string `json:"result_code" xml:"result_code"` // 业务结果 - ErrCode string `json:"err_code,omitempty" xml:"err_code,omitempty"` // 错误代码 - ErrCodeDes string `json:"err_code_des,omitempty" xml:"err_code_des,omitempty"` // 错误代码描述 - PartnerTradeNo string `json:"partner_trade_no" xml:"partner_trade_no"` // 商户订单号 - PaymentNo string `json:"payment_no" xml:"payment_no"` // 微信付款单号 - PaymentTime string `json:"payment_time" xml:"payment_time"` // 付款成功时间 + ReturnCode string `json:"return_code" xml:"return_code"` // 返回状态码 + ReturnMsg string `json:"return_msg,omitempty" xml:"return_msg,omitempty"` // 返回信息 + + ResultCode string `json:"result_code" xml:"result_code"` // 业务结果 + ErrCode string `json:"err_code,omitempty" xml:"err_code,omitempty"` // 错误代码 + ErrCodeDes string `json:"err_code_des,omitempty" xml:"err_code_des,omitempty"` // 错误代码描述 + + MchAppid string `json:"mch_appid" xml:"mch_appid"` // 商户appid + Mchid string `json:"mchid" xml:"mchid"` // 商户号 + DeviceInfo string `json:"device_info,omitempty" xml:"device_info,omitempty"` // 设备号 + NonceStr string `json:"nonce_str" xml:"nonce_str"` // 随机字符串 + PartnerTradeNo string `json:"partner_trade_no" xml:"partner_trade_no"` // 商户订单号 + PaymentNo string `json:"payment_no" xml:"payment_no"` // 微信付款单号 + PaymentTime string `json:"payment_time" xml:"payment_time"` // 付款成功时间 } type TransfersResult struct { @@ -35,6 +37,7 @@ func newTransfersResult(result TransfersResponse, body []byte, http gorequest.Re // Transfers // 付款到零钱 - 付款 +// 需要证书 // https://pay.weixin.qq.com/wiki/doc/api/tools/mch_pay.php?chapter=14_2 func (c *Client) Transfers(ctx context.Context, partnerTradeNo, openid string, amount int64, desc string) *TransfersResult { cert, err := c.P12ToPem() @@ -51,7 +54,7 @@ func (c *Client) Transfers(ctx context.Context, partnerTradeNo, openid string, a // 签名 params.Set("sign", c.getMd5Sign(params)) // 请求 - request, err := c.request(ctx, apiUrl+"/mmpaymkttransfers/promotion/transfers", params, cert) + request, err := c.request(ctx, apiUrl+"/mmpaymkttransfers/promotion/transfers", params, true, cert) // 定义 var response TransfersResponse err = xml.Unmarshal(request.ResponseBody, &response) diff --git a/pay.closeorder.go b/pay.closeorder.go new file mode 100644 index 0000000..82befd3 --- /dev/null +++ b/pay.closeorder.go @@ -0,0 +1,54 @@ +package wechatpayapiv2 + +import ( + "context" + "encoding/xml" + "go.dtapp.net/gorandom" + "go.dtapp.net/gorequest" +) + +type PayCloseOrderResponse struct { + ReturnCode string `json:"return_code" xml:"return_code"` // 返回状态码 + ReturnMsg string `json:"return_msg,omitempty" xml:"return_msg,omitempty"` // 返回信息 + + ResultCode string `json:"result_code,omitempty" xml:"result_code,omitempty"` // 业务结果 + ResultMsg string `json:"result_msg,omitempty" xml:"result_msg,omitempty"` // 业务结果描述 + ErrCode string `json:"err_code,omitempty" xml:"err_code,omitempty"` // 错误代码 + ErrCodeDes string `json:"err_code_des,omitempty" xml:"err_code_des,omitempty"` // 错误代码描述 + + Appid string `json:"appid,omitempty" xml:"appid,omitempty"` // 小程序ID + MchId string `json:"mch_id,omitempty" xml:"mch_id,omitempty"` // 商户号 + NonceStr string `json:"nonce_str,omitempty" xml:"nonce_str,omitempty"` // 随机字符串 + Sign string `json:"sign,omitempty" xml:"sign,omitempty"` // 签名 +} + +type PayCloseOrderResult struct { + Result PayCloseOrderResponse // 结果 + Body []byte // 内容 + Http gorequest.Response // 请求 + Err error // 错误 +} + +func newPayCloseOrderResult(result PayCloseOrderResponse, body []byte, http gorequest.Response, err error) *PayCloseOrderResult { + return &PayCloseOrderResult{Result: result, Body: body, Http: http, Err: err} +} + +// PayCloseOrder +// 小程序支付 - 关闭订单 +// https://pay.weixin.qq.com/wiki/doc/api/wxa/wxa_api.php?chapter=9_3 +func (c *Client) PayCloseOrder(ctx context.Context, outTradeNo string) *PayCloseOrderResult { + // 参数 + params := NewParams() + params.Set("appid", c.GetAppId()) // 小程序ID + params.Set("mch_id", c.GetMchId()) // 商户号 + params.Set("out_trade_no", outTradeNo) // 商户订单号 + params.Set("nonce_str", gorandom.Alphanumeric(32)) // 随机字符串 + // 签名 + params.Set("sign", c.getMd5Sign(params)) + // 请求 + request, err := c.request(ctx, apiUrl+"/pay/closeorder", params, false, nil) + // 定义 + var response PayCloseOrderResponse + err = xml.Unmarshal(request.ResponseBody, &response) + return newPayCloseOrderResult(response, request.ResponseBody, request, err) +} diff --git a/pay.orderquery.go b/pay.orderquery.go new file mode 100644 index 0000000..8230646 --- /dev/null +++ b/pay.orderquery.go @@ -0,0 +1,79 @@ +package wechatpayapiv2 + +import ( + "context" + "encoding/xml" + "go.dtapp.net/gorandom" + "go.dtapp.net/gorequest" +) + +type PayOrderQueryResponse struct { + ReturnCode string `json:"return_code" xml:"return_code"` // 返回状态码 + ReturnMsg string `json:"return_msg,omitempty" xml:"return_msg,omitempty"` // 返回信息 + + ResultCode string `json:"result_code,omitempty" xml:"result_code,omitempty"` // 业务结果 + ErrCode string `json:"err_code,omitempty" xml:"err_code,omitempty"` // 错误代码 + ErrCodeDes string `json:"err_code_des,omitempty" xml:"err_code_des,omitempty"` // 错误代码描述 + + Appid string `json:"appid,omitempty" xml:"appid,omitempty"` // 小程序ID + MchId string `json:"mch_id,omitempty" xml:"mch_id,omitempty"` // 商户号 + NonceStr string `json:"nonce_str,omitempty" xml:"nonce_str,omitempty"` // 随机字符串 + Sign string `json:"sign,omitempty" xml:"sign,omitempty"` // 签名 + + DeviceInfo string `json:"device_info,omitempty" xml:"device_info,omitempty"` // 设备号 + Openid string `json:"openid,omitempty" xml:"openid,omitempty"` // 用户标识 + IsSubscribe string `json:"is_subscribe,omitempty" xml:"is_subscribe,omitempty"` // 是否关注公众账号 + TradeType string `json:"trade_type,omitempty" xml:"trade_type,omitempty"` // 交易类型 + TradeState string `json:"trade_state,omitempty" xml:"trade_state,omitempty"` // 交易状态 + BankType string `json:"bank_type,omitempty" xml:"bank_type,omitempty"` // 付款银行 + TotalFee int `json:"total_fee,omitempty" xml:"total_fee,omitempty"` // 标价金额 + SettlementTotalFee int `json:"settlement_total_fee,omitempty" xml:"settlement_total_fee,omitempty"` // 应结订单金额 + FeeType string `json:"fee_type,omitempty" xml:"fee_type,omitempty"` // 标价币种 + CashFee int `json:"cash_fee,omitempty" xml:"cash_fee,omitempty"` // 现金支付金额 + CashFeeType string `json:"cash_fee_type,omitempty" xml:"cash_fee_type,omitempty"` // 现金支付币种 + CouponFee int `json:"coupon_fee,omitempty" xml:"coupon_fee,omitempty"` // 代金券金额 + CouponCount int `json:"coupon_count,omitempty" xml:"coupon_count,omitempty"` // 代金券使用数量 + CouponType string `json:"coupon_type,omitempty" xml:"coupon_type,omitempty"` // 代金券类型 + CouponId string `json:"coupon_id,omitempty" xml:"coupon_id,omitempty"` // 代金券ID + TransactionId string `json:"transaction_id,omitempty" xml:"transaction_id,omitempty"` // 微信支付订单号 + OutTradeNo string `json:"out_trade_no,omitempty" xml:"out_trade_no,omitempty"` // 商户订单号 + Attach string `json:"attach,omitempty" xml:"attach,omitempty"` // 附加数据 + TimeEnd string `json:"time_end,omitempty" xml:"time_end,omitempty"` // 支付完成时间 + TradeStateDesc string `json:"trade_state_desc,omitempty" xml:"trade_state_desc,omitempty"` // 交易状态描述 +} + +type PayOrderQueryResult struct { + Result PayOrderQueryResponse // 结果 + Body []byte // 内容 + Http gorequest.Response // 请求 + Err error // 错误 +} + +func newPayOrderQueryResult(result PayOrderQueryResponse, body []byte, http gorequest.Response, err error) *PayOrderQueryResult { + return &PayOrderQueryResult{Result: result, Body: body, Http: http, Err: err} +} + +// PayOrderQuery +// 小程序支付 - 查询订单 +// https://pay.weixin.qq.com/wiki/doc/api/wxa/wxa_api.php?chapter=9_2 +func (c *Client) PayOrderQuery(ctx context.Context, transactionId, outTradeNo string) *PayOrderQueryResult { + // 参数 + params := gorequest.NewParams() + params.Set("appid", c.GetAppId()) // 小程序ID + params.Set("mch_id", c.GetMchId()) // 商户号 + if transactionId != "" { + params.Set("transaction_id", transactionId) // 微信订单号 + } + if outTradeNo != "" { + params.Set("out_trade_no", outTradeNo) // 商户订单号 + } + params.Set("nonce_str", gorandom.Alphanumeric(32)) // 随机字符串 + // 签名 + params.Set("sign", c.getMd5Sign(params)) + // 请求 + request, err := c.request(ctx, apiUrl+"/pay/orderquery", params, false, nil) + // 定义 + var response PayOrderQueryResponse + err = xml.Unmarshal(request.ResponseBody, &response) + return newPayOrderQueryResult(response, request.ResponseBody, request, err) +} diff --git a/pay.refundquery.go b/pay.refundquery.go new file mode 100644 index 0000000..951f0cb --- /dev/null +++ b/pay.refundquery.go @@ -0,0 +1,76 @@ +package wechatpayapiv2 + +import ( + "context" + "encoding/xml" + "go.dtapp.net/gorandom" + "go.dtapp.net/gorequest" +) + +type PayRefundQueryResponse struct { + ReturnCode string `json:"return_code" xml:"return_code"` // 返回状态码 + ReturnMsg string `json:"return_msg,omitempty" xml:"return_msg,omitempty"` // 返回信息 + + ResultCode string `json:"result_code,omitempty" xml:"result_code,omitempty"` // 业务结果 + ErrCode string `json:"err_code,omitempty" xml:"err_code,omitempty"` // 错误代码 + ErrCodeDes string `json:"err_code_des,omitempty" xml:"err_code_des,omitempty"` // 错误代码描述 + + Appid string `json:"appid,omitempty" xml:"appid,omitempty"` // 小程序ID + MchId string `json:"mch_id,omitempty" xml:"mch_id,omitempty"` // 商户号 + DeviceInfo string `json:"device_info,omitempty" xml:"device_info,omitempty"` // 设备号 + NonceStr string `json:"nonce_str,omitempty" xml:"nonce_str,omitempty"` // 随机字符串 + Sign string `json:"sign,omitempty" xml:"sign,omitempty"` // 签名 + + TotalRefundCount int `json:"total_refund_count,omitempty" xml:"total_refund_count,omitempty"` // 订单总退款次数 + TransactionId string `json:"transaction_id,omitempty" xml:"transaction_id,omitempty"` // 微信订单号 + OutTradeNo string `json:"out_trade_no,omitempty" xml:"out_trade_no,omitempty"` // 商户订单号 + TotalFee int `json:"total_fee,omitempty" xml:"total_fee,omitempty"` // 订单金额 + SettlementTotalFee int `json:"settlement_total_fee,omitempty" xml:"settlement_total_fee,omitempty"` // 应结订单金额 + FeeType string `json:"fee_type,omitempty" xml:"fee_type,omitempty"` // 货币种类 + CashFee int `json:"cash_fee,omitempty" xml:"cash_fee,omitempty"` // 现金支付金额 + RefundCount int `json:"refund_count,omitempty" xml:"refund_count,omitempty"` // 退款笔数 + OutRefundNo string `json:"out_refund_no,omitempty" xml:"out_refund_no,omitempty"` // 商户退款单号 + RefundId string `json:"refund_id,omitempty" xml:"refund_id,omitempty"` // 微信退款单号 + RefundChannel string `json:"refund_channel,omitempty" xml:"refund_channel,omitempty"` // 退款渠道 + RefundFee int `json:"refund_fee,omitempty" xml:"refund_fee,omitempty"` // 退款总金额 + CouponRefundFee int `json:"coupon_refund_fee,omitempty" xml:"coupon_refund_fee,omitempty"` // 代金券退款总金额 + SettlementRefundFee int `json:"settlement_refund_fee,omitempty" xml:"settlement_refund_fee,omitempty"` // 退款金额 + CouponType string `json:"coupon_type,omitempty" xml:"coupon_type,omitempty"` // 代金券类型 + CouponRefundCount int `json:"coupon_refund_count,omitempty" xml:"coupon_refund_count,omitempty"` // 退款代金券使用数量 + CouponRefundId string `json:"coupon_refund_id,omitempty" xml:"coupon_refund_id,omitempty"` // 退款代金券ID + RefundStatus string `json:"refund_status,omitempty" xml:"refund_status,omitempty"` // 退款状态 + RefundAccount string `json:"refund_account,omitempty" xml:"refund_account,omitempty"` // 退款资金来源 + RefundRecvAccout string `json:"refund_recv_accout,omitempty" xml:"refund_recv_accout,omitempty"` // 退款入账账户 + RefundSuccessTime string `json:"refund_success_time,omitempty" xml:"refund_success_time,omitempty"` // 退款成功时间 + CashRefundFee int `json:"cash_refund_fee,omitempty" xml:"cash_refund_fee,omitempty"` // 用户退款金额 +} + +type PayRefundQueryResult struct { + Result PayRefundQueryResponse // 结果 + Body []byte // 内容 + Http gorequest.Response // 请求 + Err error // 错误 +} + +func newPayRefundQueryResult(result PayRefundQueryResponse, body []byte, http gorequest.Response, err error) *PayRefundQueryResult { + return &PayRefundQueryResult{Result: result, Body: body, Http: http, Err: err} +} + +// PayRefundQuery +// 小程序支付 - 查询退款 +// https://pay.weixin.qq.com/wiki/doc/api/wxa/wxa_api.php?chapter=9_1 +func (c *Client) PayRefundQuery(ctx context.Context, notMustParams ...gorequest.Params) *PayRefundQueryResult { + // 参数 + params := gorequest.NewParamsWith(notMustParams...) + params.Set("appid", c.GetAppId()) // 小程序ID + params.Set("mch_id", c.GetMchId()) // 商户号 + params.Set("nonce_str", gorandom.Alphanumeric(32)) // 随机字符串 + // 签名 + params.Set("sign", c.getMd5Sign(params)) + // 请求 + request, err := c.request(ctx, apiUrl+"/pay/unifiedorder", params, false, nil) + // 定义 + var response PayRefundQueryResponse + err = xml.Unmarshal(request.ResponseBody, &response) + return newPayRefundQueryResult(response, request.ResponseBody, request, err) +} diff --git a/pay.unifiedorder.go b/pay.unifiedorder.go new file mode 100644 index 0000000..d352b9a --- /dev/null +++ b/pay.unifiedorder.go @@ -0,0 +1,57 @@ +package wechatpayapiv2 + +import ( + "context" + "encoding/xml" + "go.dtapp.net/gorandom" + "go.dtapp.net/gorequest" +) + +type PayUnifiedOrderResponse struct { + ReturnCode string `json:"return_code" xml:"return_code"` // 返回状态码 + ReturnMsg string `json:"return_msg,omitempty" xml:"return_msg,omitempty"` // 返回信息 + + ResultCode string `json:"result_code,omitempty" xml:"result_code,omitempty"` // 业务结果 + ErrCode string `json:"err_code,omitempty" xml:"err_code,omitempty"` // 错误代码 + ErrCodeDes string `json:"err_code_des,omitempty" xml:"err_code_des,omitempty"` // 错误代码描述 + + Appid string `json:"appid,omitempty" xml:"appid,omitempty"` // 小程序ID + MchId string `json:"mch_id,omitempty" xml:"mch_id,omitempty"` // 商户号 + DeviceInfo string `json:"device_info,omitempty" xml:"device_info,omitempty"` // 设备号 + NonceStr string `json:"nonce_str,omitempty" xml:"nonce_str,omitempty"` // 随机字符串 + Sign string `json:"sign,omitempty" xml:"sign,omitempty"` // 签名 + + TradeType string `json:"trade_type,omitempty" xml:"trade_type,omitempty"` // 交易类型 + PrepayId string `json:"prepay_id,omitempty" xml:"prepay_id,omitempty"` // 预支付交易会话标识 + CodeUrl string `json:"code_url,omitempty" xml:"code_url,omitempty"` // 二维码链接 +} + +type PayUnifiedOrderResult struct { + Result PayUnifiedOrderResponse // 结果 + Body []byte // 内容 + Http gorequest.Response // 请求 + Err error // 错误 +} + +func newPayUnifiedOrderResult(result PayUnifiedOrderResponse, body []byte, http gorequest.Response, err error) *PayUnifiedOrderResult { + return &PayUnifiedOrderResult{Result: result, Body: body, Http: http, Err: err} +} + +// PayUnifiedOrder +// 小程序支付 - 统一下单 +// https://pay.weixin.qq.com/wiki/doc/api/wxa/wxa_api.php?chapter=9_1 +func (c *Client) PayUnifiedOrder(ctx context.Context, notMustParams ...gorequest.Params) *PayUnifiedOrderResult { + // 参数 + params := gorequest.NewParamsWith(notMustParams...) + params.Set("appid", c.GetAppId()) // 小程序ID + params.Set("mch_id", c.GetMchId()) // 商户号 + params.Set("nonce_str", gorandom.Alphanumeric(32)) // 随机字符串 + // 签名 + params.Set("sign", c.getMd5Sign(params)) + // 请求 + request, err := c.request(ctx, apiUrl+"/pay/unifiedorder", params, false, nil) + // 定义 + var response PayUnifiedOrderResponse + err = xml.Unmarshal(request.ResponseBody, &response) + return newPayUnifiedOrderResult(response, request.ResponseBody, request, err) +} diff --git a/pay.unifiedorder.notify.gin.go b/pay.unifiedorder.notify.gin.go new file mode 100644 index 0000000..49e3825 --- /dev/null +++ b/pay.unifiedorder.notify.gin.go @@ -0,0 +1,48 @@ +package wechatpayapiv2 + +import ( + "context" + "github.com/gin-gonic/gin" +) + +// PayUnifiedOrderNotifyGinRequest 小程序支付 - 统一下单 - 回调通知 - 请求参数 +type PayUnifiedOrderNotifyGinRequest struct { + ReturnCode string `form:"return_code" json:"return_code" xml:"return_code" uri:"return_code" binding:"required"` // 返回状态码 + ReturnMsg string `form:"return_msg" json:"return_msg" xml:"return_msg" uri:"return_msg" binding:"omitempty"` // 返回信息 + Appid string `form:"appid" json:"appid" xml:"appid" uri:"appid" binding:"omitempty"` // 小程序ID + MchId string `form:"mch_id" json:"mch_id" xml:"mch_id" uri:"mch_id" binding:"omitempty"` // 商户号 + DeviceInfo string `form:"device_info" json:"device_info" xml:"device_info" uri:"device_info" binding:"omitempty"` // 设备号 + NonceStr string `form:"nonce_str" json:"nonce_str" xml:"nonce_str" uri:"nonce_str" binding:"omitempty"` // 随机字符串 + Sign string `form:"sign" json:"sign" xml:"sign" uri:"sign" binding:"omitempty"` // 签名 + SignType string `form:"sign_type" json:"sign_type" xml:"sign_type" uri:"sign_type" binding:"omitempty"` // 签名类型 + ResultCode string `form:"result_code" json:"result_code" xml:"result_code" uri:"result_code" binding:"omitempty"` // 业务结果 + ErrCode string `form:"err_code" json:"err_code" xml:"err_code" uri:"err_code" binding:"omitempty"` // 错误代码 + ErrCodeDes string `form:"err_code_des" json:"err_code_des" xml:"err_code_des" uri:"err_code_des" binding:"omitempty"` // 错误代码描述 + Openid string `form:"openid" json:"openid" xml:"openid" uri:"openid" binding:"omitempty"` // 用户标识 + IsSubscribe string `form:"is_subscribe" json:"is_subscribe" xml:"is_subscribe" uri:"is_subscribe" binding:"omitempty"` // 是否关注公众账号 + TradeType string `form:"trade_type" json:"trade_type" xml:"trade_type" uri:"trade_type" binding:"omitempty"` // 交易类型 + BankType string `form:"bank_type" json:"bank_type" xml:"bank_type" uri:"bank_type" binding:"omitempty"` // 付款银行 + TotalFee int `form:"total_fee" json:"total_fee" xml:"total_fee" uri:"total_fee" binding:"omitempty"` // 订单金额 + SettlementTotalFee int `form:"settlement_total_fee" json:"settlement_total_fee" xml:"settlement_total_fee" uri:"settlement_total_fee" binding:"omitempty"` // 应结订单金额 + FeeType string `form:"fee_type" json:"fee_type" xml:"fee_type" uri:"fee_type" binding:"omitempty"` // 货币种类 + CashFee int `form:"cash_fee" json:"cash_fee" xml:"cash_fee" uri:"cash_fee" binding:"omitempty"` // 现金支付金额 + CashFeeType string `form:"cash_fee_type" json:"cash_fee_type" xml:"cash_fee_type" uri:"cash_fee_type" binding:"omitempty"` // 现金支付货币类型 + CouponFee string `form:"coupon_fee" json:"coupon_fee" xml:"coupon_fee" uri:"coupon_fee" binding:"omitempty"` // 总代金券金额 + CouponCount int `form:"coupon_count" json:"coupon_count" xml:"coupon_count" uri:"coupon_count" binding:"omitempty"` // 代金券使用数量 + CouponType string `form:"coupon_type" json:"coupon_type" xml:"coupon_type" uri:"coupon_type" binding:"omitempty"` // 代金券类型 + CouponId string `form:"coupon_id" json:"coupon_id" xml:"coupon_id" uri:"coupon_id" binding:"omitempty"` // 代金券ID + TransactionId string `form:"transaction_id" json:"transaction_id" xml:"transaction_id" uri:"transaction_id" binding:"omitempty"` // 微信支付订单号 + OutTradeNo string `form:"out_trade_no" json:"out_trade_no" xml:"out_trade_no" uri:"out_trade_no" binding:"omitempty"` // 商户订单号 + Attach string `form:"attach" json:"attach" xml:"attach" uri:"attach" binding:"omitempty"` // 商家数据包 + TimeEnd string `form:"time_end" json:"time_end" xml:"time_end" uri:"time_end" binding:"omitempty"` // 支付完成时间 +} + +// PayUnifiedOrderNotifyGin 小程序支付 - 统一下单 - 回调通知 +// https://pay.weixin.qq.com/wiki/doc/api/wxa/wxa_api.php?chapter=9_7&index=8 +func (c *Client) PayUnifiedOrderNotifyGin(ctx context.Context, ginCtx *gin.Context) (validateJson PayUnifiedOrderNotifyGinRequest, err error) { + + // 解析 + err = ginCtx.ShouldBind(&validateJson) + + return validateJson, err +} diff --git a/request.go b/request.go index 9d932d1..84c0280 100644 --- a/request.go +++ b/request.go @@ -6,7 +6,7 @@ import ( "go.dtapp.net/gorequest" ) -func (c *Client) request(ctx context.Context, url string, params map[string]interface{}, cert *tls.Certificate) (gorequest.Response, error) { +func (c *Client) request(ctx context.Context, url string, params map[string]interface{}, certStatus bool, cert *tls.Certificate) (gorequest.Response, error) { // 创建请求 client := c.requestClient @@ -21,7 +21,9 @@ func (c *Client) request(ctx context.Context, url string, params map[string]inte client.SetParams(params) // 设置证书 - client.SetP12Cert(cert) + if certStatus { + client.SetP12Cert(cert) + } // 发起请求 request, err := client.Post(ctx) diff --git a/secapi.pay.refund.go b/secapi.pay.refund.go new file mode 100644 index 0000000..b566796 --- /dev/null +++ b/secapi.pay.refund.go @@ -0,0 +1,73 @@ +package wechatpayapiv2 + +import ( + "context" + "encoding/xml" + "go.dtapp.net/gorandom" + "go.dtapp.net/gorequest" +) + +type SecApiPayRefundResponse struct { + ReturnCode string `json:"return_code" xml:"return_code"` // 返回状态码 + ReturnMsg string `json:"return_msg,omitempty" xml:"return_msg,omitempty"` // 返回信息 + + ResultCode string `json:"result_code,omitempty" xml:"result_code,omitempty"` // 业务结果 + ErrCode string `json:"err_code,omitempty" xml:"err_code,omitempty"` // 错误代码 + ErrCodeDes string `json:"err_code_des,omitempty" xml:"err_code_des,omitempty"` // 错误代码描述 + + Appid string `json:"appid,omitempty" xml:"appid,omitempty"` // 小程序ID + MchId string `json:"mch_id,omitempty" xml:"mch_id,omitempty"` // 商户号 + DeviceInfo string `json:"device_info,omitempty" xml:"device_info,omitempty"` // 设备号 + NonceStr string `json:"nonce_str,omitempty" xml:"nonce_str,omitempty"` // 随机字符串 + Sign string `json:"sign,omitempty" xml:"sign,omitempty"` // 签名 + + TotalRefundCount int `json:"total_refund_count,omitempty" xml:"total_refund_count,omitempty"` // 订单总退款次数 + TransactionId string `json:"transaction_id,omitempty" xml:"transaction_id,omitempty"` // 微信订单号 + OutTradeNo string `json:"out_trade_no,omitempty" xml:"out_trade_no,omitempty"` // 商户订单号 + OutRefundNo string `json:"out_refund_no,omitempty" xml:"out_refund_no,omitempty"` // 商户退款单号 + RefundId string `json:"refund_id,omitempty" xml:"refund_id,omitempty"` // 微信退款单号 + RefundFee int `json:"refund_fee,omitempty" xml:"refund_fee,omitempty"` // 退款金额 + SettlementRefundFee int `json:"settlement_refund_fee,omitempty" xml:"settlement_refund_fee,omitempty"` // 退款金额 + TotalFee int `json:"total_fee,omitempty" xml:"total_fee,omitempty"` // 标价金额 + SettlementTotalFee int `json:"settlement_total_fee,omitempty" xml:"settlement_total_fee,omitempty"` // 应结订单金额 + FeeType string `json:"fee_type,omitempty" xml:"fee_type,omitempty"` // 货币种类 + CashFee int `json:"cash_fee,omitempty" xml:"cash_fee,omitempty"` // 现金支付金额 + CashFeeType string `json:"cash_fee_type,omitempty" xml:"cash_fee_type,omitempty"` // 现金支付币种 + CashRefundFee int `json:"cash_refund_fee,omitempty" xml:"cash_refund_fee,omitempty"` // 现金退款金额 + CouponType string `json:"coupon_type,omitempty" xml:"coupon_type,omitempty"` // 代金券类型 + CouponRefundFee int `json:"coupon_refund_fee,omitempty" xml:"coupon_refund_fee,omitempty"` // 代金券退款总金额 + CouponRefundCount int `json:"coupon_refund_count,omitempty" xml:"coupon_refund_count,omitempty"` // 退款代金券使用数量 + CouponRefundId string `json:"coupon_refund_id,omitempty" xml:"coupon_refund_id,omitempty"` // 退款代金券ID +} + +type SecApiPayRefundResult struct { + Result SecApiPayRefundResponse // 结果 + Body []byte // 内容 + Http gorequest.Response // 请求 + Err error // 错误 +} + +func newSecApiPayRefundResult(result SecApiPayRefundResponse, body []byte, http gorequest.Response, err error) *SecApiPayRefundResult { + return &SecApiPayRefundResult{Result: result, Body: body, Http: http, Err: err} +} + +// SecApiPayRefund +// 小程序支付 - 申请退款 +// 需要证书 +// https://pay.weixin.qq.com/wiki/doc/api/wxa/wxa_api.php?chapter=9_4 +func (c *Client) SecApiPayRefund(ctx context.Context, notMustParams ...gorequest.Params) *SecApiPayRefundResult { + cert, err := c.P12ToPem() + // 参数 + params := gorequest.NewParamsWith(notMustParams...) + params.Set("appid", c.GetAppId()) // 小程序ID + params.Set("mch_id", c.GetMchId()) // 商户号 + params.Set("nonce_str", gorandom.Alphanumeric(32)) // 随机字符串 + // 签名 + params.Set("sign", c.getMd5Sign(params)) + // 请求 + request, err := c.request(ctx, apiUrl+"/secapi/pay/refund", params, true, cert) + // 定义 + var response SecApiPayRefundResponse + err = xml.Unmarshal(request.ResponseBody, &response) + return newSecApiPayRefundResult(response, request.ResponseBody, request, err) +} diff --git a/secapi.pay.refund.notify.gin.go b/secapi.pay.refund.notify.gin.go new file mode 100644 index 0000000..23bd063 --- /dev/null +++ b/secapi.pay.refund.notify.gin.go @@ -0,0 +1,26 @@ +package wechatpayapiv2 + +import ( + "context" + "github.com/gin-gonic/gin" +) + +// SecApiPayRefundNotifyGinRequest 小程序支付 - 申请退款 - 回调通知 - 请求参数 +type SecApiPayRefundNotifyGinRequest struct { + ReturnCode string `form:"return_code" json:"return_code" xml:"return_code" uri:"return_code" binding:"required"` // 返回状态码 + ReturnMsg string `form:"return_msg" json:"return_msg" xml:"return_msg" uri:"return_msg" binding:"omitempty"` // 返回信息 + Appid string `form:"appid" json:"appid" xml:"appid" uri:"appid" binding:"omitempty"` // 公众账号ID + MchId string `form:"mch_id" json:"mch_id" xml:"mch_id" uri:"mch_id" binding:"omitempty"` // 退款的商户号 + NonceStr string `form:"nonce_str" json:"nonce_str" xml:"nonce_str" uri:"nonce_str" binding:"omitempty"` // 随机字符串 + ReqInfo string `form:"req_info" json:"req_info" xml:"req_info" uri:"req_info" binding:"omitempty"` // 加密信息 +} + +// SecApiPayRefundNotifyGin 小程序支付 - 申请退款 - 回调通知 +// https://pay.weixin.qq.com/wiki/doc/api/wxa/wxa_api.php?chapter=9_16&index=10 +func (c *Client) SecApiPayRefundNotifyGin(ctx context.Context, ginCtx *gin.Context) (validateJson SecApiPayRefundNotifyGinRequest, err error) { + + // 解析 + err = ginCtx.ShouldBind(&validateJson) + + return validateJson, err +}