test
This commit is contained in:
parent
5e71fabbf9
commit
3069c47115
|
@ -26,7 +26,7 @@ func TestCard_Order(t *testing.T) {
|
||||||
req := &Order{
|
req := &Order{
|
||||||
Number: 1,
|
Number: 1,
|
||||||
MerchantId: "23329",
|
MerchantId: "23329",
|
||||||
OutTradeNo: "test_1_zltx_4",
|
OutTradeNo: "test_card_zltx_1",
|
||||||
ProductId: "222",
|
ProductId: "222",
|
||||||
Mobile: "18666666666",
|
Mobile: "18666666666",
|
||||||
NotifyUrl: "http://test.openapi.1688sup.cn",
|
NotifyUrl: "http://test.openapi.1688sup.cn",
|
||||||
|
@ -56,7 +56,7 @@ func TestCard_Query(t *testing.T) {
|
||||||
a := &Card{DctWServer: server}
|
a := &Card{DctWServer: server}
|
||||||
req := &Query{
|
req := &Query{
|
||||||
MerchantId: "23329",
|
MerchantId: "23329",
|
||||||
OutTradeNo: "test_1_zltx_4",
|
OutTradeNo: "test_card_zltx_1",
|
||||||
Version: "1.0",
|
Version: "1.0",
|
||||||
}
|
}
|
||||||
resp, err := a.Query(context.Background(), req)
|
resp, err := a.Query(context.Background(), req)
|
||||||
|
|
|
@ -26,7 +26,7 @@ func TestDirect_Order(t *testing.T) {
|
||||||
req := &Order{
|
req := &Order{
|
||||||
Number: 1,
|
Number: 1,
|
||||||
MerchantId: "23329",
|
MerchantId: "23329",
|
||||||
OutTradeNo: "test_1_zltx_7",
|
OutTradeNo: "test_direct_zltx_7",
|
||||||
ProductId: "106",
|
ProductId: "106",
|
||||||
AccountType: 1,
|
AccountType: 1,
|
||||||
RechargeAccount: "18666666666",
|
RechargeAccount: "18666666666",
|
||||||
|
@ -57,7 +57,7 @@ func TestDirect_Query(t *testing.T) {
|
||||||
a := &Direct{DctWServer: server}
|
a := &Direct{DctWServer: server}
|
||||||
req := &Query{
|
req := &Query{
|
||||||
MerchantId: "23329",
|
MerchantId: "23329",
|
||||||
OutTradeNo: "test_1_zltx_7",
|
OutTradeNo: "test_direct_zltx_7",
|
||||||
Version: "1.0",
|
Version: "1.0",
|
||||||
}
|
}
|
||||||
resp, err := a.Query(context.Background(), req)
|
resp, err := a.Query(context.Background(), req)
|
||||||
|
|
|
@ -14,7 +14,7 @@ import (
|
||||||
|
|
||||||
const (
|
const (
|
||||||
DeBug = true
|
DeBug = true
|
||||||
SignType = "MD5"
|
SignType = "md5"
|
||||||
SignKeyName = "Authorization"
|
SignKeyName = "Authorization"
|
||||||
ApplicationJSON = "application/json"
|
ApplicationJSON = "application/json"
|
||||||
)
|
)
|
||||||
|
@ -82,7 +82,7 @@ func NewDctWServer(config *DctWConfig, o ...Option) (*DctWServer, error) {
|
||||||
|
|
||||||
func (c *DctWServer) Sign(body, path, timestamp string) string {
|
func (c *DctWServer) Sign(body, path, timestamp string) string {
|
||||||
str := c.Config.AppId + body + path + timestamp + c.Config.AppKey
|
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 {
|
func (c *DctWServer) BuildAuth(signStr, timestamp string) string {
|
||||||
|
|
|
@ -29,6 +29,11 @@ func Load(dir string) ([]string, error) {
|
||||||
return files, nil
|
return files, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Md5ToLower(values []byte) string {
|
||||||
|
hash := md5.Sum(values)
|
||||||
|
return strings.ToLower(hex.EncodeToString(hash[:]))
|
||||||
|
}
|
||||||
|
|
||||||
func Md5(values []byte) string {
|
func Md5(values []byte) string {
|
||||||
hash := md5.Sum(values)
|
hash := md5.Sum(values)
|
||||||
return strings.ToUpper(hex.EncodeToString(hash[:]))
|
return strings.ToUpper(hex.EncodeToString(hash[:]))
|
||||||
|
|
Loading…
Reference in New Issue