Skip to content

Commit

Permalink
Merge pull request #3066 from JeffreySu/Developer
Browse files Browse the repository at this point in the history
更新微信支付 V3 Sample
  • Loading branch information
JeffreySu authored Sep 5, 2024
2 parents 45fe075 + da68cb2 commit 6b1879a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -338,10 +338,10 @@ public async Task<IActionResult> PayNotifyUrl()
{
//获取微信服务器异步发送的支付通知信息
var resHandler = new TenPayNotifyHandler(HttpContext);
var orderReturnJson = await resHandler.AesGcmDecryptGetObjectAsync<OrderReturnJson>();
var orderReturnJson = await resHandler.DecryptGetObjectAsync<OrderReturnJson>();

//记录日志
Senparc.Weixin.WeixinTrace.SendCustomLog("PayNotifyUrl 接收到消息", orderReturnJson.ToJson(true));
Senparc.Weixin.WeixinTrace.SendCustomLog("PayNotifyUrl 接收到消息(ApiV3)", orderReturnJson.ToJson(true));

//演示记录 transaction_id,实际开发中需要记录到数据库,以便退款和后续跟踪
TradeNumberToTransactionId[orderReturnJson.out_trade_no] = orderReturnJson.transaction_id;
Expand Down Expand Up @@ -389,13 +389,13 @@ public async Task<IActionResult> PayNotifyUrl()

#region 记录日志(也可以记录到数据库审计日志中)

var logDir = ServerUtility.ContentRootMapPath(string.Format("~/App_Data/TenPayNotify/{0}", SystemTime.Now.ToString("yyyyMMdd")));
var logDir = ServerUtility.ContentRootMapPath(string.Format("~/App_Data/TenPayNotify/ApiV3{0}", SystemTime.Now.ToString("yyyyMMdd")));
if (!Directory.Exists(logDir))
{
Directory.CreateDirectory(logDir);
}

var logPath = Path.Combine(logDir, string.Format("{0}-{1}-{2}.txt", SystemTime.Now.ToString("yyyyMMdd"), SystemTime.Now.ToString("HHmmss"), Guid.NewGuid().ToString("n").Substring(0, 8)));
var logPath = Path.Combine(logDir, string.Format("ApiV3-{0}-{1}-{2}.txt", SystemTime.Now.ToString("yyyyMMdd"), SystemTime.Now.ToString("HHmmss"), Guid.NewGuid().ToString("n").Substring(0, 8)));

using (var fileStream = System.IO.File.OpenWrite(logPath))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Version>6.11.2</Version>
<Version>6.11.3</Version>
<ImplicitUsings>enable</ImplicitUsings>
<UserSecretsId>35e58786-0820-4cde-b1ff-f4c6198d00f7</UserSecretsId>
<PublishWithAspNetCoreTargetManifest>false</PublishWithAspNetCoreTargetManifest>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
//如果不设置TenPayV3_WxOpenTenpayNotify,默认在 TenPayV3_TenpayNotify 的值最后加上 "WxOpen"
"TenPayV3_WxOpenTenpayNotify": "#{TenPayV3_WxOpenTenpayNotify}#", //http://YourDomainName/TenpayV3/PayNotifyUrlWxOpen

"EncryptionType": "#{EncryptionType}#", // 加密类型:RSA / SM
"EncryptionType": "#{EncryptionType}#", // 加密类型:RSA / SM(必填,根据后台申请证书类型选择,大部分情况为 RSA)

//开放平台
"Component_Appid": "#{Component_Appid}#",
Expand Down

0 comments on commit 6b1879a

Please sign in to comment.