直连天下,直充,卡密 notify
This commit is contained in:
parent
31e0dfa1a0
commit
2b6c021758
|
@ -3,7 +3,7 @@ module plugins/zltx_card_v1
|
||||||
go 1.22.2
|
go 1.22.2
|
||||||
|
|
||||||
require (
|
require (
|
||||||
gitea.cdlsxd.cn/sdk/plugin v1.0.9
|
gitea.cdlsxd.cn/sdk/plugin v1.0.10
|
||||||
github.com/carlmjohnson/requests v0.24.2
|
github.com/carlmjohnson/requests v0.24.2
|
||||||
github.com/go-playground/validator/v10 v10.22.0
|
github.com/go-playground/validator/v10 v10.22.0
|
||||||
github.com/hashicorp/go-plugin v1.6.1
|
github.com/hashicorp/go-plugin v1.6.1
|
||||||
|
|
|
@ -8,6 +8,8 @@ gitea.cdlsxd.cn/sdk/plugin v1.0.8 h1:86A+qENcBLZpFUO/ZDjj0onwU0VAmQVD410pUSd0mHI
|
||||||
gitea.cdlsxd.cn/sdk/plugin v1.0.8/go.mod h1:FLuWLP2QP2aBzI2HCdZ7tvl1ieMuMOpTWvItmNGCeGA=
|
gitea.cdlsxd.cn/sdk/plugin v1.0.8/go.mod h1:FLuWLP2QP2aBzI2HCdZ7tvl1ieMuMOpTWvItmNGCeGA=
|
||||||
gitea.cdlsxd.cn/sdk/plugin v1.0.9 h1:kwbYURARlW+30Qu+6Hw4q8Dqikj9/n5crpIZn3yFRwk=
|
gitea.cdlsxd.cn/sdk/plugin v1.0.9 h1:kwbYURARlW+30Qu+6Hw4q8Dqikj9/n5crpIZn3yFRwk=
|
||||||
gitea.cdlsxd.cn/sdk/plugin v1.0.9/go.mod h1:FLuWLP2QP2aBzI2HCdZ7tvl1ieMuMOpTWvItmNGCeGA=
|
gitea.cdlsxd.cn/sdk/plugin v1.0.9/go.mod h1:FLuWLP2QP2aBzI2HCdZ7tvl1ieMuMOpTWvItmNGCeGA=
|
||||||
|
gitea.cdlsxd.cn/sdk/plugin v1.0.10 h1:l+8/Lwp2uPsjPu+iGRI1t4d86dNljuMLrACz6Pg29o0=
|
||||||
|
gitea.cdlsxd.cn/sdk/plugin v1.0.10/go.mod h1:FLuWLP2QP2aBzI2HCdZ7tvl1ieMuMOpTWvItmNGCeGA=
|
||||||
github.com/bufbuild/protocompile v0.4.0 h1:LbFKd2XowZvQ/kajzguUp2DC9UEIQhIq77fZZlaQsNA=
|
github.com/bufbuild/protocompile v0.4.0 h1:LbFKd2XowZvQ/kajzguUp2DC9UEIQhIq77fZZlaQsNA=
|
||||||
github.com/bufbuild/protocompile v0.4.0/go.mod h1:3v93+mbWn/v3xzN+31nwkJfrEpAUwp+BagBSZWx+TP8=
|
github.com/bufbuild/protocompile v0.4.0/go.mod h1:3v93+mbWn/v3xzN+31nwkJfrEpAUwp+BagBSZWx+TP8=
|
||||||
github.com/carlmjohnson/requests v0.24.2 h1:JDakhAmTIKL/qL/1P7Kkc2INGBJIkIFP6xUeUmPzLso=
|
github.com/carlmjohnson/requests v0.24.2 h1:JDakhAmTIKL/qL/1P7Kkc2INGBJIkIFP6xUeUmPzLso=
|
||||||
|
|
|
@ -81,7 +81,7 @@ func orderResp(request *proto.OrderRequest, resp *card.OrderResp) *proto.OrderRe
|
||||||
|
|
||||||
func (c *Config) queryReq(in *proto.QueryRequest) *card.Query {
|
func (c *Config) queryReq(in *proto.QueryRequest) *card.Query {
|
||||||
return &card.Query{
|
return &card.Query{
|
||||||
MerchantId: c.AppId,
|
MerchantId: c.MerchantId,
|
||||||
OutTradeNo: in.Order.OrderNo,
|
OutTradeNo: in.Order.OrderNo,
|
||||||
Version: "1.0",
|
Version: "1.0",
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@ func config() []byte {
|
||||||
AppKey: "1e2bf7a04b8b1e6be5dc78d04e8639c9",
|
AppKey: "1e2bf7a04b8b1e6be5dc78d04e8639c9",
|
||||||
BaseUri: "http://test.openapi.1688sup.cn",
|
BaseUri: "http://test.openapi.1688sup.cn",
|
||||||
NotifyUrl: "https://gateway.dev.cdlsxd.cn/yxh5api/v1/order/direct/notify",
|
NotifyUrl: "https://gateway.dev.cdlsxd.cn/yxh5api/v1/order/direct/notify",
|
||||||
MerchantId: "25537",
|
MerchantId: "23329",
|
||||||
}
|
}
|
||||||
marshal, _ := json.Marshal(c)
|
marshal, _ := json.Marshal(c)
|
||||||
return marshal
|
return marshal
|
||||||
|
@ -35,13 +35,13 @@ func TestOrder(t *testing.T) {
|
||||||
request := &proto.OrderRequest{
|
request := &proto.OrderRequest{
|
||||||
Config: config(),
|
Config: config(),
|
||||||
Order: &proto.OrderRequest_Order{
|
Order: &proto.OrderRequest_Order{
|
||||||
OrderNo: "test_zltx_v1_direct_2",
|
OrderNo: "test_plugin_zltx_v1_card_2",
|
||||||
Account: "18666666666",
|
Account: "",
|
||||||
Quantity: 1,
|
Quantity: 1,
|
||||||
Extra: nil,
|
Extra: nil,
|
||||||
},
|
},
|
||||||
Product: &proto.OrderRequest_Product{
|
Product: &proto.OrderRequest_Product{
|
||||||
ProductNo: "101",
|
ProductNo: "222",
|
||||||
Extra: []byte(`{}`),
|
Extra: []byte(`{}`),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -61,7 +61,7 @@ func TestQuery(t *testing.T) {
|
||||||
request := &proto.QueryRequest{
|
request := &proto.QueryRequest{
|
||||||
Config: config(),
|
Config: config(),
|
||||||
Order: &proto.QueryRequest_Order{
|
Order: &proto.QueryRequest_Order{
|
||||||
OrderNo: "test_zltx_v1_direct_1",
|
OrderNo: "test_plugin_zltx_v1_card_2",
|
||||||
TradeNo: "",
|
TradeNo: "",
|
||||||
Account: "",
|
Account: "",
|
||||||
Extra: nil,
|
Extra: nil,
|
||||||
|
@ -82,8 +82,8 @@ func TestNotify(t *testing.T) {
|
||||||
in := &proto.NotifyRequest{
|
in := &proto.NotifyRequest{
|
||||||
Config: config(),
|
Config: config(),
|
||||||
Queries: nil,
|
Queries: nil,
|
||||||
Headers: []byte(`{"Content-Type":["application/json"],"Authorization":["MD5 appid=101,sign=292e21f3683219369cf68dede0d45730"]`),
|
Headers: []byte(`{"Accept-Encoding":["gzip, deflate, br"],"Authorization":["MD5 appid=1,sign=B6FB2AA068866CEFE88B864CA9055BC6"],"Connection":["close"],"Content-Length":["116"],"Content-Type":["application/json"],"Cookie":[""],"User-Agent":["GuzzleHttp/6.5.5 curl/7.69.1 PHP/7.2.34"],"X-Remoteaddr":["172.21.0.1"]}`),
|
||||||
Body: []byte(`{"merchantId":23329,"outTradeNo":"202409111714224026320002","rechargeAccount":"18512869479","sign":"474ACB521DEE99551153B6CE108FD06D","status":"01"}`),
|
Body: []byte(`{"merchantId":"23329","outTradeNo":"test_plugin_zltx_v1_card_2","status":"01","cardCode":"iCtn0Lix8y/+cEwVayEOPg=="}`),
|
||||||
}
|
}
|
||||||
t.Run("TestNotify", func(t *testing.T) {
|
t.Run("TestNotify", func(t *testing.T) {
|
||||||
got, err := zltx.Notify(context.Background(), in)
|
got, err := zltx.Notify(context.Background(), in)
|
||||||
|
|
|
@ -3,7 +3,7 @@ module plugins/zltx_v1
|
||||||
go 1.22.2
|
go 1.22.2
|
||||||
|
|
||||||
require (
|
require (
|
||||||
gitea.cdlsxd.cn/sdk/plugin v1.0.9
|
gitea.cdlsxd.cn/sdk/plugin v1.0.10
|
||||||
github.com/go-playground/validator/v10 v10.22.0
|
github.com/go-playground/validator/v10 v10.22.0
|
||||||
github.com/hashicorp/go-plugin v1.6.1
|
github.com/hashicorp/go-plugin v1.6.1
|
||||||
github.com/stretchr/testify v1.9.0
|
github.com/stretchr/testify v1.9.0
|
||||||
|
|
|
@ -4,6 +4,8 @@ gitea.cdlsxd.cn/sdk/plugin v1.0.8 h1:86A+qENcBLZpFUO/ZDjj0onwU0VAmQVD410pUSd0mHI
|
||||||
gitea.cdlsxd.cn/sdk/plugin v1.0.8/go.mod h1:FLuWLP2QP2aBzI2HCdZ7tvl1ieMuMOpTWvItmNGCeGA=
|
gitea.cdlsxd.cn/sdk/plugin v1.0.8/go.mod h1:FLuWLP2QP2aBzI2HCdZ7tvl1ieMuMOpTWvItmNGCeGA=
|
||||||
gitea.cdlsxd.cn/sdk/plugin v1.0.9 h1:kwbYURARlW+30Qu+6Hw4q8Dqikj9/n5crpIZn3yFRwk=
|
gitea.cdlsxd.cn/sdk/plugin v1.0.9 h1:kwbYURARlW+30Qu+6Hw4q8Dqikj9/n5crpIZn3yFRwk=
|
||||||
gitea.cdlsxd.cn/sdk/plugin v1.0.9/go.mod h1:FLuWLP2QP2aBzI2HCdZ7tvl1ieMuMOpTWvItmNGCeGA=
|
gitea.cdlsxd.cn/sdk/plugin v1.0.9/go.mod h1:FLuWLP2QP2aBzI2HCdZ7tvl1ieMuMOpTWvItmNGCeGA=
|
||||||
|
gitea.cdlsxd.cn/sdk/plugin v1.0.10 h1:l+8/Lwp2uPsjPu+iGRI1t4d86dNljuMLrACz6Pg29o0=
|
||||||
|
gitea.cdlsxd.cn/sdk/plugin v1.0.10/go.mod h1:FLuWLP2QP2aBzI2HCdZ7tvl1ieMuMOpTWvItmNGCeGA=
|
||||||
github.com/bufbuild/protocompile v0.4.0 h1:LbFKd2XowZvQ/kajzguUp2DC9UEIQhIq77fZZlaQsNA=
|
github.com/bufbuild/protocompile v0.4.0 h1:LbFKd2XowZvQ/kajzguUp2DC9UEIQhIq77fZZlaQsNA=
|
||||||
github.com/bufbuild/protocompile v0.4.0/go.mod h1:3v93+mbWn/v3xzN+31nwkJfrEpAUwp+BagBSZWx+TP8=
|
github.com/bufbuild/protocompile v0.4.0/go.mod h1:3v93+mbWn/v3xzN+31nwkJfrEpAUwp+BagBSZWx+TP8=
|
||||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||||
|
|
|
@ -82,8 +82,8 @@ func TestNotify(t *testing.T) {
|
||||||
in := &proto.NotifyRequest{
|
in := &proto.NotifyRequest{
|
||||||
Config: config(),
|
Config: config(),
|
||||||
Queries: nil,
|
Queries: nil,
|
||||||
Headers: []byte(`{"Content-Type":["application/json"],"Authorization":["MD5 appid=101,sign=292e21f3683219369cf68dede0d45730"]`),
|
Headers: []byte(`{"Accept-Encoding":["gzip, deflate, br"],"Authorization":["MD5 appid=1,sign=642F82644ABB88E73C04F7881B93E6FA"],"Connection":["close"],"Content-Length":["102"],"Content-Type":["application/json"],"Cookie":[""],"User-Agent":["GuzzleHttp/6.5.5 curl/7.69.1 PHP/7.2.34"],"X-Remoteaddr":["172.21.0.1"]}`),
|
||||||
Body: []byte(`{"merchantId":23329,"outTradeNo":"202409111714224026320002","rechargeAccount":"18512869479","sign":"474ACB521DEE99551153B6CE108FD06D","status":"01"}`),
|
Body: []byte(`{"merchantId":"25537","outTradeNo":"test_zltx_direct_2","status":"03","rechargeAccount":"18666666666"}`),
|
||||||
}
|
}
|
||||||
t.Run("TestNotify", func(t *testing.T) {
|
t.Run("TestNotify", func(t *testing.T) {
|
||||||
got, err := zltx.Notify(context.Background(), in)
|
got, err := zltx.Notify(context.Background(), in)
|
||||||
|
@ -91,7 +91,7 @@ func TestNotify(t *testing.T) {
|
||||||
t.Errorf("Notify() error = %v", err)
|
t.Errorf("Notify() error = %v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
fmt.Printf("%s \n", got.String())
|
fmt.Printf("%+v\n", got)
|
||||||
assert.Equal(t, int(proto.Status_SUCCESS), int(got.Result.Status))
|
assert.Equal(t, int(proto.Status_SUCCESS), int(got.Result.Status))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue