DotNetCore.SKIT.FlurlHttpCl.../docs/WechatTenpayBusiness/README.md

102 lines
3.2 KiB
Markdown
Raw Permalink Normal View History

2022-05-09 20:31:03 +08:00
# SKIT.FlurlHttpClient.Wechat.TenpayBusiness
2023-04-11 15:42:49 +08:00
基于 `Flurl.Http` 的[微企付](https://businesspay.qq.com/p/mse-pay/) HTTP API SDK。
2022-05-09 20:31:03 +08:00
---
## 功能
2023-04-11 15:42:49 +08:00
- 基于微企付 API 封装。
2022-05-09 20:31:03 +08:00
- 请求时自动生成签名,无需开发者手动干预。
2023-04-11 15:42:49 +08:00
- 提供了微企付所需的 RSA、SM3、SM4、SHA-256 等算法工具类。
2022-05-09 20:31:03 +08:00
- 提供了解析回调通知事件等扩展方法。
---
2023-03-02 19:36:47 +08:00
## 快速入门
2022-05-09 20:31:03 +08:00
2024-02-07 11:22:05 +08:00
> [!IMPORTANT]
> 此目录下的文档适用于 v3.x 版本的模块。如果你正在使用 2.x 版本,请移步至 GitHub/Gitee 的已归档分支。
2022-05-09 20:31:03 +08:00
### 安装:
提示:如果你使用 Visual Studio NuGet 管理器图形化界面,请在搜索结果中勾选“**包括预发行版**”。
```shell
# 通过 NuGet 安装
> Install-Package SKIT.FlurlHttpClient.Wechat.TenpayBusiness
# 通过 dotnet-tools 安装
> dotnet add package SKIT.FlurlHttpClient.Wechat.TenpayBusiness
```
### 初始化:
```csharp
using SKIT.FlurlHttpClient.Wechat.TenpayBusiness;
var options = new WechatTenpayBusinessClientOptions()
{
2023-04-11 15:42:49 +08:00
PlatformId = "微企付平台账号",
PlatformCertificateSerialNumber = "微企付平台 API 证书序列号",
PlatformCertificatePrivateKey = "-----BEGIN PRIVATE KEY-----微企付平台 API 证书私钥-----END PRIVATE KEY-----",
EnterpriseId = "微企付企业商户 ID非必填",
EnterpriseCertificateSerialNumber = "微企付企业商户 API 证书序列号(非必填)",
EnterpriseCertificatePrivateKey = "-----BEGIN PRIVATE KEY-----微企付企业商户 API 证书私钥(非必填)-----END PRIVATE KEY-----",
TBEPCertificateSerialNumber = "微企付证书序列号",
TBEPCertificatePublicKey = "-----BEGIN PUBLIC KEY-----微企付证书公钥-----END PUBLIC KEY-----"
2022-05-09 20:31:03 +08:00
};
2024-02-07 11:22:05 +08:00
var client = WechatTenpayBusinessClientBuilder.Create(options).Build();
2022-05-09 20:31:03 +08:00
```
### 请求 & 响应:
```csharp
using SKIT.FlurlHttpClient.Wechat.TenpayBusiness;
using SKIT.FlurlHttpClient.Wechat.TenpayBusiness.Models;
/* 以根据交易订单查询付款结果接口为例 */
2023-04-11 15:42:49 +08:00
var request = new GetPaymentByPaymentIdRequest()
2022-05-09 20:31:03 +08:00
{
OutPaymentId = "平台支付单号"
};
2023-04-11 15:42:49 +08:00
var response = await client.ExecuteGetPaymentByOutPaymentIdAsync(request);
2022-05-09 20:31:03 +08:00
if (response.IsSuccessful())
{
Console.WriteLine("微企付支付单号:" + response.PaymentId);
}
else
{
Console.WriteLine("错误代码:" + response.Error.Code);
Console.WriteLine("错误描述:" + response.Error.Description);
}
```
---
2023-03-02 19:36:47 +08:00
## 基础用法
2024-02-07 11:22:05 +08:00
- ⭐ [如何快速找到需要调用的 API 模型类名 / 方法名(附完整 API 对照表)?](./Basic_ModelDefinition.md)
2022-05-09 20:31:03 +08:00
2023-03-02 19:36:47 +08:00
- [如何加密请求中的敏感数据?](./Basic_RequestSensitiveDataEncryption.md)
2022-05-09 20:31:03 +08:00
2023-03-02 19:36:47 +08:00
- [如何解密响应中的敏感数据?](./Basic_ResponseSensitiveDataDecryption.md)
2022-05-09 20:31:03 +08:00
2023-03-02 19:36:47 +08:00
- [如何验证响应签名?](./Basic_ResponseSignatureVerification.md)
2022-05-09 20:31:03 +08:00
2023-03-02 19:36:47 +08:00
- [如何验证回调通知事件签名?](./Basic_EventSignatureVerification.md)
2022-05-09 20:31:03 +08:00
2023-03-02 19:36:47 +08:00
---
## 高级技巧
2022-12-15 11:59:29 +08:00
2024-03-09 22:28:48 +08:00
- [配置 JSON 序列化器](./Advanced_JsonSerializer.md)
2024-02-21 21:59:41 +08:00
2024-03-09 22:28:48 +08:00
- [配置 HttpClient](./Advanced_HttpClient.md)
2022-12-15 11:59:29 +08:00
2024-03-09 22:28:48 +08:00
- [使用拦截器](./Advanced_Interceptor.md)
2022-12-15 11:59:29 +08:00
2024-03-09 22:28:48 +08:00
- [避免内存泄漏](./Advanced_Dispose.md)
- [与 `IHttpClientFactory` 集成](./Advanced_HttpClientFactory.md)