修改vivo支付接口
This commit is contained in:
@@ -47,7 +47,7 @@ func (p *OppoType) FileIdInfo(ctx context.Context, oauthToken string, ssoid stri
|
||||
})
|
||||
getRes := getHtml.ReadAllString()
|
||||
gjson.DecodeTo(getRes, &res)
|
||||
g.Log().Debugf(ctx, "当前登陆请求的:%v", res)
|
||||
//g.Log().Debugf(ctx, "当前登陆请求的:%v", res)
|
||||
return
|
||||
|
||||
}
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
package vivo
|
||||
|
||||
type Pay struct {
|
||||
AppId string
|
||||
AppKey string
|
||||
AppSecret string
|
||||
AppId string
|
||||
AppKey string
|
||||
//AppSecret string
|
||||
}
|
||||
|
||||
func New(appId, appKey, appSecret string) (client *Pay) {
|
||||
func New(cfg *Pay) (client *Pay) {
|
||||
return &Pay{
|
||||
AppId: appId,
|
||||
AppKey: appKey,
|
||||
AppSecret: appSecret,
|
||||
AppId: cfg.AppId,
|
||||
AppKey: cfg.AppKey,
|
||||
//AppSecret: cfg.AppSecret,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,3 +9,26 @@ type TokenAuthResponseData struct {
|
||||
Success bool `json:"success,omitempty"`
|
||||
OpenId string `json:"openid,omitempty"`
|
||||
}
|
||||
|
||||
type LoginType struct {
|
||||
Token string `json:"token"`
|
||||
Ssoid string `json:"ssoid"`
|
||||
Channel int `json:"channel"`
|
||||
AdId string `json:"adId"`
|
||||
}
|
||||
|
||||
type PayCallback struct {
|
||||
AppId string `json:"appId"`
|
||||
CpId string `json:"cpId"`
|
||||
CpOrderNumber string `json:"cpOrderNumber"`
|
||||
ExtInfo string `json:"extInfo"`
|
||||
OrderAmount string `json:"orderAmount"`
|
||||
OrderNumber string `json:"orderNumber"`
|
||||
PayTime string `json:"payTime"`
|
||||
RespCode string `json:"respCode"`
|
||||
RespMsg string `json:"respMsg"`
|
||||
SignMethod string `json:"signMethod"`
|
||||
Signature string `json:"signature"`
|
||||
TradeStatus string `json:"tradeStatus"`
|
||||
TradeType string `json:"tradeType"`
|
||||
}
|
||||
|
||||
@@ -14,7 +14,8 @@ func (p *Pay) VerifySign(bm g.Map, key string) bool {
|
||||
signature := bm["signature"]
|
||||
delete(bm, "signature")
|
||||
delete(bm, "signMethod")
|
||||
return signature == p.sign(bm, key)
|
||||
sign := p.sign(bm, key)
|
||||
return signature == sign
|
||||
}
|
||||
|
||||
func (p *Pay) sign(bm g.Map, key string) string {
|
||||
|
||||
@@ -41,7 +41,7 @@ func TestVerifySign(t *testing.T) {
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
if got := New("123", "123", "123").VerifySign(tt.args.bm, tt.args.key); got != tt.want {
|
||||
if got := New(nil).VerifySign(tt.args.bm, tt.args.key); got != tt.want {
|
||||
t.Errorf("VerifySign() = %v, want %v", got, tt.want)
|
||||
}
|
||||
})
|
||||
|
||||
@@ -30,7 +30,7 @@ func TestAuthToken(t *testing.T) {
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
gotRsp, err := New("", "", "").AuthToken(tt.args.bm)
|
||||
gotRsp, err := New(nil).AuthToken(tt.args.bm)
|
||||
if (err != nil) != tt.wantErr {
|
||||
t.Errorf("AuthToken() error = %v, wantErr %v", err, tt.wantErr)
|
||||
return
|
||||
@@ -62,7 +62,7 @@ func TestFormatURLParam(t *testing.T) {
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
if gotUrlParam := New("", "", "").FormatURLParam(tt.args.body); gotUrlParam != tt.wantUrlParam {
|
||||
if gotUrlParam := New(nil).FormatURLParam(tt.args.body); gotUrlParam != tt.wantUrlParam {
|
||||
t.Errorf("FormatURLParam() = %v, want %v", gotUrlParam, tt.wantUrlParam)
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user