修复商福通接口签名编码逻辑;统一充值和创建套餐接口为聚合接口
This commit is contained in:
@@ -109,17 +109,17 @@ type PaymentScanPayReq struct {
|
||||
Currency string `json:"currency"`
|
||||
ClientIp string `json:"clientIp"`
|
||||
MchOrderNo string `json:"mchOrderNo"`
|
||||
StoreId *string `json:"storeId"`
|
||||
RouteNo *string `json:"routeNo"`
|
||||
HbFqNum *int `json:"hbFqNum"`
|
||||
HbFqPercent *int `json:"hbFqPercent"`
|
||||
BuyerRemark *string `json:"buyerRemark"`
|
||||
NotifyUrl *string `json:"notifyUrl"`
|
||||
ReturnUrl *string `json:"returnUrl"`
|
||||
ExpiredTime *int `json:"expiredTime"`
|
||||
OrderTimeout *string `json:"orderTimeout"`
|
||||
ExtParam *string `json:"extParam"`
|
||||
LimitPay *int `json:"limitPay"`
|
||||
StoreId *string `json:"storeId,omitempty"`
|
||||
RouteNo *string `json:"routeNo,omitempty"`
|
||||
HbFqNum *int `json:"hbFqNum,omitempty"`
|
||||
HbFqPercent *int `json:"hbFqPercent,omitempty"`
|
||||
BuyerRemark *string `json:"buyerRemark,omitempty"`
|
||||
NotifyUrl *string `json:"notifyUrl,omitempty"`
|
||||
ReturnUrl *string `json:"returnUrl,omitempty"`
|
||||
ExpiredTime *int `json:"expiredTime,omitempty"`
|
||||
OrderTimeout *string `json:"orderTimeout,omitempty"`
|
||||
ExtParam *string `json:"extParam,omitempty"`
|
||||
LimitPay *int `json:"limitPay,omitempty"`
|
||||
}
|
||||
|
||||
type PaymentH5PayReq struct {
|
||||
@@ -130,27 +130,27 @@ type PaymentH5PayReq struct {
|
||||
PayType SftPayType `json:"payType"`
|
||||
ClientIp string `json:"clientIp"`
|
||||
MchOrderNo string `json:"mchOrderNo"`
|
||||
StoreId *string `json:"storeId"`
|
||||
RouteNo *string `json:"routeNo"`
|
||||
HbFqNum *int `json:"hbFqNum"`
|
||||
HbFqPercent *int `json:"hbFqPercent"`
|
||||
BuyerRemark *string `json:"buyerRemark"`
|
||||
NotifyUrl *string `json:"notifyUrl"`
|
||||
ReturnUrl *string `json:"returnUrl"`
|
||||
ExpiredTime *int `json:"expiredTime"`
|
||||
OrderTimeout *string `json:"orderTimeout"`
|
||||
ExtParam *string `json:"extParam"`
|
||||
LimitPay *int `json:"limitPay"`
|
||||
StoreId *string `json:"storeId,omitempty"`
|
||||
RouteNo *string `json:"routeNo,omitempty"`
|
||||
HbFqNum *int `json:"hbFqNum,omitempty"`
|
||||
HbFqPercent *int `json:"hbFqPercent,omitempty"`
|
||||
BuyerRemark *string `json:"buyerRemark,omitempty"`
|
||||
NotifyUrl *string `json:"notifyUrl,omitempty"`
|
||||
ReturnUrl *string `json:"returnUrl,omitempty"`
|
||||
ExpiredTime *int `json:"expiredTime,omitempty"`
|
||||
OrderTimeout *string `json:"orderTimeout,omitempty"`
|
||||
ExtParam *string `json:"extParam,omitempty"`
|
||||
LimitPay *int `json:"limitPay,omitempty"`
|
||||
}
|
||||
|
||||
type QueryTradeReq struct {
|
||||
PayOrderId *string `json:"payOrderId"`
|
||||
MchOrderNo *string `json:"mchOrderNo"`
|
||||
PayOrderId *string `json:"payOrderId,omitempty"`
|
||||
MchOrderNo *string `json:"mchOrderNo,omitempty"`
|
||||
}
|
||||
|
||||
type OrderCloseReq struct {
|
||||
MchOrderNo *string `json:"mchOrderNo"`
|
||||
PayOrderId *string `json:"payOrderId"`
|
||||
MchOrderNo *string `json:"mchOrderNo,omitempty"`
|
||||
PayOrderId *string `json:"payOrderId,omitempty"`
|
||||
}
|
||||
|
||||
// type OrderRefundReq struct {
|
||||
@@ -315,6 +315,9 @@ func (s *SftClient) sign(msg any) (*request, error) {
|
||||
return nil, fmt.Errorf("格式化加密正文失败:%w", err)
|
||||
}
|
||||
|
||||
pretty, _ := json.MarshalIndent(msg, "", " ")
|
||||
println("content:\n" + string(pretty) + "\n\n")
|
||||
|
||||
body := request{
|
||||
AppId: s.appid,
|
||||
Version: "1.0",
|
||||
@@ -330,7 +333,7 @@ func (s *SftClient) sign(msg any) (*request, error) {
|
||||
return nil, fmt.Errorf("签名失败:%w", err)
|
||||
}
|
||||
|
||||
body.Sign = string(signature)
|
||||
body.Sign = base64.StdEncoding.EncodeToString(signature)
|
||||
return &body, nil
|
||||
}
|
||||
|
||||
@@ -350,13 +353,18 @@ func (s *SftClient) verify(str []byte) (string, error) {
|
||||
return "", core.NewServErr("响应数据签名为空")
|
||||
}
|
||||
|
||||
sign, err := base64.StdEncoding.DecodeString(*resp.Sign)
|
||||
if err != nil {
|
||||
return "", core.NewServErr("响应数据签名 base64 解码失败")
|
||||
}
|
||||
|
||||
ser, err := resp.String()
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("格式化响应内容失败:%w", err)
|
||||
}
|
||||
|
||||
hashed := sha256.Sum256([]byte(ser))
|
||||
err = rsa.VerifyPKCS1v15(s.publicKey, crypto.SHA256, hashed[:], []byte(*resp.Sign))
|
||||
err = rsa.VerifyPKCS1v15(s.publicKey, crypto.SHA256, hashed[:], sign)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("验签失败:%w", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user