1
This commit is contained in:
@@ -10,6 +10,7 @@ import (
|
|||||||
"encoding/pem"
|
"encoding/pem"
|
||||||
"fmt"
|
"fmt"
|
||||||
"git.rosy.net.cn/baseapi/utils"
|
"git.rosy.net.cn/baseapi/utils"
|
||||||
|
"git.rosy.net.cn/jx-callback/globals"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
"sort"
|
"sort"
|
||||||
@@ -98,6 +99,7 @@ func (a *API) signParams(params map[string]interface{}) (sign string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
finalStr := strings.Join(strList, "&")
|
finalStr := strings.Join(strList, "&")
|
||||||
|
globals.SugarLogger.Debugf("============finalStr: %s", finalStr)
|
||||||
d := sha256.Sum256([]byte(finalStr))
|
d := sha256.Sum256([]byte(finalStr))
|
||||||
signature, _ := rsa.SignPKCS1v15(rand.Reader, a.privateKey, crypto.SHA256, d[:])
|
signature, _ := rsa.SignPKCS1v15(rand.Reader, a.privateKey, crypto.SHA256, d[:])
|
||||||
sign = base64.StdEncoding.EncodeToString(signature)
|
sign = base64.StdEncoding.EncodeToString(signature)
|
||||||
@@ -128,6 +130,7 @@ func (a *API) AccessAPI(method string, params, bizContent map[string]interface{}
|
|||||||
var request *http.Request
|
var request *http.Request
|
||||||
params["timestamp"] = utils.GetCurTimeStr()
|
params["timestamp"] = utils.GetCurTimeStr()
|
||||||
params[signKey] = a.signParams(params)
|
params[signKey] = a.signParams(params)
|
||||||
|
globals.SugarLogger.Debugf("======sginKey := %v", params[signKey])
|
||||||
|
|
||||||
fullURL := utils.GenerateGetURL(prodURL, "", params)
|
fullURL := utils.GenerateGetURL(prodURL, "", params)
|
||||||
if isPost {
|
if isPost {
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
package alipayapi
|
package alipayapi
|
||||||
|
|
||||||
import "git.rosy.net.cn/baseapi/utils"
|
import (
|
||||||
|
"git.rosy.net.cn/baseapi/utils"
|
||||||
|
"git.rosy.net.cn/jx-callback/globals"
|
||||||
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
GrantTypeCode = "authorization_code"
|
GrantTypeCode = "authorization_code"
|
||||||
@@ -52,6 +55,8 @@ func (a *API) SystemAuthToken(grantType, code, refreshToken string) (tokenInfo *
|
|||||||
params["alipay_root_cert_sn"] = aliPayRootCertSN
|
params["alipay_root_cert_sn"] = aliPayRootCertSN
|
||||||
|
|
||||||
retVal, err := a.AccessAPI("alipay.system.oauth.token", params, nil, false)
|
retVal, err := a.AccessAPI("alipay.system.oauth.token", params, nil, false)
|
||||||
|
globals.SugarLogger.Debugf("======retVal := %v", retVal)
|
||||||
|
globals.SugarLogger.Debugf("======err := %v", err)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
err = utils.Map2StructByJson(retVal, &tokenInfo, false)
|
err = utils.Map2StructByJson(retVal, &tokenInfo, false)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user