修改vivo支付接口

This commit is contained in:
ayflying
2025-07-24 18:33:54 +08:00
parent 90b72129a5
commit fae17af54a
6 changed files with 36 additions and 12 deletions

View File

@@ -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
}

View File

@@ -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,
}
}

View File

@@ -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"`
}

View File

@@ -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 {

View File

@@ -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)
}
})

View File

@@ -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)
}
})