diff --git a/dctw/v1/api/card/card_test.go b/dctw/v1/api/card/card_test.go index ed8a3da..83d9440 100644 --- a/dctw/v1/api/card/card_test.go +++ b/dctw/v1/api/card/card_test.go @@ -26,7 +26,7 @@ func TestCard_Order(t *testing.T) { req := &Order{ Number: 1, MerchantId: "23329", - OutTradeNo: "test_1_zltx_4", + OutTradeNo: "test_card_zltx_1", ProductId: "222", Mobile: "18666666666", NotifyUrl: "http://test.openapi.1688sup.cn", @@ -56,7 +56,7 @@ func TestCard_Query(t *testing.T) { a := &Card{DctWServer: server} req := &Query{ MerchantId: "23329", - OutTradeNo: "test_1_zltx_4", + OutTradeNo: "test_card_zltx_1", Version: "1.0", } resp, err := a.Query(context.Background(), req) diff --git a/dctw/v1/api/direct/direct_test.go b/dctw/v1/api/direct/direct_test.go index 210aca5..347ed88 100644 --- a/dctw/v1/api/direct/direct_test.go +++ b/dctw/v1/api/direct/direct_test.go @@ -26,7 +26,7 @@ func TestDirect_Order(t *testing.T) { req := &Order{ Number: 1, MerchantId: "23329", - OutTradeNo: "test_1_zltx_7", + OutTradeNo: "test_direct_zltx_7", ProductId: "106", AccountType: 1, RechargeAccount: "18666666666", @@ -57,7 +57,7 @@ func TestDirect_Query(t *testing.T) { a := &Direct{DctWServer: server} req := &Query{ MerchantId: "23329", - OutTradeNo: "test_1_zltx_7", + OutTradeNo: "test_direct_zltx_7", Version: "1.0", } resp, err := a.Query(context.Background(), req) diff --git a/dctw/v1/core/core.go b/dctw/v1/core/core.go index b3ddceb..a2206ad 100644 --- a/dctw/v1/core/core.go +++ b/dctw/v1/core/core.go @@ -14,7 +14,7 @@ import ( const ( DeBug = true - SignType = "MD5" + SignType = "md5" SignKeyName = "Authorization" ApplicationJSON = "application/json" ) @@ -82,7 +82,7 @@ func NewDctWServer(config *DctWConfig, o ...Option) (*DctWServer, error) { func (c *DctWServer) Sign(body, path, timestamp string) string { str := c.Config.AppId + body + path + timestamp + c.Config.AppKey - return utils.Md5([]byte(str)) + return utils.Md5ToLower([]byte(str)) } func (c *DctWServer) BuildAuth(signStr, timestamp string) string { diff --git a/utils/utils.go b/utils/utils.go index 40d7670..80f6e7f 100644 --- a/utils/utils.go +++ b/utils/utils.go @@ -29,6 +29,11 @@ func Load(dir string) ([]string, error) { return files, nil } +func Md5ToLower(values []byte) string { + hash := md5.Sum(values) + return strings.ToLower(hex.EncodeToString(hash[:])) +} + func Md5(values []byte) string { hash := md5.Sum(values) return strings.ToUpper(hex.EncodeToString(hash[:]))