docs: 提供微信商户平台模块的示例项目

This commit is contained in:
Fu Diwei
2021-07-30 14:09:25 +08:00
parent 0a5c049a53
commit b0c9187923
12 changed files with 284 additions and 2 deletions

View File

@@ -0,0 +1,38 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Sample_Net5.Controllers
{
[ApiController]
[Route("notify")]
public class WxpayNotifyController : ControllerBase
{
private readonly ILogger _logger;
public WxpayNotifyController(
ILoggerFactory loggerFactory)
{
_logger = loggerFactory.CreateLogger(GetType());
}
[HttpPost]
public async Task<IActionResult> ReceiveMessage()
{
// 接收服务器推送
// 文档https://pay.weixin.qq.com/wiki/doc/apiv3/wechatpay/wechatpay4_2.shtml
using var reader = new StreamReader(Request.Body, Encoding.UTF8);
string content = await reader.ReadToEndAsync();
_logger.LogInformation("接收到微信支付推送的数据:{0}", content);
return new JsonResult(new { code = "SUCCESS", message = "成功" });
}
}
}