Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update README.md #88

Merged
merged 4 commits into from
Dec 28, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 13 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -288,8 +288,20 @@ result, err := client.Request(
2. 调用 `handler.ParseNotifyRequest` 验签,并解密报文。

### 初始化
+ 方法一(推荐):先手动注册下载器,再获取微信平台证书访问器。(在仅需回调通知验签与解密情景下使用)

+ 方法一(推荐):如果你像 [发送请求](#发送请求) 那样使用 `WithWechatPayAutoAuthCipher` 初始化 `core.Client`,直接获取微信支付平台证书访问器初始化 `notify.Handler`。
```go
ctx := context.Background()
// 这是一个单纯的回调处理进程,没有使用 WithWechatPayAutoAuthCipher 创建商户的 client,则需要手动注册下载器
err := downloader.MgrInstance().RegisterDownloaderWithPrivateKey(ctx, mchPrivateKey, mchCertificateSerialNumber, mchID, mchAPIV3Key)

// 注册完成,获取平台证书访问器
certVisitor := downloader.MgrInstance().GetCertificateVisitor(mchID)
handler := notify.NewNotifyHandler(mchAPIv3Key, verifiers.NewSHA256WithRSAVerifier(certVisitor))

```

+ 方法二:如果你像 [发送请求](#发送请求) 那样使用 `WithWechatPayAutoAuthCipher` 初始化 `core.Client`(验签与解密之后还会用到client),直接获取微信支付平台证书访问器初始化 `notify.Handler`。

```go
ctx := context.Background()
Expand All @@ -304,19 +316,6 @@ certVisitor := downloader.MgrInstance().GetCertificateVisitor(mchID)
handler := notify.NewNotifyHandler(mchAPIv3Key, verifiers.NewSHA256WithRSAVerifier(certVisitor))
```

+ 方法二:如果没有使用 `WithWechatPayAutoAuthCipher`,则需要先手动注册下载器。

```go
ctx := context.Background()
// 这是一个单纯的回调处理进程,没有使用 WithWechatPayAutoAuthCipher 创建商户的 client,则需要手动注册下载器
err := downloader.MgrInstance().RegisterDownloaderWithPrivateKey(ctx, mchPrivateKey, mchCertificateSerialNumber, mchID, mchAPIV3Key)

// 注册完成,获取平台证书访问器
certVisitor := downloader.MgrInstance().GetCertificateVisitor(mchID)
handler := notify.NewNotifyHandler(mchAPIv3Key, verifiers.NewSHA256WithRSAVerifier(certVisitor))

```

+ 方法三:使用本地的微信支付平台证书和商户 APIv3 密钥初始化 `Handler`。

```go
Expand Down