General.Web/Controllers/API/WeChatPayController.cs
(开头部分) 18KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using System.Text.Json;
using System.Threading.Tasks;
using Essensoft.AspNetCore.Payment.WeChatPay;
using Essensoft.AspNetCore.Payment.WeChatPay.Request;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Options;
using General.Mvc.Models.Pay;
namespace General.Mvc.Controllers.API
{
public class WeChatPayController : Controller
{
private readonly IWeChatPayClient _client;
private readonly IOptions<WeChatPayOptions> _optionsAccessor;
public WeChatPayController(IWeChatPayClient client, IOptions<WeChatPayOptions> optionsAccessor)
{
_client = client;
_optionsAccessor = optionsAccessor;
}
/// <summary>
/// 微信支付指引页
/// </summary>
public IActionResult Index()
{
return View();
}
/// <summary>
/// 刷卡支付
/// </summary>
[HttpGet]
public IActionResult MicroPay()
{
return View();
}
/// <summary>
/// 刷卡支付
/// </summary>
/// <param name="viewModel"></param>
[HttpPost]
public async Task<IActionResult> MicroPay(WeChatPayMicroPayViewModel viewModel)
{
var request = new WeChatPayMicroPayRequest
{
Body = viewModel.Body,
OutTradeNo = viewModel.OutTradeNo,
TotalFee = viewModel.TotalFee,
SpBillCreateIp = viewModel.SpBillCreateIp,
AuthCode = viewModel.AuthCode
};
var response = await _client.ExecuteAsync(request, _optionsAccessor.Value);
ViewData["response"] = response.ResponseBody;
return View();
}
/// <summary>
/// 公众号支付
后面还有 524 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明
AI 解读
登录后可用,每次 10 积分,解读结果公开显示在下面。
还没有人解读过这个文件。
