merchant id int64

This commit is contained in:
李子铭 2024-11-19 14:12:20 +08:00
parent 0c674a9557
commit 96b7fa817b
10 changed files with 16 additions and 16 deletions

View File

@ -3,7 +3,7 @@ module plugins/zltx_card_v1
go 1.22.2
require (
gitea.cdlsxd.cn/sdk/plugin v1.0.11
gitea.cdlsxd.cn/sdk/plugin v1.0.12
github.com/go-playground/validator/v10 v10.22.0
github.com/hashicorp/go-plugin v1.6.1
github.com/stretchr/testify v1.9.0

View File

@ -2,6 +2,8 @@ gitea.cdlsxd.cn/sdk/plugin v1.0.10 h1:l+8/Lwp2uPsjPu+iGRI1t4d86dNljuMLrACz6Pg29o
gitea.cdlsxd.cn/sdk/plugin v1.0.10/go.mod h1:FLuWLP2QP2aBzI2HCdZ7tvl1ieMuMOpTWvItmNGCeGA=
gitea.cdlsxd.cn/sdk/plugin v1.0.11 h1:NMMgw2p7ZF7EbWjkSO7ttM62BLhsG0bGmPdGGS1gpJc=
gitea.cdlsxd.cn/sdk/plugin v1.0.11/go.mod h1:FLuWLP2QP2aBzI2HCdZ7tvl1ieMuMOpTWvItmNGCeGA=
gitea.cdlsxd.cn/sdk/plugin v1.0.12 h1:gA7zRagOro38rbRVIfFgGRuGOr+Wig8EjeqQkYedFXc=
gitea.cdlsxd.cn/sdk/plugin v1.0.12/go.mod h1:FLuWLP2QP2aBzI2HCdZ7tvl1ieMuMOpTWvItmNGCeGA=
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/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=

View File

@ -14,7 +14,7 @@ type Config struct {
AppKey string `json:"app_key" validate:"required"`
BaseUri string `json:"base_uri" validate:"required"`
NotifyUrl string `json:"notify_url" validate:"required"`
MerchantId string `json:"merchant_id" validate:"required"`
MerchantId int64 `json:"merchant_id" validate:"required"`
}
func (c *Config) validate() error {

View File

@ -8,7 +8,6 @@ import (
"gitea.cdlsxd.cn/sdk/plugin/proto"
"io"
"net/http"
"strings"
)
// 插件通信信息,若不对应则会报错panic
@ -77,11 +76,10 @@ func (p *ZLTXCardV1Service) Notify(ctx context.Context, request *proto.NotifyReq
}
newHeaders := make(http.Header)
for key, values := range httpHeaders {
newKey := strings.ToTitle(strings.ToLower(key))
newHeaders[newKey] = values
newHeaders[key] = values
}
req := &http.Request{
httpRequest := &http.Request{
Header: newHeaders,
Body: io.NopCloser(bytes.NewBuffer(request.Body)),
}
@ -91,7 +89,7 @@ func (p *ZLTXCardV1Service) Notify(ctx context.Context, request *proto.NotifyReq
return nil, err
}
resp, cardCode, err := dctW.Notify(ctx, req)
resp, cardCode, err := dctW.Notify(ctx, httpRequest)
if err != nil {
return nil, err
}

View File

@ -17,7 +17,7 @@ func config() []byte {
AppKey: "1e2bf7a04b8b1e6be5dc78d04e8639c9",
BaseUri: "http://test.openapi.1688sup.cn",
NotifyUrl: "https://gateway.dev.cdlsxd.cn/yxh5api/v1/order/direct/notify",
MerchantId: "23329",
MerchantId: 23329,
}
marshal, _ := json.Marshal(c)
return marshal
@ -82,8 +82,8 @@ func TestNotify(t *testing.T) {
in := &proto.NotifyRequest{
Config: config(),
Queries: nil,
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":"test_plugin_zltx_v1_card_2","status":"01","cardCode":"iCtn0Lix8y/+cEwVayEOPg=="}`),
Headers: []byte(`{"Accept-Encoding":["gzip, deflate, br"],"Authorization":["MD5 appid=1,sign=B8DD605A67EDFF68C83626A4529E5B99"],"Connection":["close"],"Content-Length":["140"],"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":"test_v1_card_zltx_002","tradeNo":"713390676754186241","status":"01","cardCode":"i548vESCHR7GkTeJwg8vHA=="}`),
}
t.Run("TestNotify", func(t *testing.T) {
got, err := zltx.Notify(context.Background(), in)

View File

@ -3,7 +3,7 @@ module plugins/zltx_v1
go 1.22.2
require (
gitea.cdlsxd.cn/sdk/plugin v1.0.11
gitea.cdlsxd.cn/sdk/plugin v1.0.12
github.com/go-playground/validator/v10 v10.22.0
github.com/hashicorp/go-plugin v1.6.1
github.com/stretchr/testify v1.9.0

View File

@ -1,5 +1,7 @@
gitea.cdlsxd.cn/sdk/plugin v1.0.11 h1:NMMgw2p7ZF7EbWjkSO7ttM62BLhsG0bGmPdGGS1gpJc=
gitea.cdlsxd.cn/sdk/plugin v1.0.11/go.mod h1:FLuWLP2QP2aBzI2HCdZ7tvl1ieMuMOpTWvItmNGCeGA=
gitea.cdlsxd.cn/sdk/plugin v1.0.12 h1:gA7zRagOro38rbRVIfFgGRuGOr+Wig8EjeqQkYedFXc=
gitea.cdlsxd.cn/sdk/plugin v1.0.12/go.mod h1:FLuWLP2QP2aBzI2HCdZ7tvl1ieMuMOpTWvItmNGCeGA=
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/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=

View File

@ -14,7 +14,7 @@ type Config struct {
AppKey string `json:"app_key" validate:"required"`
BaseUri string `json:"base_uri" validate:"required"`
NotifyUrl string `json:"notify_url" validate:"required"`
MerchantId string `json:"merchant_id" validate:"required"`
MerchantId int64 `json:"merchant_id" validate:"required"`
}
func (c *Config) validate() error {

View File

@ -9,7 +9,6 @@ import (
"gitea.cdlsxd.cn/sdk/plugin/proto"
"io"
"net/http"
"strings"
)
// 插件通信信息,若不对应则会报错panic
@ -85,8 +84,7 @@ func (p *ZLTXV1Service) Notify(ctx context.Context, request *proto.NotifyRequest
}
newHeaders := make(http.Header)
for key, values := range httpHeaders {
newKey := strings.ToTitle(strings.ToLower(key))
newHeaders[newKey] = values
newHeaders[key] = values
}
req := &http.Request{

View File

@ -17,7 +17,7 @@ func config() []byte {
AppKey: "1e2bf7a04b8b1e6be5dc78d04e8639c9",
BaseUri: "http://test.openapi.1688sup.cn",
NotifyUrl: "https://gateway.dev.cdlsxd.cn/yxh5api/v1/order/direct/notify",
MerchantId: "25537",
MerchantId: 25537,
}
marshal, _ := json.Marshal(c)
return marshal