Zongsoft.Externals.Wechat
7.8.0
See the version list below for details.
dotnet add package Zongsoft.Externals.Wechat --version 7.8.0
NuGet\Install-Package Zongsoft.Externals.Wechat -Version 7.8.0
<PackageReference Include="Zongsoft.Externals.Wechat" Version="7.8.0" />
<PackageVersion Include="Zongsoft.Externals.Wechat" Version="7.8.0" />
<PackageReference Include="Zongsoft.Externals.Wechat" />
paket add Zongsoft.Externals.Wechat --version 7.8.0
#r "nuget: Zongsoft.Externals.Wechat, 7.8.0"
#:package Zongsoft.Externals.Wechat@7.8.0
#addin nuget:?package=Zongsoft.Externals.Wechat&version=7.8.0
#tool nuget:?package=Zongsoft.Externals.Wechat&version=7.8.0
Zongsoft.Externals.Wechat Extension Plugin Library
Current capabilities and limitations
This library provides selected REST wrappers for mini program login and phone-number exchange, official account OAuth and template messages, payments, and refunds. Payment implementations include both APIv3 and APIv2/XML paths; this is not a complete SDK for all WeChat products.
The payment HTTP client signs outgoing requests but does not verify response signatures. The default callback gateway dispatches requests and the payment callback handler decrypts resources. This pipeline does not validate notification signatures, timestamp windows, or business idempotency. The host must verify notifications before they enter the pipeline and validate order ownership and amounts during business processing.
The Web API login and credential endpoints include WeChat session or access credentials and must not be exposed directly as login endpoints for untrusted clients. Hosts must restrict these endpoints and transform their responses. Mini program session_key values must remain on the server.
The third-party platform authorization flow below is a platform reference. The library does not provide complete services for receiving verification tickets or managing component and authorizer tokens.
WeChat Third-Party Platform
Concepts
Third-party platform application
component_appidThird-party platform secret
component_appsecretEncryption and decryption keys
symmetric_key,AESEncodingKeyPlatform access token
component_access_token- The credential used to call third-party platform APIs. The token is valid for
2hours. Refresh it before it expires, for example at about1hour and50minutes. - Reference: https://developers.weixin.qq.com/doc/oplatform/openApi/ticket-token/api_getcomponentaccesstoken.html
- The credential used to call third-party platform APIs. The token is valid for
Platform verify ticket
component_verify_ticket- After a third-party platform is created and approved, the WeChat server sends the verify ticket to its authorization event receiving URL by
POSTevery 10 minutes. The third-party platform must verify the message signature, decrypt and store the ticket, then return the stringsuccess. - Reference: https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/Before_Develop/component_verify_ticket.html
- After a third-party platform is created and approved, the WeChat server sends the verify ticket to its authorization event receiving URL by
Authorization Flow
- Wait for the
component_verify_ticketcallback pushed by WeChat. - Get or asynchronously refresh the platform access token
component_access_token. - Use the platform access token to get the pre-authorization code
pre_auth_code. - Generate two authorization page URLs from the pre-authorization code.
- Scan page: https://mp.weixin.qq.com/cgi-bin/componentloginpage?component_appid=xxxx&pre_auth_code=xxxxx&redirect_uri=xxxx&auth_type=xxx
- WeChat share: https://mp.weixin.qq.com/safe/bindcomponent?action=bindcomponent&no_scan=1&component_appid=xxxx&pre_auth_code=xxxxx&redirect_uri=xxxx&auth_type=xxx&biz_appid=xxxx#wechat_redirect
- After the user authorizes, WeChat pushes a callback. Read the authorization binding information in that callback.
Use https://developers.weixin.qq.com/doc/oplatform/openApi/ticket-token/api_getauthorizerrefreshtoken.html to obtain
authorizer_appid,authorizer_access_token, andauthorizer_refresh_token. - Periodically refresh the authorizer access credential.
References
Regular merchant documentation center
Service provider documentation center
Official WeChat Pay SDKs and tools
API certificate
Tools
WeChat Pay API verification script for Postman
WeChat Pay signing, signature verification, encryption, and decryption tools
https://pay.weixin.qq.com/wiki/doc/apiv3/wechatpay/download/Product_5.zip
WeChat Pay certificate tool
Plugin-Based Integration
Compose this feature through the host; a package reference supplies compile-time APIs, while plugin loading also requires deployed manifests and runtime assets. See the complete plugin workflow.
The manifest exposes the Wechat components and services. Keep account, certificate and payment settings under application-owned options. API and callback gateway plugins are optional, separate host contributions.
| Runtime artifact | Source of truth |
|---|---|
Zongsoft.Externals.Wechat |
Zongsoft.Externals.Wechat.plugin |
| File copying and dependencies | Zongsoft.Externals.Wechat.deploy |
Add this fragment to an existing host .deploy (retain Main and the host’s other base manifests; do not replace the whole file):
[plugins zongsoft externals wechat]
nuget:Zongsoft.Externals.Wechat
Run dotnet deploy against a test deployment as explained in the workflow, with the host's framework, platform, architecture and, where needed, site. Pin compatible versions in real deployments; application dependencies such as databases, caches or commercial runtimes are still separate prerequisites.
Additional artifacts listed by the deployment manifest include Zongsoft.Externals.Wechat.plugin, Zongsoft.Externals.Wechat.option. Retain assemblies, dependencies and satellite resource directories as well. Restart the host after deployment, check plugin loading and service/driver registration, then verify the workflow above; copied files alone do not prove that the feature is active.
Publishing
Set NUGET_API_KEY and use the Release pack task. The --project option selects a project or solution. Publish the main package first, wait until it is available from NuGet, and then publish the API and gateway packages that reference it:
dotnet cake build.cake --target=pack --edition=Release --project=src/Zongsoft.Externals.Wechat.csproj
dotnet cake build.cake --target=pack --edition=Release --project=api/Zongsoft.Externals.Wechat.Web.csproj
dotnet cake build.cake --target=pack --edition=Release --project=gateway/Zongsoft.Externals.Wechat.Gateway.csproj
Without --project, the task builds the complete solution.
Account lookup
Implement IAccountProvider.GetAccountAsync to supply dynamic accounts. Use await AppletManager.GetAppletAsync(code, cancellation) or await ChannelManager.GetChannelAsync(code, cancellation) to obtain an applet or channel. Use FindAppletAsync or FindChannelAsync and check for null when absence is allowed. Lookups support cancellation and reuse existing instances.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Microsoft.Extensions.Configuration.Abstractions (>= 10.0.0)
- Microsoft.Extensions.Http (>= 10.0.0)
- Portable.BouncyCastle (>= 1.9.0)
- Zongsoft.Core (>= 7.70.0)
-
net8.0
- Microsoft.Extensions.Configuration.Abstractions (>= 8.0.0)
- Microsoft.Extensions.Http (>= 8.0.1)
- Portable.BouncyCastle (>= 1.9.0)
- Zongsoft.Core (>= 7.70.0)
-
net9.0
- Microsoft.Extensions.Configuration.Abstractions (>= 9.0.2)
- Microsoft.Extensions.Http (>= 9.0.2)
- Portable.BouncyCastle (>= 1.9.0)
- Zongsoft.Core (>= 7.70.0)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on Zongsoft.Externals.Wechat:
| Package | Downloads |
|---|---|
|
Zongsoft.Externals.Wechat.Web
This is a web api library about Wechat. |
|
|
Zongsoft.Externals.Wechat.Gateway
This is a library about Wechat Gateway. |
GitHub repositories
This package is not used by any popular GitHub repositories.