1.引入的包
import (
"context"
"crypto/x509"
"encoding/json"
"github.com/wechatpay-apiv3/wechatpay-go/core"
"github.com/wechatpay-apiv3/wechatpay-go/core/option"
wxutils "github.com/wechatpay-apiv3/wechatpay-go/utils"
)
2.建立请求vx的client
type OrderService struct{}
func (orderService *OrderService)SetUp()(opt []core.ClientOption, err error){
//商户号
mchID := global.GVA_CONFIG.VX.Payid
//商户证书序列号
mchCertSerialNumber := global.GVA_CONFIG.VX.CerSerial
//商户私钥文件路径
privateKeyPath := global.GVA_CONFIG.VX.PrivateKey
//平台证书文件路径
wechatCertificatePath := global.GVA_CONFIG.VX.Certificate
// 加载商户私钥
privateKey, err := wxutils.LoadPrivateKeyWithPath(privateKeyPath)
if err != nil {
fmt.Printf("load private err:%s", err.Error())
return nil, err
}
// 加载微信支付平台证书
wechatPayCertificate, err := wxutils.LoadCertificateWithPath(wechatCe