版本是.NET 7.0.5,不知道注册的对不对
注册
//启用微信配置(一句代码)
var registerService = app.UseSenparcWeixin(app.Environment,
null /* 不为 null 则覆盖 appsettings 中的 SenpacSetting 配置*/,
null /* 不为 null 则覆盖 appsettings 中的 SenpacWeixinSetting 配置*/,
register => { /* CO2NET 全局配置 */ },
(register, weixinSetting) =>
{
//注册小程序信息(可以执行多次,注册多个小程序)
register.RegisterWxOpenAccount(weixinSetting, "第一个小程序");
register.RegisterWxOpenAccount(weixinSetting.Items["第二个小程序"], "第二个小程序");
//注册微信支付(可以执行多次,注册多个微信支付)
register.RegisterTenpayApiV3(weixinSetting, "第一个小程序");//记录到同一个 SenparcWeixinSettingItem 对象中
register.RegisterTenpayApiV3(weixinSetting.Items["第二个小程序"], "第二个小程序");//记录到同一个 SenparcWeixinSettingItem 对象中
});
配置
//Senparc.Weixin SDK 设置
"SenparcWeixinSetting": {
//以下为 Senparc.Weixin 的 SenparcWeixinSetting 微信配置
//注意:所有的字符串值都可能被用于字典索引,因此请勿留空字符串(但可以根据需要,删除对应的整条设置)!
//微信全局
"IsDebug": true,
//以下不使用的参数可以删除,key 修改后将会失效
//小程序
"WxOpenAppId": "1111111111111111111",
"WxOpenAppSecret": "1111111111111111111",
"WxOpenToken": "1111111111111111111",
"WxOpenEncodingAESKey": "1111111111111111111",
//微信支付V3
"TenPayV3_AppId": "1111111111111111111",
"TenPayV3_AppSecret": "1111111111111111111",
"TenPayV3_SubAppId": "#{TenPayV3_SubAppId}#",
"TenPayV3_SubAppSecret": "#{TenPayV3_SubAppSecret}#",
"TenPayV3_MchId": "1111111111111111111",
"TenPayV3_SubMchId": "#{TenPayV3_SubMchId}#", //子商户,没有可留空
"TenPayV3_Key": "#{TenPayV3_Key}#",
"TenPayV3_TenpayNotify": "#{TenPayV3_TenpayNotify}#", //https://YourDomainName/TenpayApiV3/PayNotifyUrl
"TenPayV3_PrivateKey": "#{TenPayV3_PrivateKey}#", //(新)证书私钥
"TenPayV3_SerialNumber": "#{TenPayV3_SerialNumber}#", //(新)证书序列号
"TenPayV3_ApiV3Key": "#{TenPayV3_APIv3Key}#", //(新)APIv3 密钥
//以下Items中的内容根据实际情况使用
//Items 下面可以添加任意多个公众号、小程序、企业微信、微信支付(V2/V3)、开放平台的信息
"Items": {
"第二个小程序": {
//公众号
"WxOpenAppId": "2222222222222222222222222",
"WxOpenAppSecret": "2222222222222222222222222",
"WxOpenToken": "2222222222222222222222222",
"WxOpenEncodingAESKey": "2222222222222222222222222",
//微信支付V3(新版),略
"TenPayV3_AppId": "2222222222222222222222222",
"TenPayV3_AppSecret": "2222222222222222222222222",
"TenPayV3_SubAppId": "#{TenPayV3_SubAppId}#",
"TenPayV3_SubAppSecret": "#{TenPayV3_SubAppSecret}#",
"TenPayV3_MchId": "2222222222222222222222222",
"TenPayV3_SubMchId": "#{TenPayV3_SubMchId}#", //子商户,没有可留空
"TenPayV3_Key": "#{TenPayV3_Key}#",
"TenPayV3_TenpayNotify": "#{TenPayV3_TenpayNotify}#", //https://YourDomainName/TenpayApiV3/PayNotifyUrl
"TenPayV3_PrivateKey": "#{TenPayV3_PrivateKey}#", //(新)证书私钥
"TenPayV3_SerialNumber": "#{TenPayV3_SerialNumber}#", //(新)证书序列号
"TenPayV3_ApiV3Key": "#{TenPayV3_APIv3Key}#" //(新)APIv3 密钥
}
}
}
获取得时候是空的
var config1 = Config.SenparcWeixinSetting.Items["第一个小程序"];
var config2 = Config.SenparcWeixinSetting.Items["第二个小程序"];
{
"config1": {
"itemKey": "第一个小程序",
"token": null,
"encodingAESKey": null,
"weixinAppId": null,
"weixinAppSecret": null,
"wxOpenAppId": null,
"wxOpenAppSecret": null,
"wxOpenToken": null,
"wxOpenEncodingAESKey": null,
"weixinCorpId": null,
"weixinCorpAgentId": null,
"weixinCorpSecret": null,
"weixinCorpToken": null,
"weixinCorpEncodingAESKey": null,
"weixinPay_PartnerId": null,
"weixinPay_Key": null,
"weixinPay_AppId": null,
"weixinPay_AppKey": null,
"weixinPay_TenpayNotify": null,
"tenPayV3_MchId": "1111111111111111111",
"tenPayV3_SubMchId": "#{TenPayV3_SubMchId}#",
"tenPayV3_Key": "#{TenPayV3_Key}#",
"tenPayV3_CertPath": null,
"tenPayV3_CertSecret": null,
"tenPayV3_AppId": "1111111111111111111",
"tenPayV3_AppSecret": "1111111111111111111",
"tenPayV3_SubAppId": "#{TenPayV3_SubAppId}#",
"tenPayV3_SubAppSecret": "#{TenPayV3_SubAppSecret}#",
"tenPayV3_TenpayNotify": "#{TenPayV3_TenpayNotify}#",
"tenPayV3_PrivateKey": "#{TenPayV3_PrivateKey}#",
"tenPayV3_SerialNumber": "#{TenPayV3_SerialNumber}#",
"tenPayV3_APIv3Key": "#{TenPayV3_APIv3Key}#",
"tenPayV3_WxOpenTenpayNotify": null,
"component_Appid": null,
"component_Secret": null,
"component_Token": null,
"component_EncodingAESKey": null,
"agentUrl": null,
"agentToken": null,
"senparcWechatAgentKey": null
},
"config2": {
"itemKey": "第二个小程序",
"token": null,
"encodingAESKey": null,
"weixinAppId": null,
"weixinAppSecret": null,
"wxOpenAppId": null,
"wxOpenAppSecret": null,
"wxOpenToken": null,
"wxOpenEncodingAESKey": null,
"weixinCorpId": null,
"weixinCorpAgentId": null,
"weixinCorpSecret": null,
"weixinCorpToken": null,
"weixinCorpEncodingAESKey": null,
"weixinPay_PartnerId": null,
"weixinPay_Key": null,
"weixinPay_AppId": null,
"weixinPay_AppKey": null,
"weixinPay_TenpayNotify": null,
"tenPayV3_MchId": null,
"tenPayV3_SubMchId": null,
"tenPayV3_Key": null,
"tenPayV3_CertPath": null,
"tenPayV3_CertSecret": null,
"tenPayV3_AppId": null,
"tenPayV3_AppSecret": null,
"tenPayV3_SubAppId": null,
"tenPayV3_SubAppSecret": null,
"tenPayV3_TenpayNotify": null,
"tenPayV3_PrivateKey": null,
"tenPayV3_SerialNumber": null,
"tenPayV3_APIv3Key": null,
"tenPayV3_WxOpenTenpayNotify": null,
"component_Appid": null,
"component_Secret": null,
"component_Token": null,
"component_EncodingAESKey": null,
"agentUrl": null,
"agentToken": null,
"senparcWechatAgentKey": null
}
}