调整支付接口-新增PC端扫码支付模块
parent
6b2ddf3b53
commit
0613556c99
|
|
@ -1,6 +1,7 @@
|
|||
using Essensoft.AspNetCore.Payment.WeChatPay;
|
||||
using Essensoft.AspNetCore.Payment.WeChatPay.Request;
|
||||
using Essensoft.AspNetCore.Payment.WeChatPay.Response;
|
||||
using Essensoft.AspNetCore.Payment.WeChatPay.V2;
|
||||
using Essensoft.AspNetCore.Payment.WeChatPay.V2.Request;
|
||||
using Essensoft.AspNetCore.Payment.WeChatPay.V2.Response;
|
||||
using Microsoft.Extensions.Options;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
|
|
|||
|
|
@ -38,6 +38,15 @@ namespace New_College.Common.Helper
|
|||
}
|
||||
|
||||
|
||||
public class WeChatPayTransactionsNativeQuery
|
||||
{
|
||||
public int? Total { get; set; }
|
||||
public string Description { get; set; }
|
||||
public string NotifyUrl { get; set; }
|
||||
public string OutTradeNo { get; set; }
|
||||
}
|
||||
|
||||
|
||||
public class ProductPayRequest
|
||||
{
|
||||
/// <summary>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,44 @@
|
|||
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
|
||||
{
|
||||
/// <summary>
|
||||
/// 扫码支付-Native下单API
|
||||
/// </summary>
|
||||
/// <param name="_client"></param>
|
||||
/// <param name="_optionsAccessor"></param>
|
||||
/// <param name="viewModel"></param>
|
||||
/// <returns></returns>
|
||||
public static async Task<dynamic> QrCodePay(IWeChatPayClient _client,
|
||||
IOptions<WeChatPayOptions> _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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -13,9 +13,9 @@
|
|||
<PackageReference Include="Aliyun.OSS.SDK.NetCore" Version="2.10.0" />
|
||||
<PackageReference Include="DingtalkChatbotSdk" Version="1.0.1" />
|
||||
<PackageReference Include="DinkToPdf.Standard" Version="1.1.0" />
|
||||
<PackageReference Include="Essensoft.AspNetCore.Payment.Alipay" Version="3.1.8" />
|
||||
<PackageReference Include="Essensoft.AspNetCore.Payment.Security" Version="3.1.8" />
|
||||
<PackageReference Include="Essensoft.AspNetCore.Payment.WeChatPay" Version="3.1.5" />
|
||||
<PackageReference Include="Essensoft.AspNetCore.Payment.Alipay" Version="3.3.2" />
|
||||
<PackageReference Include="Essensoft.AspNetCore.Payment.Security" Version="3.3.2" />
|
||||
<PackageReference Include="Essensoft.AspNetCore.Payment.WeChatPay" Version="3.3.2" />
|
||||
<PackageReference Include="log4net" Version="2.0.15" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.SignalR.Protocols.NewtonsoftJson" Version="8.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="8.0.0" />
|
||||
|
|
|
|||
|
|
@ -0,0 +1,16 @@
|
|||
using New_College.Common.Helper;
|
||||
using New_College.IServices.BASE;
|
||||
using New_College.Model.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace New_College.IServices
|
||||
{
|
||||
public interface IWeiChatPayServicesV3 : IBaseServices<V_OrderInfo>
|
||||
{
|
||||
Task<string> QrCodePay(WeChatPayTransactionsNativeQuery viewModel);
|
||||
}
|
||||
}
|
||||
|
|
@ -25,4 +25,9 @@ namespace New_College.Model.ViewModels
|
|||
|
||||
public int StudentId { get; set; }
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@ using New_College.Common.Helper;
|
|||
using Microsoft.Extensions.Options;
|
||||
using Essensoft.AspNetCore.Payment.WeChatPay;
|
||||
using Essensoft.AspNetCore.Payment.Alipay;
|
||||
using Essensoft.AspNetCore.Payment.WeChatPay.Notify;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Essensoft.AspNetCore.Payment.Alipay.Domain;
|
||||
using Essensoft.AspNetCore.Payment.Alipay.Request;
|
||||
|
|
@ -24,9 +23,11 @@ using System.Collections.Generic;
|
|||
using LinqKit;
|
||||
using System.Collections.Specialized;
|
||||
using Org.BouncyCastle.Asn1.Ocsp;
|
||||
using Essensoft.AspNetCore.Payment.WeChatPay.Response;
|
||||
using Essensoft.AspNetCore.Payment.WeChatPay.Request;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using NPOI.SS.Formula.Functions;
|
||||
using Essensoft.AspNetCore.Payment.WeChatPay.V2.Request;
|
||||
using Essensoft.AspNetCore.Payment.WeChatPay.V2;
|
||||
|
||||
namespace New_College.Services
|
||||
{
|
||||
|
|
@ -44,6 +45,7 @@ namespace New_College.Services
|
|||
private readonly IV_VipCardTypeRepository v_VipCardTypeRepository;
|
||||
|
||||
private readonly ILogger<V_OrderInfo> logger;
|
||||
private readonly IWeiChatPayServicesV3 _weiChatPayServicesV3;
|
||||
|
||||
public int Nums = 10;
|
||||
public V_OrderInfoServices(IWeChatPayClient client, IOptions<WeChatPayOptions> optionsAccessor
|
||||
|
|
@ -53,7 +55,7 @@ namespace New_College.Services
|
|||
, IV_CustomerInfoRepository IV_CustomerInfoRepository
|
||||
, IV_VipCardInfoRepository IV_VipCardInfoRepository
|
||||
, IV_VipCardTypeRepository IV_VipCardTypeRepository
|
||||
, ILogger<V_OrderInfo> loggers
|
||||
, ILogger<V_OrderInfo> loggers, IWeiChatPayServicesV3 weiChatPayServicesV3
|
||||
)
|
||||
{
|
||||
_client = client;
|
||||
|
|
@ -67,6 +69,17 @@ namespace New_College.Services
|
|||
v_VipCardTypeRepository = IV_VipCardTypeRepository;
|
||||
logger = loggers;
|
||||
base.BaseDal = dal;
|
||||
_weiChatPayServicesV3 = weiChatPayServicesV3;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 扫码支付-Native下单API
|
||||
/// </summary>
|
||||
/// <param name="viewModel"></param>
|
||||
public async Task<string> QrCodePay(WeChatPayTransactionsNativeQuery viewModel)
|
||||
{
|
||||
return await _weiChatPayServicesV3.QrCodePay(viewModel);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -287,7 +300,7 @@ namespace New_College.Services
|
|||
//viewModel.NotifyUrl = string.Format("{0}/api/front/HFivePay/WeChartOrderConfirm?out_trade_no={1}", PayInfoQuery.ApiUrl, out_trade_no);
|
||||
viewModel.SpBillCreateIp = PayInfoQuery.CreateIp;
|
||||
viewModel.OutTradeNo = out_trade_no;
|
||||
viewModel.TotalFee = Convert.ToInt32(query.Money*100);
|
||||
viewModel.TotalFee = Convert.ToInt32(query.Money * 100);
|
||||
viewModel.Body = "六纬志愿VIP";
|
||||
viewModel.TradeType = "MWEB";
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,83 @@
|
|||
|
||||
using New_College.IServices;
|
||||
using New_College.Model.Models;
|
||||
using New_College.Services.BASE;
|
||||
using New_College.IRepository.Base;
|
||||
using New_College.IRepository.UnitOfWork;
|
||||
using New_College.Model.ViewModels;
|
||||
using System.Threading.Tasks;
|
||||
using New_College.Common;
|
||||
using New_College.IRepository;
|
||||
using System.Linq;
|
||||
using YIJIYI.Core.Common.Helper;
|
||||
using System;
|
||||
using New_College.Model;
|
||||
using New_College.Common.Helper;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Essensoft.AspNetCore.Payment.WeChatPay;
|
||||
using Essensoft.AspNetCore.Payment.Alipay;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Essensoft.AspNetCore.Payment.Alipay.Domain;
|
||||
using Essensoft.AspNetCore.Payment.Alipay.Request;
|
||||
using System.Collections.Generic;
|
||||
using LinqKit;
|
||||
using System.Collections.Specialized;
|
||||
using Org.BouncyCastle.Asn1.Ocsp;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using NPOI.SS.Formula.Functions;
|
||||
using Essensoft.AspNetCore.Payment.WeChatPay.V3;
|
||||
|
||||
namespace New_College.Services
|
||||
{
|
||||
public class WeiChatPayServicesV3 : BaseServices<V_OrderInfo>, IWeiChatPayServicesV3
|
||||
{
|
||||
private readonly IWeChatPayClient _client;
|
||||
private readonly IOptions<WeChatPayOptions> _optionsAccessor;
|
||||
private readonly IAlipayClient alipayClient;
|
||||
private readonly IOptions<AlipayOptions> alipayoptions;
|
||||
|
||||
private readonly IBaseRepository<V_OrderInfo> _dal;
|
||||
private readonly IUnitOfWork _unitOfWork;
|
||||
private readonly IV_CustomerInfoRepository v_CustomerInfoRepository;
|
||||
private readonly IV_VipCardInfoRepository v_VipCardInfoRepository;
|
||||
private readonly IV_VipCardTypeRepository v_VipCardTypeRepository;
|
||||
|
||||
private readonly ILogger<V_OrderInfo> logger;
|
||||
|
||||
public int Nums = 10;
|
||||
public WeiChatPayServicesV3(IWeChatPayClient client, IOptions<WeChatPayOptions> optionsAccessor
|
||||
, IAlipayClient IAlipayClient, IOptions<AlipayOptions> alipayopt
|
||||
, IBaseRepository<V_OrderInfo> dal
|
||||
, IUnitOfWork IUnitOfWork
|
||||
, IV_CustomerInfoRepository IV_CustomerInfoRepository
|
||||
, IV_VipCardInfoRepository IV_VipCardInfoRepository
|
||||
, IV_VipCardTypeRepository IV_VipCardTypeRepository
|
||||
, ILogger<V_OrderInfo> loggers
|
||||
)
|
||||
{
|
||||
_client = client;
|
||||
_optionsAccessor = optionsAccessor;
|
||||
alipayClient = IAlipayClient;
|
||||
alipayoptions = alipayopt;
|
||||
this._dal = dal;
|
||||
_unitOfWork = IUnitOfWork;
|
||||
v_CustomerInfoRepository = IV_CustomerInfoRepository;
|
||||
v_VipCardInfoRepository = IV_VipCardInfoRepository;
|
||||
v_VipCardTypeRepository = IV_VipCardTypeRepository;
|
||||
logger = loggers;
|
||||
base.BaseDal = dal;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// PC端扫描支付生成URL
|
||||
/// </summary>
|
||||
/// <param name="viewModel"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<string> QrCodePay(WeChatPayTransactionsNativeQuery viewModel)
|
||||
{
|
||||
return await WeChatPayV3.QrCodePay(_client, _optionsAccessor, viewModel);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue