using Essensoft.AspNetCore.Payment.WeChatPay; using Essensoft.AspNetCore.Payment.WeChatPay.V3; using Essensoft.AspNetCore.Payment.WeChatPay.V3.Domain; using Essensoft.AspNetCore.Payment.WeChatPay.V3.Request; using Microsoft.Extensions.Options; using System; using System.Collections.Generic; using System.Linq; using System.Net.Http; using System.Threading.Tasks; namespace New_College.Common.Helper { public class WeChatPayV3 { /// /// 扫码支付-Native下单API /// /// /// /// /// public static async Task QrCodePay(IWeChatPayClient _client, IOptions _optionsAccessor, WeChatPayTransactionsNativeQuery viewModel) { var model = new WeChatPayTransactionsNativeBodyModel { AppId = _optionsAccessor.Value.AppId, MchId = _optionsAccessor.Value.MchId, Amount = new Essensoft.AspNetCore.Payment.WeChatPay.V3.Domain.Amount { Total = viewModel.Total, Currency = "CNY" }, Description = viewModel.Description, NotifyUrl = viewModel.NotifyUrl, OutTradeNo = viewModel.OutTradeNo, }; var request = new WeChatPayTransactionsNativeRequest(); request.SetBodyModel(model); return await _client.ExecuteAsync(request, _optionsAccessor.Value); } } }