forked from fudiwei/DotNetCore.SKIT.FlurlHttpClient.Wechat
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
650 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
## 如何解密回调通知事件中的敏感数据? | ||
|
||
--- | ||
|
||
### 解密流程 | ||
|
||
对于回调通知事件的敏感信息,微信商户平台使用了商户密钥基于 AES 算法加密。 | ||
|
||
开发者可利用本库提供的 `AESUtility` 工具类自行解密相关字段。 | ||
|
||
此外,本库还封装了直接解密事件的扩展方法,下面给出一个示例代码: | ||
|
||
```csharp | ||
/* 微信商户平台发来的通知内容 */ | ||
string callbackXml = "<xml> ... </xml>"; | ||
/* 将 XML 反序列化得到通知对象 */ | ||
var callbackModel = client.DeserializeEvent(callbackJson); | ||
/* 解密得到支付通知敏感数据(以退款结果通知为例) */ | ||
var callbackResource = client.DecryptEventRequestInfo<Events.RefundEventRequestInfo>(callbackModel); | ||
string outRefundNumber = callbackResource.OutRefundNumber; | ||
string refundId = callbackResource.RefundId; | ||
} | ||
``` | ||
|
||
完整的回调通知模型定义可以参考项目目录下的 _src/SKIT.FlurlHttpClient.Wechat.TenpayV2/Events_ 目录。 |
15 changes: 15 additions & 0 deletions
15
docs/WechatTenpayV2/Advanced_EventSignatureVerification.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
## 如何验证回调通知事件签名? | ||
|
||
--- | ||
|
||
### 验签流程 | ||
|
||
你可根据官方文档的规则利用本库提供的 `MD5Utility`、`HMACUtility` 工具类自行进行签名验证。 | ||
|
||
此外,本库还封装了直接解密事件的扩展方法,下面给出一个示例代码: | ||
|
||
```csharp | ||
bool ret = client.VerifyEventSignature( | ||
callbackBody: "<xml> 微信回调通知中请求正文 XML 内容 </xml>" | ||
); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
## 如何使用拦截器? | ||
|
||
--- | ||
|
||
拦截器在本库下的用法与在 [SKIT.FlurlHttpClient.Wechat.Api](../WechatApi/README.md) 模块下的用法类似,请参阅[相关文档](../WechatApi/Advanced_Interceptor.md)。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
## 如何指定 JSON 序列化器? | ||
|
||
--- | ||
|
||
JSON 序列化器在本库下的用法与在 [SKIT.FlurlHttpClient.Wechat.Api](../WechatApi/README.md) 模块下的用法类似,请参阅[相关文档](../WechatApi/Advanced_JsonSerializer.md)。 |
Oops, something went wrong.