1
This commit is contained in:
@@ -10,6 +10,7 @@ const (
|
||||
BankList = "bank" // 银行列表查询
|
||||
MerchantMcc = "customer/category" // 银行列表查询
|
||||
FileUpload = "file/upload" // 文件上传
|
||||
|
||||
)
|
||||
|
||||
// 业务访问路由2
|
||||
|
||||
@@ -28,6 +28,7 @@ const (
|
||||
SeparateBindAction = "ledger/applyBind" // 分账关系绑定
|
||||
SeparateUnBindAction = "ledger/applyUnBind" // 分账关系解除绑定
|
||||
SeparateCardBinAction = "cardBin" // 卡BIN查询
|
||||
AttachmentUpload = "uploadFile" // 附件上传
|
||||
)
|
||||
|
||||
// 分账
|
||||
|
||||
@@ -134,36 +134,53 @@ type UploadImgResp struct {
|
||||
Result interface{} `json:"result"` //
|
||||
}
|
||||
|
||||
// signParamRSA 支付签名
|
||||
//func (a *API) signParamRSA(params map[string]interface{}, RSAPrivate string) (sig string, err error) {
|
||||
// block, _ := pem.Decode([]byte(RSAPrivate))
|
||||
// private, err := x509.ParsePKCS8PrivateKey(block.Bytes)
|
||||
// if err != nil {
|
||||
// return "", err
|
||||
// }
|
||||
//
|
||||
// // 签名参数
|
||||
// body, err := json.Marshal(params)
|
||||
// if err != nil {
|
||||
// return "", err
|
||||
// }
|
||||
//
|
||||
// //bodyData := base64.StdEncoding.EncodeToString(body)
|
||||
// nonceStr := GenerateSecureRandomString(12)
|
||||
// timeStamp := utils.Int64ToStr(time.Now().Unix())
|
||||
// context := fmt.Sprintf("%s\n%s\n%s\n%s\n%s\n", a.appID, a.serialNo, timeStamp, nonceStr, string(body))
|
||||
//
|
||||
// // 进行rsa加密签名
|
||||
// hashed := sha256.Sum256([]byte(context))
|
||||
// signedData, err := rsa.SignPKCS1v15(rand.Reader, private.(*rsa.PrivateKey), crypto.SHA256, hashed[:])
|
||||
// if err != nil {
|
||||
// return "", err
|
||||
// }
|
||||
//
|
||||
// signData := base64.StdEncoding.EncodeToString(signedData)
|
||||
// authorization := fmt.Sprintf(`LKLAPI-SHA256withRSA appid="%s",serial_no="%s",timestamp="%s",nonce_str="%s",signature="%s"`, a.appID, a.serialNo, timeStamp, nonceStr, signData)
|
||||
// return authorization, nil
|
||||
//}
|
||||
// AttachmentUpload 附件上传
|
||||
func (a *API) AttachmentUpload(param *AttachmentImg) (*AttachmentImgResp, error) {
|
||||
reqParameter := map[string]interface{}{
|
||||
"reqData": param,
|
||||
"ver": Version,
|
||||
"timestamp": utils.Int64ToStr(time.Now().Unix()),
|
||||
"reqId": utils.GetUUID(),
|
||||
}
|
||||
result, err := a.AccessAPISign(SeparateAccountProdUrl, AttachmentUpload, http.MethodPost, "", reqParameter)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if result["retCode"].(string) != Success {
|
||||
return nil, errors.New(result["retMsg"].(string))
|
||||
}
|
||||
|
||||
bodyResult, err := json.Marshal(result["respData"])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
attachment := &AttachmentImgResp{}
|
||||
if err = json.Unmarshal(bodyResult, attachment); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return attachment, nil
|
||||
}
|
||||
|
||||
// AttachmentImg 进件附件上传
|
||||
type AttachmentImg struct {
|
||||
Version string `json:"version"`
|
||||
OrderNo string `json:"orderNo"`
|
||||
OrgCode string `json:"orgCode"`
|
||||
AttType string `json:"attType"`
|
||||
AttExtName string `json:"attExtName"`
|
||||
AttContext string `json:"attContext"`
|
||||
}
|
||||
|
||||
// AttachmentImgResp 进件返回值
|
||||
type AttachmentImgResp struct {
|
||||
AttType string `json:"attType"`
|
||||
OrderNo string `json:"orderNo"`
|
||||
OrgCode string `json:"orgCode"`
|
||||
AttFileId string `json:"attFileId"`
|
||||
}
|
||||
|
||||
// signParamRSA 支付签名
|
||||
func (a *API) signParamPrivateKey(params map[string]interface{}, RSAPrivate string) (sig string, err error) {
|
||||
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user