wechatpay-apiv3 / wechatpay-go

微信支付 APIv3 的官方 Go Library
https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/pages/index.shtml
Apache License 2.0
1.07k stars 145 forks source link

支持微信支付公钥验签 (全新商户) #220

Closed xy-peng closed 6 months ago

xy-peng commented 7 months ago

方案

  1. 扩展了 verifierencryptors,支持微信支付公钥
  2. 将本地平台证书的方法标识为废弃

如何使用

// 初始化 Client
opts := []core.ClientOption{
    option.WithWechatPayPublicKeyAuthCipher(
        mchID,
        mchCertificateSerialNumber, mchPrivateKey,
        wechatpayPublicKeyID, wechatpayPublicKey),
}
client, err := core.NewClient(ctx, opts...)

// 初始化 notify.Handler
handler := notify.NewNotifyHandler(
    mchAPIv3Key, 
    verifiers.NewSHA256WithRSAPubkeyVerifier(wechatpayPublicKeyID, *wechatPayPublicKey))
sonarcloud[bot] commented 6 months ago

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud