diff --git a/api/index.go b/api/index.go index 35e83f3..f83b044 100644 --- a/api/index.go +++ b/api/index.go @@ -43,6 +43,7 @@ func Pay(c *gin.Context) (utils.Data, error) { param.OutTradeNo = order.OrderNo param.TotalAmount = strconv.FormatFloat(order.PayAmount, 'E', -1, 64) param.Subject = order.Subject + // global.Config.Server.Domain param.NotifyURL = global.Config.Server.Domain + "/notify" param.ReturnURL = global.Config.Server.Domain + "/return" client, err := alipay.New(global.Config.Alipay.AppId, global.Config.Alipay.PrivateKey, true) @@ -56,11 +57,12 @@ func Pay(c *gin.Context) (utils.Data, error) { fmt.Println(result.String()) order.PayUrl = result.String() - order.Token = utils.Md5(order.OrderNo + strconv.Itoa(order.UserId) + strconv.FormatInt(time.Now().Unix(), 10)) + // utils.Md5(order.OrderNo + strconv.Itoa(order.UserId) + strconv.FormatInt(time.Now().Unix(), 10)) + order.Token = order.OrderNo global.DB.Save(order) data := utils.Data{ - "pay_url": global.Config.Server.Domain + "/payment/" + order.Token + "pay_url": global.Config.Server.Domain + "/payment/" + order.OrderNo, } return data, nil } diff --git a/config.yaml b/config.yaml index 19f7ddf..b227f12 100644 --- a/config.yaml +++ b/config.yaml @@ -1,9 +1,9 @@ server: port: 9090 - domain: "" + domain: "http://pay.hexidongkeji.top" alipay: - app-id: "2021003176607480" - private-key: "MIIEpAIBAAKCAQEApYCmDarjoizjH++KYs0QztdXSnBMSAKwPbCI98ma/soren7rBBEqSS7E6pHxGAoH9FgjugaYJQLT5D+a/qwko7E/swf59RZM7VjbAfQVaSPPPnl2rRzVC8hAVGsTXRZB3dgeZlXgS4QecjxtiqoejtLf8ipXJHGbwu3avvIJ9FnF6BwoZrbiS7OeijuNmiu0kjRecCq28tRMsVZL/d1eYKV38GiWEsIKl533JkdAOTkec/4hmBeyZRCBzwAwHwvEZmXEf82i9vlLlSD6A2LMkKYWOlI+3CVZ52YcYWmgyad5FA61fHt9mqqtkC71Aot0uzHCwaeljpp5tgjx/j7xfQIDAQABAoIBAA7AHYygS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/smlS/hfIvknZZKQoYYRgiB60f2t6aDJOzjUMCIgClWpQztDzbKonKx1ykCmiSgtUJF9MVP4iz5cJKc0wdnjO20DxFJGMHl89ejlfrfmM5D1E0d2l7kpO6M/66mjNT7fGtAdorAw8OzKbZh/KCfsq9cCgYEApWEL95ILtP5eyHQI//f+L/1U+7oh2pdyDc1FBTe6bx1UOOtV3zJWltFE6Fgwl5qUFf+9QPNnysSsgwjTo5tGxMS6W8Xt4+XH3KVazrJaMaFUthln0YQwiU0xWkPZT1grlEoyo5c5iKNh7UrB0PEWBzOXzLRW15oQ4R0oUF3A48UCgYARV4Nm/JpwUCH/wBR+PNQLdgHRVuI3SbuXfZEfRQSjfebcJJKHnNBOOqmfC2v0E1gF+M4OJ1NF6w5iueJYEdxtjdx6yhONvDLABrJ8kj3vGhHm+9lyDAcW46Zhl/VKvI4pkhfLhD6KVrJwVyo8lRiKSdLSRBY06WSPNsvuYAvieQKBgQDk52HC2XLdui/wMnESIJ/+qwuKh/BAC7e/jEuZpQxRFVbE8L2m638f+tkXdHlMERqaROd2h31cPpvZzOyeJBvhUEmuQcBfq+G4YsRQIH0XDvx/nBO4m03nFOXyLkFx4X1fZs/0i3CO506WHdgkM5wd8nA6+9S4DdNAjHvoC4WQ3A==" database: host: "47.98.244.18" port: "3306" diff --git a/go.mod b/go.mod index b2d67a8..d95f1f2 100644 --- a/go.mod +++ b/go.mod @@ -2,13 +2,20 @@ module jypay go 1.21.1 +require ( + github.com/gin-gonic/gin v1.9.1 + github.com/smartwalle/alipay/v3 v3.2.20 + gopkg.in/yaml.v3 v3.0.1 + gorm.io/driver/mysql v1.5.2 + gorm.io/gorm v1.25.5 +) + require ( github.com/bytedance/sonic v1.10.2 // indirect github.com/chenzhuoyu/base64x v0.0.0-20230717121745-296ad89f973d // indirect github.com/chenzhuoyu/iasm v0.9.1 // indirect github.com/gabriel-vasile/mimetype v1.4.3 // indirect github.com/gin-contrib/sse v0.1.0 // indirect - github.com/gin-gonic/gin v1.9.1 // indirect github.com/go-playground/locales v0.14.1 // indirect github.com/go-playground/universal-translator v0.18.1 // indirect github.com/go-playground/validator/v10 v10.16.0 // indirect @@ -23,7 +30,6 @@ require ( github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect github.com/pelletier/go-toml/v2 v2.1.0 // indirect - github.com/smartwalle/alipay/v3 v3.2.20 // indirect github.com/smartwalle/ncrypto v1.0.4 // indirect github.com/smartwalle/ngx v1.0.9 // indirect github.com/smartwalle/nsign v1.0.9 // indirect @@ -35,8 +41,4 @@ require ( golang.org/x/sys v0.15.0 // indirect golang.org/x/text v0.14.0 // indirect google.golang.org/protobuf v1.31.0 // indirect - gopkg.in/yaml.v2 v2.4.0 // indirect - gopkg.in/yaml.v3 v3.0.1 // indirect - gorm.io/driver/mysql v1.5.2 // indirect - gorm.io/gorm v1.25.5 // indirect ) diff --git a/go.sum b/go.sum index 342a826..761ce3d 100644 --- a/go.sum +++ b/go.sum @@ -10,6 +10,7 @@ github.com/chenzhuoyu/iasm v0.9.0/go.mod h1:Xjy2NpN3h7aUqeqM+woSuuvxmIe6+DDsiNLI github.com/chenzhuoyu/iasm v0.9.1 h1:tUHQJXo3NhBqw6s33wkGn9SP3bvrWLdlVIJ3hQBL7P0= github.com/chenzhuoyu/iasm v0.9.1/go.mod h1:Xjy2NpN3h7aUqeqM+woSuuvxmIe6+DDsiNLIrkAmYog= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +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/gabriel-vasile/mimetype v1.4.3 h1:in2uUcidCuFcDKtdcBxlR0rJ1+fsokWf+uqxgUFjbI0= github.com/gabriel-vasile/mimetype v1.4.3/go.mod h1:d8uq/6HKRL6CGdk+aubisF/M5GcPfT7nKyLpA0lbSSk= @@ -17,6 +18,8 @@ github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= github.com/gin-gonic/gin v1.9.1 h1:4idEAncQnU5cB7BeOkPtxjfCSye0AAm1R0RVIqJ+Jmg= github.com/gin-gonic/gin v1.9.1/go.mod h1:hPrL7YrpYKXt5YId3A/Tnip5kqbEAP+KLuI3SUcPTeU= +github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s= +github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA= github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY= github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY= @@ -28,6 +31,7 @@ github.com/go-sql-driver/mysql v1.7.0/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9 github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU= github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= +github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E= @@ -51,6 +55,7 @@ github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9G github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= github.com/pelletier/go-toml/v2 v2.1.0 h1:FnwAJ4oYMvbT/34k9zzHuZNrhlz48GB3/s6at6/MHO4= github.com/pelletier/go-toml/v2 v2.1.0/go.mod h1:tJU2Z3ZkXwnxa4DPO899bsyIoywizdUvyaeZurnPPDc= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/smartwalle/alipay/v3 v3.2.20 h1:IjpG3YYgUgzCfS0z/EHlUbbr0OlrmOBHUst/3FzToYE= github.com/smartwalle/alipay/v3 v3.2.20/go.mod h1:KWg91KsY+eIOf26ZfZeH7bed1bWulGpGrL1ErHF3jWo= @@ -69,6 +74,7 @@ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI= github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08= @@ -87,13 +93,13 @@ golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc= golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8= google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= -gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/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= diff --git a/main b/main new file mode 100644 index 0000000..6791332 Binary files /dev/null and b/main differ diff --git a/main.go b/main.go index 2cf7a91..e9accf1 100644 --- a/main.go +++ b/main.go @@ -21,6 +21,6 @@ func main() { r.POST("/notify", utils.BuildHandler(api.Notify)) r.GET("/return/:order_no", utils.BuildHandler(api.Return)) r.GET("/test-post", utils.BuildJsonHandler(api.TestPost)) - err := r.Run() // listen and serve on 0.0.0.0:8080 + err := r.Run(":" + global.Config.Server.Port) // listen and serve on 0.0.0.0:8080 panic(err) }