mirror of
https://gitee.com/fudiwei/DotNetCore.SKIT.FlurlHttpClient.Wechat.git
synced 2025-07-15 14:04:32 +08:00
feat(wxads): 升级公共组件
This commit is contained in:
parent
7205686f71
commit
9b434632d7
31
src/SKIT.FlurlHttpClient.Wechat.Ads/README.md
Normal file
31
src/SKIT.FlurlHttpClient.Wechat.Ads/README.md
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
## SKIT.FlurlHttpClient.Wechat.TenpayV2
|
||||||
|
|
||||||
|
[](https://github.com/fudiwei/DotNetCore.SKIT.FlurlHttpClient.Wechat)
|
||||||
|
[](https://github.com/fudiwei/DotNetCore.SKIT.FlurlHttpClient.Wechat)
|
||||||
|
[](https://www.nuget.org/packages/SKIT.FlurlHttpClient.Wechat.TenpayV2)
|
||||||
|
[](https://mit-license.org/)
|
||||||
|
|
||||||
|
基于 `Flurl.Http` 的微信商户平台 API v2 版客户端。
|
||||||
|
|
||||||
|
**注意**:本库仅仅包含微信支付未提供 v3 版 API 的部分功能,如需微信支付 v3 版 API 客户端,欢迎使用 [`SKIT.FlurlHttpClient.Wechat.TenpayV3`](https://www.nuget.org/packages/SKIT.FlurlHttpClient.Wechat.TenpayV3)。
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### 【功能特性】
|
||||||
|
|
||||||
|
- 基于微信支付 v2 版 API 封装。
|
||||||
|
- 支持直连商户、服务商两种模式。
|
||||||
|
- 请求时自动生成签名,无需开发者手动干预。
|
||||||
|
- 提供了微信支付所需的 MD5、HMAC-SHA-256 等算法工具类。
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### 【开发文档】
|
||||||
|
|
||||||
|
[点此查看](https://github.com/fudiwei/DotNetCore.SKIT.FlurlHttpClient.Wechat)。
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### 【更新日志】
|
||||||
|
|
||||||
|
[点此查看](https://github.com/fudiwei/DotNetCore.SKIT.FlurlHttpClient.Wechat/blob/main/CHANGELOG.md)。
|
@ -9,6 +9,8 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<PackageId>SKIT.FlurlHttpClient.Wechat.Ads</PackageId>
|
<PackageId>SKIT.FlurlHttpClient.Wechat.Ads</PackageId>
|
||||||
|
<PackageIcon>LOGO.png</PackageIcon>
|
||||||
|
<PackageReadmeFile>README.md</PackageReadmeFile>
|
||||||
<PackageLicenseExpression>MIT</PackageLicenseExpression>
|
<PackageLicenseExpression>MIT</PackageLicenseExpression>
|
||||||
<PackageProjectUrl>https://github.com/fudiwei/DotNetCore.SKIT.FlurlHttpClient.Wechat</PackageProjectUrl>
|
<PackageProjectUrl>https://github.com/fudiwei/DotNetCore.SKIT.FlurlHttpClient.Wechat</PackageProjectUrl>
|
||||||
<PackageTags>Flurl.Http Wechat Weixin MicroMessage WechatAds WechatAdvertisting 微信 广告平台 微信广告平台 腾讯广告平台 广点通 微信广点通 腾讯广点通</PackageTags>
|
<PackageTags>Flurl.Http Wechat Weixin MicroMessage WechatAds WechatAdvertisting 微信 广告平台 微信广告平台 腾讯广告平台 广点通 微信广点通 腾讯广点通</PackageTags>
|
||||||
@ -17,17 +19,28 @@
|
|||||||
<Authors>Fu Diwei</Authors>
|
<Authors>Fu Diwei</Authors>
|
||||||
<RepositoryType>git</RepositoryType>
|
<RepositoryType>git</RepositoryType>
|
||||||
<RepositoryUrl>https://github.com/fudiwei/DotNetCore.SKIT.FlurlHttpClient.Wechat.git</RepositoryUrl>
|
<RepositoryUrl>https://github.com/fudiwei/DotNetCore.SKIT.FlurlHttpClient.Wechat.git</RepositoryUrl>
|
||||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
|
||||||
<IncludeSymbols>true</IncludeSymbols>
|
|
||||||
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
|
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<PropertyGroup Condition="'$(Configuration)' == 'Release'">
|
||||||
|
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
|
||||||
|
<Deterministic>true</Deterministic>
|
||||||
|
<EmbedUntrackedSources>true</EmbedUntrackedSources>
|
||||||
|
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||||
|
<IncludeSymbols>true</IncludeSymbols>
|
||||||
|
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="../../LOGO.png" Pack="true" PackagePath="/" />
|
||||||
|
<None Include="README.md" Pack="true" PackagePath="/" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="System.Web" Condition="'$(TargetFramework)' == 'net461'" />
|
<Reference Include="System.Web" Condition="'$(TargetFramework)' == 'net461'" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="SKIT.FlurlHttpClient.Common" Version="2.1.1" />
|
<PackageReference Include="SKIT.FlurlHttpClient.Common" Version="2.2.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -10,7 +10,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Ads.Utilities
|
|||||||
public static class MD5Utility
|
public static class MD5Utility
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取信息摘要。
|
/// 获取 MD5 信息摘要。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="bytes">信息字节数组。</param>
|
/// <param name="bytes">信息字节数组。</param>
|
||||||
/// <returns>信息摘要。</returns>
|
/// <returns>信息摘要。</returns>
|
||||||
@ -24,7 +24,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Ads.Utilities
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取信息摘要。
|
/// 获取 MD5 信息摘要。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="message">文本信息。</param>
|
/// <param name="message">文本信息。</param>
|
||||||
/// <returns>信息摘要。</returns>
|
/// <returns>信息摘要。</returns>
|
||||||
|
@ -1,8 +1,11 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFrameworks>netcoreapp3.1; net6.0</TargetFrameworks>
|
<TargetFrameworks>net472; netcoreapp3.1; net6.0</TargetFrameworks>
|
||||||
<LangVersion>9.0</LangVersion>
|
<LangVersion>latest</LangVersion>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
<NullableReferenceTypes>true</NullableReferenceTypes>
|
||||||
|
<IsPackable>false</IsPackable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -0,0 +1,57 @@
|
|||||||
|
using System.IO;
|
||||||
|
using System.Reflection;
|
||||||
|
using Xunit;
|
||||||
|
|
||||||
|
namespace SKIT.FlurlHttpClient.Wechat.Ads.UnitTests
|
||||||
|
{
|
||||||
|
public class TestCase_CodeReviewAnalyzer
|
||||||
|
{
|
||||||
|
private Assembly SourceAssembly { get; } = Assembly.Load("SKIT.FlurlHttpClient.Wechat.Ads");
|
||||||
|
|
||||||
|
[Fact(DisplayName = "代码评审:分析 API 模型命名")]
|
||||||
|
public void TestApiModelsNaming()
|
||||||
|
{
|
||||||
|
CodeStyleUtil.VerifyApiModelsNaming(SourceAssembly, out var ex);
|
||||||
|
|
||||||
|
if (ex != null)
|
||||||
|
throw ex;
|
||||||
|
|
||||||
|
Assert.Null(ex);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact(DisplayName = "代码评审:分析 API 模型定义")]
|
||||||
|
public void TestApiModelsDefinition()
|
||||||
|
{
|
||||||
|
string workdir = Path.Combine(TestConfigs.ProjectTestDirectory, "ModelSamples");
|
||||||
|
CodeStyleUtil.VerifyApiModelsDefinition(SourceAssembly, workdir, out var ex);
|
||||||
|
|
||||||
|
if (ex != null)
|
||||||
|
throw ex;
|
||||||
|
|
||||||
|
Assert.Null(ex);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact(DisplayName = "代码评审:分析 API 接口命名")]
|
||||||
|
public void TestApiExtensionsNaming()
|
||||||
|
{
|
||||||
|
CodeStyleUtil.VerifyApiExtensionsNaming(SourceAssembly, out var ex);
|
||||||
|
|
||||||
|
if (ex != null)
|
||||||
|
throw ex;
|
||||||
|
|
||||||
|
Assert.Null(ex);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact(DisplayName = "代码评审:分析代码规范")]
|
||||||
|
public void TestCodeStyle()
|
||||||
|
{
|
||||||
|
string workdir = Path.Combine(TestConfigs.ProjectSourceDirectory);
|
||||||
|
CodeStyleUtil.VerifySourceCodeStyle(workdir, out var ex);
|
||||||
|
|
||||||
|
if (ex != null)
|
||||||
|
throw ex;
|
||||||
|
|
||||||
|
Assert.Null(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,17 +1,11 @@
|
|||||||
using System;
|
using Xunit;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Xunit;
|
|
||||||
|
|
||||||
namespace SKIT.FlurlHttpClient.Wechat.Ads.UnitTests
|
namespace SKIT.FlurlHttpClient.Wechat.Ads.UnitTests
|
||||||
{
|
{
|
||||||
public class WechatAdsSecurityTests
|
public class TestCase_HashUtilityTests
|
||||||
{
|
{
|
||||||
[Fact(DisplayName = "信息摘要(MD5)")]
|
[Fact(DisplayName = "测试用例:MD5 信息摘要")]
|
||||||
public void Md5HashTest()
|
public void TestMD5Hash()
|
||||||
{
|
{
|
||||||
string rawData = "spidbff89d5138160943040012345678901234567890uFolxxiZbrZ/PRbyen5uK5D1kgIB2yHyDsfDGxxgeG";
|
string rawData = "spidbff89d5138160943040012345678901234567890uFolxxiZbrZ/PRbyen5uK5D1kgIB2yHyDsfDGxxgeG";
|
||||||
|
|
@ -1,6 +1,4 @@
|
|||||||
using System;
|
namespace SKIT.FlurlHttpClient.Wechat.Ads.UnitTests
|
||||||
|
|
||||||
namespace SKIT.FlurlHttpClient.Wechat.Ads.UnitTests
|
|
||||||
{
|
{
|
||||||
class TestClients
|
class TestClients
|
||||||
{
|
{
|
||||||
|
@ -8,8 +8,9 @@ namespace SKIT.FlurlHttpClient.Wechat.Ads.UnitTests
|
|||||||
{
|
{
|
||||||
static TestConfigs()
|
static TestConfigs()
|
||||||
{
|
{
|
||||||
// NOTICE: 请在项目根目录下按照 appsettings.json 的格式新建 appsettings.local.json 填入测试参数。
|
// NOTICE: 请在项目根目录下按照 appsettings.json 的格式新建 appsettings.local.json 填入测试参数。
|
||||||
// WARN: 敏感信息请不要提交到 git!
|
// WARNING: 请在 DEBUG 模式下运行测试用例。
|
||||||
|
// WARNING: 敏感信息请不要提交到 git!
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -17,13 +18,13 @@ namespace SKIT.FlurlHttpClient.Wechat.Ads.UnitTests
|
|||||||
using var jdoc = JsonDocument.Parse(stream);
|
using var jdoc = JsonDocument.Parse(stream);
|
||||||
|
|
||||||
var config = jdoc.RootElement.GetProperty("TestConfig");
|
var config = jdoc.RootElement.GetProperty("TestConfig");
|
||||||
WechatAgencyId = config.GetProperty("AgencyId").GetString();
|
WechatAgencyId = config.GetProperty("AgencyId").GetString()!;
|
||||||
WechatAgencyAppId = config.GetProperty("AgencyAppId").GetString();
|
WechatAgencyAppId = config.GetProperty("AgencyAppId").GetString()!;
|
||||||
WechatAgencyApiKey = config.GetProperty("AgencyApiKey").GetString();
|
WechatAgencyApiKey = config.GetProperty("AgencyApiKey").GetString()!;
|
||||||
WechatAccessToken = config.GetProperty("AccessToken").GetString();
|
WechatAccessToken = config.GetProperty("AccessToken").GetString()!;
|
||||||
|
|
||||||
ProjectSourceDirectory = jdoc.RootElement.GetProperty("ProjectSourceDirectory").GetString();
|
ProjectSourceDirectory = jdoc.RootElement.GetProperty("ProjectSourceDirectory").GetString()!;
|
||||||
ProjectTestDirectory = jdoc.RootElement.GetProperty("ProjectTestDirectory").GetString();
|
ProjectTestDirectory = jdoc.RootElement.GetProperty("ProjectTestDirectory").GetString()!;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
@ -1,62 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Reflection;
|
|
||||||
using System.Threading;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Xunit;
|
|
||||||
|
|
||||||
namespace SKIT.FlurlHttpClient.Wechat.Ads.UnitTests
|
|
||||||
{
|
|
||||||
public class WechatAdsDeclarationTests
|
|
||||||
{
|
|
||||||
private static readonly Assembly _assembly = Assembly.Load("SKIT.FlurlHttpClient.Wechat.Ads");
|
|
||||||
|
|
||||||
[Fact(DisplayName = "验证 API 模型命名")]
|
|
||||||
public void ApiModelsNamingTest()
|
|
||||||
{
|
|
||||||
CodeStyleUtil.VerifyApiModelsNaming(_assembly, out var ex);
|
|
||||||
|
|
||||||
if (ex != null)
|
|
||||||
throw ex;
|
|
||||||
|
|
||||||
Assert.Null(ex);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Fact(DisplayName = "验证 API 模型定义")]
|
|
||||||
public void ApiModelsDefinitionTest()
|
|
||||||
{
|
|
||||||
string workdir = Path.Combine(TestConfigs.ProjectTestDirectory, "ModelSamples");
|
|
||||||
CodeStyleUtil.VerifyApiModelsDefinition(_assembly, workdir, out var ex);
|
|
||||||
|
|
||||||
if (ex != null)
|
|
||||||
throw ex;
|
|
||||||
|
|
||||||
Assert.Null(ex);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Fact(DisplayName = "验证 API 接口命名")]
|
|
||||||
public void ApiExtensionsNamingTest()
|
|
||||||
{
|
|
||||||
CodeStyleUtil.VerifyApiExtensionsNaming(_assembly, out var ex);
|
|
||||||
|
|
||||||
if (ex != null)
|
|
||||||
throw ex;
|
|
||||||
|
|
||||||
Assert.Null(ex);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Fact(DisplayName = "验证代码规范")]
|
|
||||||
public void CodeStyleTest()
|
|
||||||
{
|
|
||||||
string workdir = Path.Combine(TestConfigs.ProjectSourceDirectory);
|
|
||||||
CodeStyleUtil.VerifySourceCodeStyle(workdir, out var ex);
|
|
||||||
|
|
||||||
if (ex != null)
|
|
||||||
throw ex;
|
|
||||||
|
|
||||||
Assert.Null(ex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -7,7 +7,7 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="SKIT.FlurlHttpClient.Common" Version="2.1.1" />
|
<PackageReference Include="SKIT.FlurlHttpClient.Common" Version="2.2.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
Loading…
Reference in New Issue
Block a user