easyabp / abp.wechat Goto Github PK
View Code? Open in Web Editor NEWAbp 微信 SDK 模块,包含对微信小程序、公众号、企业微信、开放平台、第三方平台等相关接口封装。
License: MIT License
Abp 微信 SDK 模块,包含对微信小程序、公众号、企业微信、开放平台、第三方平台等相关接口封装。
License: MIT License
微信回调时需要签名验证,而微信不会携带租户信息(实际上用户可能自定义甚至无关租户的mchid,比如EShop的多商户场景),因此需要做处理,考虑注册机制。
例如:注册表默认由内存提供,如果开发者想严格多租户或者用其他方式例如缓存和sql,他可以替换实现。在微信回调时从注册表匹配配置,方便签名验证。
关联:#3
是否支持在后台返回客户端需要的签名及相关参数呢,比如多租户情况下,一个后台支撑N个相同的小程序时,这样就不用每个小程序都配置
请求中的notify url配置没有正确赋值
Hello,
我没有在nuget找到EasyAbp.Abp.WeChat.Official这个包,请问一下是否已发布nuget包?
以下是你的配置实例:
1.2 模块的配置
微信模块的配置参数都存放在 AbpWeChatMiniProgramOptions 内部,开发人员只需要在启动模块的 ConfigureService() 方法中进行配置即可,下面是最小启动配置。
[DependsOn(typeof(AbpWeChatMiniProgramHttpApiModule))]
public class XXXHttpApiModule : AbpModule
{
public override void ConfigureServices(ServiceConfigurationContext context)
{
Configure(op =>
{
// 微信小程序所配置的 Token 值。
op.Token = "0000000000";
// 微信小程序分配的 AppId。
op.AppId = "0000000000";
// 微信小程序的唯一密钥。
op.AppSecret = "0000000000";
});
}
}
在easyabp.eshop中,使用微信小程序支付成功,微信回调支付通知接口302,无其它任何日志信息
@GameBelial 你怎么看?
当证书未设置,请求被微信拒绝,返回的xml不能被识别导致报错
2023-04-17 16:14:44.518 +08:00 [INF] Request starting HTTP/1.1 POST https://test-youdian-api.gejinet.com/wechat-pay/notify text/xml 834
2023-04-17 16:14:44.519 +08:00 [INF] Executing endpoint 'EasyAbp.Abp.WeChat.Pay.Controller.WeChatPayController.NotifyAsync (EasyAbp.Abp.WeChat.Pay.HttpApi)'
2023-04-17 16:14:44.520 +08:00 [INF] Route matched with {area = "easyAbpAbpWeChat", controller = "WeChatPay", action = "Notify", page = ""}. Executing controller action with signature System.Threading.Tasks.Task1[Microsoft.AspNetCore.Mvc.ActionResult] NotifyAsync(System.String, System.String) on controller EasyAbp.Abp.WeChat.Pay.Controller.WeChatPayController (EasyAbp.Abp.WeChat.Pay.HttpApi). 2023-04-17 16:14:44.522 +08:00 [ERR] The input data is not a complete block. System.Security.Cryptography.CryptographicException: The input data is not a complete block. at System.Security.Cryptography.UniversalCryptoDecryptor.UncheckedTransformFinalBlock(ReadOnlySpan
1 inputBuffer, Span1 outputBuffer) at System.Security.Cryptography.UniversalCryptoDecryptor.UncheckedTransformFinalBlock(Byte[] inputBuffer, Int32 inputOffset, Int32 inputCount) at System.Security.Cryptography.UniversalCryptoTransform.TransformFinalBlock(Byte[] inputBuffer, Int32 inputOffset, Int32 inputCount) at System.Security.Cryptography.CryptoStream.ReadAsyncCore(Memory
1 buffer, CancellationToken cancellationToken, Boolean useAsync)
at Volo.Abp.Security.Encryption.StringEncryptionService.Decrypt(String cipherText, String passPhrase, Byte[] salt)
at Volo.Abp.Settings.SettingEncryptionService.Decrypt(SettingDefinition settingDefinition, String encryptedValue)
我看了下,2.0.0版本,已经没有这个接口了。
看源码中,现在好像是用 IAbpWeChatOptionsProvider 来实现多个小程序的生效?
您好!
我的Abp vNext 框架项目中引用 EasyAbp.Abp.Wechat.Official v2.3.0。
Api version 7.0.1
我在*.Domain项目中引用 EasyAbp.Abp.Wechat.Official,在 *.Application 项目中新建了 实现 IAbpWeChatSharableCache 抽象类的中 GetOrNullAsync() 和 SetAsync() 方法。
这是我的代码。
public class EasyAbpWechatAccesstokenCache : IAbpWeChatSharableCache, ITransientDependency
{
public async Task<string> GetOrNullAsync(string key)
{
return "";
}
public async Task SetAsync(string key, string value, DistributedCacheEntryOptions options)
{
throw new Exception();
}
}
期望的结果:在获取微信的access_token时,优先调用 EasyAbpWechatAccesstokenCache.GetOrNullAsync() 而不是 DefaultAbpWeChatSharableCache.GetOrNullAsync()
请指导。
NetCore Version: 6.0.0
Abp Version: 6.0.0
EasyAbp.Abp.WeChat.MiniProgram Version: 2.1.0
EasyAbp.Abp.WeChat.OfficialVersion: 2.1.0
但在2.0以下版本,如 1.11.0 注入任何服务都没有问题。
namespace AuthServer.Domain;
public class MiniProgramDomainService : IDomainService
{
/// <summary>
/// [公众号] 微信用户登录服务
/// </summary>
protected readonly EasyAbp.Abp.WeChat.Official.Services.Login.LoginWeService _loginService;
/// <summary>
/// 构造函数注入服务
/// </summary>
/// <param name="login"></param>
/// <param name="miniLogin"></param>
public MiniProgramDomainService(
EasyAbp.Abp.WeChat.Official.Services.Login.LoginWeService login)
{
_loginService = login;
}
}
namespace AuthServer.Application;
public class LoginAppService : ApplicationService, ILoginAppService
{
protected readonly MiniProgramDomainService _miniProgram;
public LoginAppService(MiniProgramDomainService miniProgram)
{
_miniProgram = miniProgram;
}
}
当调用 LoginAppService 中任一接口时,都会报错。
证书目前采用物理路径,对于多租户甚至更复杂场景,物理路径不能很好的支持,因为系统管理员不会帮每个人上传证书到物理路径中。
考虑对接abp的二进制文件存储管理:https://docs.abp.io/en/abp/latest/Blob-Storing
请问支持这个功能吗?
如题
我认为有两种设计思路:
@GameBelial @wakuflair 你们怎么看?
目前写死了IOption的配置来源
异常信息
An exception was thrown while activating EasyAbp.Abp.WeChat.Official.ApiRequests.DefaultWeChatOfficialApiRequester -> EasyAbp.Abp.WeChat.Common.Infrastructure.AccessToken.DefaultAccessTokenProvider -> Xzkj.Hhcx.Distribution.AbpWeChatSharableCacheImplementation.
我的源代码
using EasyAbp.Abp.WeChat.Official.Options;
using EasyAbp.Abp.WeChat.Official.Services;
using System.Net.Http;
using System.Threading.Tasks;
using Volo.Abp.DependencyInjection;
using Xzkj.Hhcx.Distribution.WechatOfficialExtensions.QrCode.Request;
using Xzkj.Hhcx.Distribution.WechatOfficialExtensions.QrCode.Response;
namespace Xzkj.Hhcx.Distribution.WechatOfficialExtensions.QrCode;
/// <summary>
/// 微信 QRCode 服务
/// </summary>
public class QrCodeService : OfficialAbpWeChatServiceBase
{
/// <summary>
/// 创建二维码
/// </summary>
const string CreateQrCodeApiUrl = "https://api.weixin.qq.com/cgi-bin/qrcode/create?";
public QrCodeService(AbpWeChatOfficialOptions options, IAbpLazyServiceProvider lazyServiceProvider) : base(options, lazyServiceProvider)
{
}
/// <summary>
/// 创建QrCode
/// </summary>
/// <param name="actionName"></param>
/// <param name="id"></param>
/// <param name="expireSeconds"></param>
/// <returns></returns>
public Task<CreateQrCodeResponse> CreateQrCodeAsync(EnumQrCodeCreateActionName actionName, int id, int expireSeconds = 60)
{
return ApiRequester.RequestAsync<CreateQrCodeResponse>(
CreateQrCodeApiUrl,
HttpMethod.Post,
new CreateQrCodeSceneIdRequest(actionName, id, expireSeconds),
Options
);
}
/// <summary>
/// 创建QrCode
/// </summary>
/// <param name="actionName"></param>
/// <param name="str"></param>
/// <param name="expireSeconds"></param>
/// <returns></returns>
public Task<CreateQrCodeResponse> CreateQrCodeAsync(EnumQrCodeCreateActionName actionName, string str, int expireSeconds = 60)
{
return ApiRequester.RequestAsync<CreateQrCodeResponse>(
CreateQrCodeApiUrl,
HttpMethod.Post,
new CreateQrCodeSceneStrRequest(actionName, str, expireSeconds),
Options
);
}
}
我的调用方式(略写)
readonly IAbpWeChatServiceFactory _wechatFactory
// ···
var qrCodeService = await _wechatFactory.CreateAsync<QrCodeService>();
var qrCoreCreate = await qrCodeService.CreateQrCodeAsync(actionName: EnumQrCodeCreateActionName.QR_LIMIT_STR_SCENE, "1," + dir.UserId.ToString());
每个租户如果拥有不同的公众号的话,能否考虑将公众号的Options 不定死, 放到settings里面获取
如果handler对订单处理失败(或过程抛错),应对微信服务器返回“失败”信息,要求微信服务器重新通知,而不是永远返回“成功”。
是否可以扩展配置指定redis缓存地址及缓存key进行token的存储和读取?
Abp.WeChat/src/Pay/EasyAbp.Abp.WeChat.Pay/Services/WeChatPayServiceBase.cs
protected virtual Task RequestAndGetReturnValueAsync(
此处判断
if (result.SelectSingleNode("/xml/return_code")?.InnerText != "SUCCESS" ||
result.SelectSingleNode("/xml/return_msg")?.InnerText != "OK")
建议改为
if (result.SelectSingleNode("/xml/return_code")?.InnerText != "SUCCESS" ||
result.SelectSingleNode("/xml/result_code")?.InnerText != "SUCCESS")
因为部分api 的return_msg 为空
例如:企业付款api https://api.mch.weixin.qq.com/mmpaymkttransfers/promotion/transfers
https://pay.weixin.qq.com/wiki/doc/api/wxa/wxa_api.php?chapter=9_16&index=10#menu1
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.