通联宝支付测试

This commit is contained in:
苏尹岚
2020-02-27 08:58:58 +08:00
parent 92a244c3aa
commit 91fa24df7c
4 changed files with 20 additions and 3 deletions

View File

@@ -1,7 +1,12 @@
package localjx
import (
"crypto/md5"
"crypto/rand"
"crypto/rsa"
"crypto/x509"
"encoding/json"
"io/ioutil"
"time"
"git.rosy.net.cn/jx-callback/globals"
@@ -40,6 +45,14 @@ func pay4OrderByTL(ctx *jxcontext.Context, order *model.GoodsOrder, vendorPayTyp
param.Acct = authInfo.GetAuthID()
}
result, err := api.TLpayAPI.CreateUnitorderOrder(param)
result2 := &tonglianpayapi.PayInfo{}
json.Unmarshal([]byte(result.PayInfo), &result2)
file, err := ioutil.ReadFile("conf/rsa_key.pem")
prk, err := x509.ParsePKCS1PrivateKey(file)
paySign, err := rsa.DecryptOAEP(md5.New(), rand.Reader, prk, []byte(result2.PaySign), nil)
result2.PaySign = string(paySign)
str, err := json.Marshal(result2)
result.PayInfo = string(str)
if err == nil {
result2 := &wxpayapi.CreateOrderResult{}
json.Unmarshal([]byte(result.PayInfo), &result2)