mirror of
https://github.com/kongyuebin1/dongfeng-pay.git
synced 2025-10-16 10:08:00 +08:00
修改网关代码的结构,调整了逻辑,删除了许多无用的代码
This commit is contained in:
43
gateway/tests/pay_for_test.go
Normal file
43
gateway/tests/pay_for_test.go
Normal file
@@ -0,0 +1,43 @@
|
||||
package test
|
||||
|
||||
import (
|
||||
"gateway/conf"
|
||||
_ "gateway/message"
|
||||
_ "gateway/models"
|
||||
"gateway/models/payfor"
|
||||
"gateway/pay_for"
|
||||
"gateway/utils"
|
||||
"github.com/beego/beego/v2/core/logs"
|
||||
"github.com/rs/xid"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestAutoPayFor(t *testing.T) {
|
||||
params := make(map[string]string)
|
||||
|
||||
params["merchantKey"] = "kkkkc254gk8isf001cqrj6p0"
|
||||
params["realname"] = "孔跃彬"
|
||||
params["cardNo"] = "6214830200383973"
|
||||
params["accType"] = "0"
|
||||
params["amount"] = "100"
|
||||
paySecret := "ssssc254gk8isf001cqrj6pg"
|
||||
params["merchantOrderId"] = xid.New().String()
|
||||
keys := utils.SortMap(params)
|
||||
params["sign"] = utils.GetMD5Sign(params, keys, paySecret)
|
||||
payFor := pay_for.AutoPayFor(params, conf.SELF_API)
|
||||
logs.Info(payFor)
|
||||
}
|
||||
|
||||
func TestPayForFail(t *testing.T) {
|
||||
p := new(payfor.PayforInfo)
|
||||
p.BankOrderId = "4444c4vlk3u7mathho2o8md0"
|
||||
res := pay_for.PayForFail(*p)
|
||||
logs.Info(res)
|
||||
}
|
||||
|
||||
func TestPayForSuccess(t *testing.T) {
|
||||
p := new(payfor.PayforInfo)
|
||||
p.BankOrderId = "4444c4vlk3u7mathho2o8md0"
|
||||
res := pay_for.PayForSuccess(*p)
|
||||
logs.Info(res)
|
||||
}
|
63
gateway/tests/pay_test.go
Normal file
63
gateway/tests/pay_test.go
Normal file
@@ -0,0 +1,63 @@
|
||||
package test
|
||||
|
||||
import (
|
||||
_ "gateway/message"
|
||||
_ "gateway/models"
|
||||
"gateway/service"
|
||||
"gateway/utils"
|
||||
"github.com/astaxie/beego/httplib"
|
||||
"github.com/astaxie/beego/logs"
|
||||
"github.com/rs/xid"
|
||||
"net/url"
|
||||
"testing"
|
||||
)
|
||||
import _ "gateway/routers"
|
||||
|
||||
/*
|
||||
** 充值测试
|
||||
*/
|
||||
func TestPay(t *testing.T) {
|
||||
params := make(map[string]string)
|
||||
params["orderNo"] = xid.New().String()
|
||||
params["productName"] = "kongyuhebin"
|
||||
params["orderPeriod"] = "1"
|
||||
params["orderPrice"] = "100.00"
|
||||
params["payWayCode"] = "WEIXIN_SCAN"
|
||||
params["osType"] = "1"
|
||||
params["notifyUrl"] = "http://localhost:12309/shop/notify"
|
||||
params["payKey"] = "kkkkc254gk8isf001cqrj6p0"
|
||||
keys := utils.SortMap(params)
|
||||
params["sign"] = utils.GetMD5Sign(params, keys, "ssssc254gk8isf001cqrj6pg")
|
||||
|
||||
u := url.Values{}
|
||||
for k, v := range params {
|
||||
u.Add(k, v)
|
||||
}
|
||||
|
||||
l := "http://localhost:12309/gateway/scan?" + u.Encode()
|
||||
logs.Info("请求url:" + l)
|
||||
|
||||
resp := httplib.Get(l)
|
||||
s, err := resp.String()
|
||||
|
||||
if err != nil {
|
||||
logs.Error("请求错误:" + err.Error())
|
||||
|
||||
}
|
||||
|
||||
logs.Info("微信扫码返回结果:" + s)
|
||||
}
|
||||
|
||||
/**
|
||||
** 充值失败回调
|
||||
*/
|
||||
func TestPayFail(t *testing.T) {
|
||||
service.SolvePayFail("6666c50bd567matj5v6g30dg", "")
|
||||
}
|
||||
|
||||
/**
|
||||
** 充值成功
|
||||
*/
|
||||
func TestPaySuccess(t *testing.T) {
|
||||
service.SolvePaySuccess("6666c50mhcu7matjtv0a4330", 0, "")
|
||||
}
|
Reference in New Issue
Block a user