mirror of
http://git.coreshop.cn/jianweie/coreshoppro.git
synced 2026-02-05 00:49:49 +08:00
优化微信支付、支付宝支付多种支付终端情况下的一一对应处理。
This commit is contained in:
@@ -85,6 +85,9 @@ namespace CoreCms.Net.Services
|
|||||||
return jm;
|
return jm;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var notifyUrl = config.notifyUrl.EndsWith("/") ? config.notifyUrl + "m-" + config.appId : config.notifyUrl + "/m-" + config.appId;
|
||||||
|
|
||||||
|
|
||||||
//构建linkPay请求配置实体
|
//构建linkPay请求配置实体
|
||||||
var payOptions = new AlipayOptions
|
var payOptions = new AlipayOptions
|
||||||
{
|
{
|
||||||
@@ -112,7 +115,7 @@ namespace CoreCms.Net.Services
|
|||||||
};
|
};
|
||||||
var req = new AlipayTradePrecreateRequest();
|
var req = new AlipayTradePrecreateRequest();
|
||||||
req.SetBizModel(model);
|
req.SetBizModel(model);
|
||||||
req.SetNotifyUrl(config.notifyUrl);
|
req.SetNotifyUrl(notifyUrl);
|
||||||
//req.SetReturnUrl("https://pc.pro.demo.corecms.cn/order/payment/result");
|
//req.SetReturnUrl("https://pc.pro.demo.corecms.cn/order/payment/result");
|
||||||
|
|
||||||
Loging.NLogUtil.WriteAll(LogLevel.Trace, Loging.LogType.Order, "支付宝ScanQRCodes支付拼接APP入参", JsonConvert.SerializeObject(model));
|
Loging.NLogUtil.WriteAll(LogLevel.Trace, Loging.LogType.Order, "支付宝ScanQRCodes支付拼接APP入参", JsonConvert.SerializeObject(model));
|
||||||
@@ -139,7 +142,7 @@ namespace CoreCms.Net.Services
|
|||||||
};
|
};
|
||||||
var req = new AlipayTradePagePayRequest();
|
var req = new AlipayTradePagePayRequest();
|
||||||
req.SetBizModel(model);
|
req.SetBizModel(model);
|
||||||
req.SetNotifyUrl(config.notifyUrl);
|
req.SetNotifyUrl(notifyUrl);
|
||||||
req.SetReturnUrl(config.jumpUrl);
|
req.SetReturnUrl(config.jumpUrl);
|
||||||
|
|
||||||
Loging.NLogUtil.WriteAll(LogLevel.Trace, Loging.LogType.Order, "支付宝JSAPI_PC支付拼接APP入参", JsonConvert.SerializeObject(model));
|
Loging.NLogUtil.WriteAll(LogLevel.Trace, Loging.LogType.Order, "支付宝JSAPI_PC支付拼接APP入参", JsonConvert.SerializeObject(model));
|
||||||
@@ -166,7 +169,7 @@ namespace CoreCms.Net.Services
|
|||||||
};
|
};
|
||||||
var req = new AlipayTradeAppPayRequest();
|
var req = new AlipayTradeAppPayRequest();
|
||||||
req.SetBizModel(model);
|
req.SetBizModel(model);
|
||||||
req.SetNotifyUrl(config.notifyUrl);
|
req.SetNotifyUrl(notifyUrl);
|
||||||
//req.SetReturnUrl(config.jumpUrl);
|
//req.SetReturnUrl(config.jumpUrl);
|
||||||
|
|
||||||
Loging.NLogUtil.WriteAll(LogLevel.Trace, Loging.LogType.Order, "支付宝APP支付拼接APP入参", JsonConvert.SerializeObject(model));
|
Loging.NLogUtil.WriteAll(LogLevel.Trace, Loging.LogType.Order, "支付宝APP支付拼接APP入参", JsonConvert.SerializeObject(model));
|
||||||
@@ -194,7 +197,7 @@ namespace CoreCms.Net.Services
|
|||||||
};
|
};
|
||||||
var req = new AlipayTradeWapPayRequest();
|
var req = new AlipayTradeWapPayRequest();
|
||||||
req.SetBizModel(model);
|
req.SetBizModel(model);
|
||||||
req.SetNotifyUrl(config.notifyUrl);
|
req.SetNotifyUrl(notifyUrl);
|
||||||
req.SetReturnUrl(config.jumpUrl);
|
req.SetReturnUrl(config.jumpUrl);
|
||||||
|
|
||||||
Loging.NLogUtil.WriteAll(LogLevel.Trace, Loging.LogType.Order, "支付宝MWEB支付拼接APP入参", JsonConvert.SerializeObject(model));
|
Loging.NLogUtil.WriteAll(LogLevel.Trace, Loging.LogType.Order, "支付宝MWEB支付拼接APP入参", JsonConvert.SerializeObject(model));
|
||||||
|
|||||||
@@ -180,13 +180,16 @@ namespace CoreCms.Net.Services
|
|||||||
openId = user.openid;
|
openId = user.openid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var notifyUrl = config.notifyUrl.EndsWith("/") ? config.notifyUrl + "m-" + config.appId : config.notifyUrl + "/m-" + config.appId;
|
||||||
|
|
||||||
|
|
||||||
var orderRequest = new WeChatPayUnifiedOrderRequest
|
var orderRequest = new WeChatPayUnifiedOrderRequest
|
||||||
{
|
{
|
||||||
Body = entity.payTitle.Length > 40 ? entity.payTitle[..40] : entity.payTitle,
|
Body = entity.payTitle.Length > 40 ? entity.payTitle[..40] : entity.payTitle,
|
||||||
OutTradeNo = entity.paymentId,
|
OutTradeNo = entity.paymentId,
|
||||||
TotalFee = Convert.ToInt32(entity.money * 100),
|
TotalFee = Convert.ToInt32(entity.money * 100),
|
||||||
SpBillCreateIp = entity.ip,
|
SpBillCreateIp = entity.ip,
|
||||||
NotifyUrl = config.notifyUrl,
|
NotifyUrl = notifyUrl,
|
||||||
TradeType = tradeType,
|
TradeType = tradeType,
|
||||||
//OpenId = openId
|
//OpenId = openId
|
||||||
};
|
};
|
||||||
@@ -233,7 +236,7 @@ namespace CoreCms.Net.Services
|
|||||||
jm.status = true;
|
jm.status = true;
|
||||||
jm.msg = "创建JSAPI支付环境成功";
|
jm.msg = "创建JSAPI支付环境成功";
|
||||||
jm.data = parameter;
|
jm.data = parameter;
|
||||||
//jm.otherData = response;
|
jm.otherData = response;
|
||||||
}
|
}
|
||||||
//扫码支付
|
//扫码支付
|
||||||
else if (tradeType == GlobalEnumVars.WeiChatPayTradeType.NATIVE.ToString())
|
else if (tradeType == GlobalEnumVars.WeiChatPayTradeType.NATIVE.ToString())
|
||||||
|
|||||||
@@ -12,10 +12,12 @@ using System.Threading.Tasks;
|
|||||||
using System.Xml;
|
using System.Xml;
|
||||||
using CoreCms.Net.Caching.AutoMate.RedisCache;
|
using CoreCms.Net.Caching.AutoMate.RedisCache;
|
||||||
using CoreCms.Net.Configuration;
|
using CoreCms.Net.Configuration;
|
||||||
|
using CoreCms.Net.IServices;
|
||||||
using CoreCms.Net.Loging;
|
using CoreCms.Net.Loging;
|
||||||
using Essensoft.Paylink.Alipay;
|
using Essensoft.Paylink.Alipay;
|
||||||
using Essensoft.Paylink.Alipay.Notify;
|
using Essensoft.Paylink.Alipay.Notify;
|
||||||
using Essensoft.Paylink.Alipay.Utility;
|
using Essensoft.Paylink.Alipay.Utility;
|
||||||
|
using Google.Protobuf.WellKnownTypes;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.Extensions.Options;
|
using Microsoft.Extensions.Options;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
@@ -30,33 +32,49 @@ namespace CoreCms.Net.Web.WebApi.Controllers.PayNotify
|
|||||||
public class AliPayController : ControllerBase
|
public class AliPayController : ControllerBase
|
||||||
{
|
{
|
||||||
private readonly IAlipayNotifyClient _client;
|
private readonly IAlipayNotifyClient _client;
|
||||||
private readonly IOptions<AlipayOptions> _optionsAccessor;
|
|
||||||
private readonly IRedisOperationRepository _redisOperationRepository;
|
private readonly IRedisOperationRepository _redisOperationRepository;
|
||||||
|
private readonly IAlipayConfigServices _alipayConfigServices;
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 构造函数
|
/// 构造函数
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="client"></param>
|
/// <param name="client"></param>
|
||||||
/// <param name="optionsAccessor"></param>
|
|
||||||
/// <param name="redisOperationRepository"></param>
|
/// <param name="redisOperationRepository"></param>
|
||||||
public AliPayController(IAlipayNotifyClient client, IOptions<AlipayOptions> optionsAccessor, IRedisOperationRepository redisOperationRepository)
|
/// <param name="alipayConfigServices"></param>
|
||||||
|
public AliPayController(IAlipayNotifyClient client, IRedisOperationRepository redisOperationRepository, IAlipayConfigServices alipayConfigServices)
|
||||||
{
|
{
|
||||||
_client = client;
|
_client = client;
|
||||||
_optionsAccessor = optionsAccessor;
|
|
||||||
_redisOperationRepository = redisOperationRepository;
|
_redisOperationRepository = redisOperationRepository;
|
||||||
|
_alipayConfigServices = alipayConfigServices;
|
||||||
}
|
}
|
||||||
|
|
||||||
#region 支付宝统一回调接口
|
#region 支付宝统一回调接口
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// APP支付统一下单支付结果通知
|
/// APP支付统一下单支付结果通知
|
||||||
/// https://api.pro.coreshop.cn/Notify/AliPay/Unifiedorder
|
/// https://api.pro.coreshop.cn/Notify/AliPay/Unifiedorder
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public async Task<IActionResult> Unifiedorder()
|
[Route("m-{appid}")]
|
||||||
|
public async Task<IActionResult> Unifiedorder([FromRoute(Name = "appid")] string appid)
|
||||||
{
|
{
|
||||||
NLogUtil.WriteAll(LogLevel.Trace, LogType.Order, "支付宝支付回调开始", "支付宝回调开始数据标记");
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var notify = await _client.ExecuteAsync<AlipayTradeAppPayNotify>(Request, _optionsAccessor.Value);
|
var config = await _alipayConfigServices.QueryByClauseAsync(p => p.isDefault == true && p.isEnable == true && p.appId == appid);
|
||||||
|
//构建linkPay请求配置实体
|
||||||
|
var payOptions = new AlipayOptions
|
||||||
|
{
|
||||||
|
AppId = config.appId,
|
||||||
|
AlipayPublicKey = config.publicKey,
|
||||||
|
AppPrivateKey = config.privateKey,
|
||||||
|
ServerUrl = config.serverUrl,
|
||||||
|
SignType = config.signType,
|
||||||
|
AppPublicCert = config.appPublicCert,
|
||||||
|
AlipayPublicCert = config.alipayPublicCert,
|
||||||
|
AlipayRootCert = config.alipayRootCert
|
||||||
|
};
|
||||||
|
|
||||||
|
var notify = await _client.ExecuteAsync<AlipayTradeAppPayNotify>(Request, payOptions);
|
||||||
NLogUtil.WriteAll(LogLevel.Trace, LogType.Order, "支付宝支付回调支付宝返回的参数", JsonConvert.SerializeObject(notify));
|
NLogUtil.WriteAll(LogLevel.Trace, LogType.Order, "支付宝支付回调支付宝返回的参数", JsonConvert.SerializeObject(notify));
|
||||||
if (notify.TradeStatus == AlipayTradeStatus.Success)
|
if (notify.TradeStatus == AlipayTradeStatus.Success)
|
||||||
{
|
{
|
||||||
@@ -82,17 +100,34 @@ namespace CoreCms.Net.Web.WebApi.Controllers.PayNotify
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public async Task<IActionResult> Gateway()
|
[Route("m-{appid}")]
|
||||||
|
|
||||||
|
public async Task<IActionResult> Gateway([FromRoute(Name = "appid")] string appid)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
var config = await _alipayConfigServices.QueryByClauseAsync(p => p.isDefault == true && p.isEnable == true && p.appId == appid);
|
||||||
|
//构建linkPay请求配置实体
|
||||||
|
var payOptions = new AlipayOptions
|
||||||
|
{
|
||||||
|
AppId = config.appId,
|
||||||
|
AlipayPublicKey = config.publicKey,
|
||||||
|
AppPrivateKey = config.privateKey,
|
||||||
|
ServerUrl = config.serverUrl,
|
||||||
|
SignType = config.signType,
|
||||||
|
AppPublicCert = config.appPublicCert,
|
||||||
|
AlipayPublicCert = config.alipayPublicCert,
|
||||||
|
AlipayRootCert = config.alipayRootCert
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
var service = Request.Form["service"].ToString();
|
var service = Request.Form["service"].ToString();
|
||||||
switch (service)
|
switch (service)
|
||||||
{
|
{
|
||||||
// 激活开发者模式
|
// 激活开发者模式
|
||||||
case "alipay.service.check":
|
case "alipay.service.check":
|
||||||
{
|
{
|
||||||
var options = _optionsAccessor.Value;
|
var options = payOptions;
|
||||||
|
|
||||||
// 获取参数
|
// 获取参数
|
||||||
var parameters = await _client.GetParametersAsync(Request);
|
var parameters = await _client.GetParametersAsync(Request);
|
||||||
@@ -121,49 +156,49 @@ namespace CoreCms.Net.Web.WebApi.Controllers.PayNotify
|
|||||||
// 资金单据状态变更通知
|
// 资金单据状态变更通知
|
||||||
case "alipay.fund.trans.order.changed":
|
case "alipay.fund.trans.order.changed":
|
||||||
{
|
{
|
||||||
var notify = await _client.CertificateExecuteAsync<AlipayFundTransOrderChangedNotify>(Request, _optionsAccessor.Value);
|
var notify = await _client.CertificateExecuteAsync<AlipayFundTransOrderChangedNotify>(Request, payOptions);
|
||||||
return AlipayNotifyResult.Success;
|
return AlipayNotifyResult.Success;
|
||||||
}
|
}
|
||||||
// 第三方应用授权取消消息
|
// 第三方应用授权取消消息
|
||||||
case "alipay.open.auth.appauth.cancelled":
|
case "alipay.open.auth.appauth.cancelled":
|
||||||
{
|
{
|
||||||
var notify = await _client.CertificateExecuteAsync<AlipayOpenAuthAppauthCancelledNotify>(Request, _optionsAccessor.Value);
|
var notify = await _client.CertificateExecuteAsync<AlipayOpenAuthAppauthCancelledNotify>(Request, payOptions);
|
||||||
return AlipayNotifyResult.Success;
|
return AlipayNotifyResult.Success;
|
||||||
}
|
}
|
||||||
// 用户授权取消消息
|
// 用户授权取消消息
|
||||||
case "alipay.open.auth.userauth.cancelled":
|
case "alipay.open.auth.userauth.cancelled":
|
||||||
{
|
{
|
||||||
var notify = await _client.CertificateExecuteAsync<AlipayOpenAuthUserauthCancelledNotify>(Request, _optionsAccessor.Value);
|
var notify = await _client.CertificateExecuteAsync<AlipayOpenAuthUserauthCancelledNotify>(Request, payOptions);
|
||||||
return AlipayNotifyResult.Success;
|
return AlipayNotifyResult.Success;
|
||||||
}
|
}
|
||||||
// 小程序审核通过通知
|
// 小程序审核通过通知
|
||||||
case "alipay.open.mini.version.audit.passed":
|
case "alipay.open.mini.version.audit.passed":
|
||||||
{
|
{
|
||||||
var notify = await _client.CertificateExecuteAsync<AlipayOpenMiniVersionAuditPassedNotify>(Request, _optionsAccessor.Value);
|
var notify = await _client.CertificateExecuteAsync<AlipayOpenMiniVersionAuditPassedNotify>(Request, payOptions);
|
||||||
return AlipayNotifyResult.Success;
|
return AlipayNotifyResult.Success;
|
||||||
}
|
}
|
||||||
// 用户授权取消消息
|
// 用户授权取消消息
|
||||||
case "alipay.open.mini.version.audit.rejected":
|
case "alipay.open.mini.version.audit.rejected":
|
||||||
{
|
{
|
||||||
var notify = await _client.CertificateExecuteAsync<AlipayOpenMiniVersionAuditRejectedNotify>(Request, _optionsAccessor.Value);
|
var notify = await _client.CertificateExecuteAsync<AlipayOpenMiniVersionAuditRejectedNotify>(Request, payOptions);
|
||||||
return AlipayNotifyResult.Success;
|
return AlipayNotifyResult.Success;
|
||||||
}
|
}
|
||||||
// 收单资金结算到银行账户,结算退票的异步通知
|
// 收单资金结算到银行账户,结算退票的异步通知
|
||||||
case "alipay.trade.settle.dishonoured":
|
case "alipay.trade.settle.dishonoured":
|
||||||
{
|
{
|
||||||
var notify = await _client.CertificateExecuteAsync<AlipayTradeSettleDishonouredNotify>(Request, _optionsAccessor.Value);
|
var notify = await _client.CertificateExecuteAsync<AlipayTradeSettleDishonouredNotify>(Request, payOptions);
|
||||||
return AlipayNotifyResult.Success;
|
return AlipayNotifyResult.Success;
|
||||||
}
|
}
|
||||||
// 收单资金结算到银行账户,结算失败的异步通知
|
// 收单资金结算到银行账户,结算失败的异步通知
|
||||||
case "alipay.trade.settle.fail":
|
case "alipay.trade.settle.fail":
|
||||||
{
|
{
|
||||||
var notify = await _client.CertificateExecuteAsync<AlipayTradeSettleFailNotify>(Request, _optionsAccessor.Value);
|
var notify = await _client.CertificateExecuteAsync<AlipayTradeSettleFailNotify>(Request, payOptions);
|
||||||
return AlipayNotifyResult.Success;
|
return AlipayNotifyResult.Success;
|
||||||
}
|
}
|
||||||
// 收单资金结算到银行账户,结算成功的异步通知
|
// 收单资金结算到银行账户,结算成功的异步通知
|
||||||
case "alipay.trade.settle.success":
|
case "alipay.trade.settle.success":
|
||||||
{
|
{
|
||||||
var notify = await _client.CertificateExecuteAsync<AlipayTradeSettleSuccessNotify>(Request, _optionsAccessor.Value);
|
var notify = await _client.CertificateExecuteAsync<AlipayTradeSettleSuccessNotify>(Request, payOptions);
|
||||||
return AlipayNotifyResult.Success;
|
return AlipayNotifyResult.Success;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -180,11 +215,28 @@ namespace CoreCms.Net.Web.WebApi.Controllers.PayNotify
|
|||||||
/// 扫码支付异步通知
|
/// 扫码支付异步通知
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public async Task<IActionResult> Precreate()
|
[Route("m-{appid}")]
|
||||||
|
|
||||||
|
public async Task<IActionResult> Precreate([FromRoute(Name = "appid")] string appid)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var notify = await _client.ExecuteAsync<AlipayTradeAppPayNotify>(Request, _optionsAccessor.Value);
|
var config = await _alipayConfigServices.QueryByClauseAsync(p => p.isDefault == true && p.isEnable == true && p.appId == appid);
|
||||||
|
//构建linkPay请求配置实体
|
||||||
|
var payOptions = new AlipayOptions
|
||||||
|
{
|
||||||
|
AppId = config.appId,
|
||||||
|
AlipayPublicKey = config.publicKey,
|
||||||
|
AppPrivateKey = config.privateKey,
|
||||||
|
ServerUrl = config.serverUrl,
|
||||||
|
SignType = config.signType,
|
||||||
|
AppPublicCert = config.appPublicCert,
|
||||||
|
AlipayPublicCert = config.alipayPublicCert,
|
||||||
|
AlipayRootCert = config.alipayRootCert
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
var notify = await _client.ExecuteAsync<AlipayTradeAppPayNotify>(Request, payOptions);
|
||||||
if (notify.TradeStatus == AlipayTradeStatus.Success)
|
if (notify.TradeStatus == AlipayTradeStatus.Success)
|
||||||
{
|
{
|
||||||
await _redisOperationRepository.ListLeftPushAsync(RedisMessageQueueKey.AliPayNotice, JsonConvert.SerializeObject(notify));
|
await _redisOperationRepository.ListLeftPushAsync(RedisMessageQueueKey.AliPayNotice, JsonConvert.SerializeObject(notify));
|
||||||
@@ -204,11 +256,26 @@ namespace CoreCms.Net.Web.WebApi.Controllers.PayNotify
|
|||||||
/// APP支付异步通知
|
/// APP支付异步通知
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public async Task<IActionResult> AppPay()
|
[Route("m-{appid}")]
|
||||||
|
public async Task<IActionResult> AppPay([FromRoute(Name = "appid")] string appid)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var notify = await _client.CertificateExecuteAsync<AlipayTradeAppPayNotify>(Request, _optionsAccessor.Value);
|
var config = await _alipayConfigServices.QueryByClauseAsync(p => p.isDefault == true && p.isEnable == true && p.appId == appid);
|
||||||
|
//构建linkPay请求配置实体
|
||||||
|
var payOptions = new AlipayOptions
|
||||||
|
{
|
||||||
|
AppId = config.appId,
|
||||||
|
AlipayPublicKey = config.publicKey,
|
||||||
|
AppPrivateKey = config.privateKey,
|
||||||
|
ServerUrl = config.serverUrl,
|
||||||
|
SignType = config.signType,
|
||||||
|
AppPublicCert = config.appPublicCert,
|
||||||
|
AlipayPublicCert = config.alipayPublicCert,
|
||||||
|
AlipayRootCert = config.alipayRootCert
|
||||||
|
};
|
||||||
|
|
||||||
|
var notify = await _client.CertificateExecuteAsync<AlipayTradeAppPayNotify>(Request, payOptions);
|
||||||
if (notify.TradeStatus == AlipayTradeStatus.Success)
|
if (notify.TradeStatus == AlipayTradeStatus.Success)
|
||||||
{
|
{
|
||||||
Console.WriteLine("OutTradeNo: " + notify.OutTradeNo);
|
Console.WriteLine("OutTradeNo: " + notify.OutTradeNo);
|
||||||
@@ -222,15 +289,31 @@ namespace CoreCms.Net.Web.WebApi.Controllers.PayNotify
|
|||||||
return NoContent();
|
return NoContent();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 电脑网站支付异步通知
|
/// 电脑网站支付异步通知
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public async Task<IActionResult> PagePay()
|
[Route("m-{appid}")]
|
||||||
|
public async Task<IActionResult> PagePay([FromRoute(Name = "appid")] string appid)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var notify = await _client.CertificateExecuteAsync<AlipayTradePagePayNotify>(Request, _optionsAccessor.Value);
|
var config = await _alipayConfigServices.QueryByClauseAsync(p => p.isDefault == true && p.isEnable == true && p.appId == appid);
|
||||||
|
//构建linkPay请求配置实体
|
||||||
|
var payOptions = new AlipayOptions
|
||||||
|
{
|
||||||
|
AppId = config.appId,
|
||||||
|
AlipayPublicKey = config.publicKey,
|
||||||
|
AppPrivateKey = config.privateKey,
|
||||||
|
ServerUrl = config.serverUrl,
|
||||||
|
SignType = config.signType,
|
||||||
|
AppPublicCert = config.appPublicCert,
|
||||||
|
AlipayPublicCert = config.alipayPublicCert,
|
||||||
|
AlipayRootCert = config.alipayRootCert
|
||||||
|
};
|
||||||
|
|
||||||
|
var notify = await _client.CertificateExecuteAsync<AlipayTradePagePayNotify>(Request, payOptions);
|
||||||
if (notify.TradeStatus == AlipayTradeStatus.Success)
|
if (notify.TradeStatus == AlipayTradeStatus.Success)
|
||||||
{
|
{
|
||||||
Console.WriteLine("OutTradeNo: " + notify.OutTradeNo);
|
Console.WriteLine("OutTradeNo: " + notify.OutTradeNo);
|
||||||
@@ -249,11 +332,26 @@ namespace CoreCms.Net.Web.WebApi.Controllers.PayNotify
|
|||||||
/// 手机网站支付异步通知
|
/// 手机网站支付异步通知
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public async Task<IActionResult> WapPay()
|
[Route("m-{appid}")]
|
||||||
|
public async Task<IActionResult> WapPay([FromRoute(Name = "appid")] string appid)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var notify = await _client.CertificateExecuteAsync<AlipayTradeWapPayNotify>(Request, _optionsAccessor.Value);
|
var config = await _alipayConfigServices.QueryByClauseAsync(p => p.isDefault == true && p.isEnable == true && p.appId == appid);
|
||||||
|
//构建linkPay请求配置实体
|
||||||
|
var payOptions = new AlipayOptions
|
||||||
|
{
|
||||||
|
AppId = config.appId,
|
||||||
|
AlipayPublicKey = config.publicKey,
|
||||||
|
AppPrivateKey = config.privateKey,
|
||||||
|
ServerUrl = config.serverUrl,
|
||||||
|
SignType = config.signType,
|
||||||
|
AppPublicCert = config.appPublicCert,
|
||||||
|
AlipayPublicCert = config.alipayPublicCert,
|
||||||
|
AlipayRootCert = config.alipayRootCert
|
||||||
|
};
|
||||||
|
|
||||||
|
var notify = await _client.CertificateExecuteAsync<AlipayTradeWapPayNotify>(Request, payOptions);
|
||||||
if (notify.TradeStatus == AlipayTradeStatus.Success)
|
if (notify.TradeStatus == AlipayTradeStatus.Success)
|
||||||
{
|
{
|
||||||
Console.WriteLine("OutTradeNo: " + notify.OutTradeNo);
|
Console.WriteLine("OutTradeNo: " + notify.OutTradeNo);
|
||||||
|
|||||||
@@ -34,7 +34,6 @@ namespace CoreCms.Net.Web.WebApi.Controllers.PayNotify
|
|||||||
private readonly ICoreCmsBillPaymentsServices _billPaymentsServices;
|
private readonly ICoreCmsBillPaymentsServices _billPaymentsServices;
|
||||||
private readonly ICoreCmsBillRefundServices _billRefundServices;
|
private readonly ICoreCmsBillRefundServices _billRefundServices;
|
||||||
private readonly IWeChatPayNotifyClient _client;
|
private readonly IWeChatPayNotifyClient _client;
|
||||||
//private readonly IOptions<WeChatPayOptions> _optionsAccessor;
|
|
||||||
private readonly IRedisOperationRepository _redisOperationRepository;
|
private readonly IRedisOperationRepository _redisOperationRepository;
|
||||||
|
|
||||||
private readonly IWeChatPayConfigServices _weChatPayConfigServices;
|
private readonly IWeChatPayConfigServices _weChatPayConfigServices;
|
||||||
@@ -45,11 +44,9 @@ namespace CoreCms.Net.Web.WebApi.Controllers.PayNotify
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public WeChatPayController(
|
public WeChatPayController(
|
||||||
IWeChatPayNotifyClient client
|
IWeChatPayNotifyClient client
|
||||||
//, IOptions<WeChatPayOptions> optionsAccessor
|
|
||||||
, ICoreCmsBillPaymentsServices billPaymentsServices, ICoreCmsBillRefundServices billRefundServices, IRedisOperationRepository redisOperationRepository, IWeChatPayConfigServices weChatPayConfigServices)
|
, ICoreCmsBillPaymentsServices billPaymentsServices, ICoreCmsBillRefundServices billRefundServices, IRedisOperationRepository redisOperationRepository, IWeChatPayConfigServices weChatPayConfigServices)
|
||||||
{
|
{
|
||||||
_client = client;
|
_client = client;
|
||||||
//_optionsAccessor = optionsAccessor;
|
|
||||||
_billPaymentsServices = billPaymentsServices;
|
_billPaymentsServices = billPaymentsServices;
|
||||||
_billRefundServices = billRefundServices;
|
_billRefundServices = billRefundServices;
|
||||||
_redisOperationRepository = redisOperationRepository;
|
_redisOperationRepository = redisOperationRepository;
|
||||||
@@ -60,12 +57,14 @@ namespace CoreCms.Net.Web.WebApi.Controllers.PayNotify
|
|||||||
/// 统一下单支付结果通知
|
/// 统一下单支付结果通知
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public async Task<IActionResult> Unifiedorder()
|
[Route("m-{appid}")]
|
||||||
|
public async Task<IActionResult> Unifiedorder([FromRoute(Name = "appid")] string appid)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
//NLogUtil.WriteAll(LogLevel.Trace, LogType.Order, "微信支付成功接收appid", JsonConvert.SerializeObject(appid));
|
||||||
|
|
||||||
var config = await _weChatPayConfigServices.QueryByClauseAsync(p => p.isDefault == true && p.isEnable == true);
|
var config = await _weChatPayConfigServices.QueryByClauseAsync(p => p.isDefault == true && p.isEnable == true && p.appId == appid);
|
||||||
//构建linkPay请求配置实体
|
//构建linkPay请求配置实体
|
||||||
var payOptions = new WeChatPayOptions
|
var payOptions = new WeChatPayOptions
|
||||||
{
|
{
|
||||||
@@ -105,8 +104,6 @@ namespace CoreCms.Net.Web.WebApi.Controllers.PayNotify
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
var config = await _weChatPayConfigServices.QueryByClauseAsync(p => p.isDefault == true && p.isEnable == true);
|
var config = await _weChatPayConfigServices.QueryByClauseAsync(p => p.isDefault == true && p.isEnable == true);
|
||||||
//构建linkPay请求配置实体
|
//构建linkPay请求配置实体
|
||||||
var payOptions = new WeChatPayOptions
|
var payOptions = new WeChatPayOptions
|
||||||
@@ -121,7 +118,6 @@ namespace CoreCms.Net.Web.WebApi.Controllers.PayNotify
|
|||||||
SubMchId = config.subMchId
|
SubMchId = config.subMchId
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
var notify = await _client.ExecuteAsync<WeChatPayRefundNotify>(Request, payOptions);
|
var notify = await _client.ExecuteAsync<WeChatPayRefundNotify>(Request, payOptions);
|
||||||
NLogUtil.WriteAll(LogLevel.Trace, LogType.Refund, "微信退款结果通知", JsonConvert.SerializeObject(notify));
|
NLogUtil.WriteAll(LogLevel.Trace, LogType.Refund, "微信退款结果通知", JsonConvert.SerializeObject(notify));
|
||||||
|
|
||||||
|
|||||||
@@ -730,42 +730,42 @@
|
|||||||
支付宝异步通知
|
支付宝异步通知
|
||||||
</summary>
|
</summary>
|
||||||
</member>
|
</member>
|
||||||
<member name="M:CoreCms.Net.Web.WebApi.Controllers.PayNotify.AliPayController.#ctor(Essensoft.Paylink.Alipay.IAlipayNotifyClient,Microsoft.Extensions.Options.IOptions{Essensoft.Paylink.Alipay.AlipayOptions},CoreCms.Net.Caching.AutoMate.RedisCache.IRedisOperationRepository)">
|
<member name="M:CoreCms.Net.Web.WebApi.Controllers.PayNotify.AliPayController.#ctor(Essensoft.Paylink.Alipay.IAlipayNotifyClient,CoreCms.Net.Caching.AutoMate.RedisCache.IRedisOperationRepository,CoreCms.Net.IServices.IAlipayConfigServices)">
|
||||||
<summary>
|
<summary>
|
||||||
构造函数
|
构造函数
|
||||||
</summary>
|
</summary>
|
||||||
<param name="client"></param>
|
<param name="client"></param>
|
||||||
<param name="optionsAccessor"></param>
|
|
||||||
<param name="redisOperationRepository"></param>
|
<param name="redisOperationRepository"></param>
|
||||||
|
<param name="alipayConfigServices"></param>
|
||||||
</member>
|
</member>
|
||||||
<member name="M:CoreCms.Net.Web.WebApi.Controllers.PayNotify.AliPayController.Unifiedorder">
|
<member name="M:CoreCms.Net.Web.WebApi.Controllers.PayNotify.AliPayController.Unifiedorder(System.String)">
|
||||||
<summary>
|
<summary>
|
||||||
APP支付统一下单支付结果通知
|
APP支付统一下单支付结果通知
|
||||||
https://api.pro.coreshop.cn/Notify/AliPay/Unifiedorder
|
https://api.pro.coreshop.cn/Notify/AliPay/Unifiedorder
|
||||||
</summary>
|
</summary>
|
||||||
</member>
|
</member>
|
||||||
<member name="M:CoreCms.Net.Web.WebApi.Controllers.PayNotify.AliPayController.Gateway">
|
<member name="M:CoreCms.Net.Web.WebApi.Controllers.PayNotify.AliPayController.Gateway(System.String)">
|
||||||
<summary>
|
<summary>
|
||||||
应用网关
|
应用网关
|
||||||
</summary>
|
</summary>
|
||||||
<returns></returns>
|
<returns></returns>
|
||||||
</member>
|
</member>
|
||||||
<member name="M:CoreCms.Net.Web.WebApi.Controllers.PayNotify.AliPayController.Precreate">
|
<member name="M:CoreCms.Net.Web.WebApi.Controllers.PayNotify.AliPayController.Precreate(System.String)">
|
||||||
<summary>
|
<summary>
|
||||||
扫码支付异步通知
|
扫码支付异步通知
|
||||||
</summary>
|
</summary>
|
||||||
</member>
|
</member>
|
||||||
<member name="M:CoreCms.Net.Web.WebApi.Controllers.PayNotify.AliPayController.AppPay">
|
<member name="M:CoreCms.Net.Web.WebApi.Controllers.PayNotify.AliPayController.AppPay(System.String)">
|
||||||
<summary>
|
<summary>
|
||||||
APP支付异步通知
|
APP支付异步通知
|
||||||
</summary>
|
</summary>
|
||||||
</member>
|
</member>
|
||||||
<member name="M:CoreCms.Net.Web.WebApi.Controllers.PayNotify.AliPayController.PagePay">
|
<member name="M:CoreCms.Net.Web.WebApi.Controllers.PayNotify.AliPayController.PagePay(System.String)">
|
||||||
<summary>
|
<summary>
|
||||||
电脑网站支付异步通知
|
电脑网站支付异步通知
|
||||||
</summary>
|
</summary>
|
||||||
</member>
|
</member>
|
||||||
<member name="M:CoreCms.Net.Web.WebApi.Controllers.PayNotify.AliPayController.WapPay">
|
<member name="M:CoreCms.Net.Web.WebApi.Controllers.PayNotify.AliPayController.WapPay(System.String)">
|
||||||
<summary>
|
<summary>
|
||||||
手机网站支付异步通知
|
手机网站支付异步通知
|
||||||
</summary>
|
</summary>
|
||||||
@@ -775,12 +775,12 @@
|
|||||||
微信支付异步通知
|
微信支付异步通知
|
||||||
</summary>
|
</summary>
|
||||||
</member>
|
</member>
|
||||||
<member name="M:CoreCms.Net.Web.WebApi.Controllers.PayNotify.WeChatPayController.#ctor(Essensoft.Paylink.WeChatPay.V2.IWeChatPayNotifyClient,Microsoft.Extensions.Options.IOptions{Essensoft.Paylink.WeChatPay.WeChatPayOptions},CoreCms.Net.IServices.ICoreCmsBillPaymentsServices,CoreCms.Net.IServices.ICoreCmsBillRefundServices,CoreCms.Net.Caching.AutoMate.RedisCache.IRedisOperationRepository)">
|
<member name="M:CoreCms.Net.Web.WebApi.Controllers.PayNotify.WeChatPayController.#ctor(Essensoft.Paylink.WeChatPay.V2.IWeChatPayNotifyClient,CoreCms.Net.IServices.ICoreCmsBillPaymentsServices,CoreCms.Net.IServices.ICoreCmsBillRefundServices,CoreCms.Net.Caching.AutoMate.RedisCache.IRedisOperationRepository,CoreCms.Net.IServices.IWeChatPayConfigServices)">
|
||||||
<summary>
|
<summary>
|
||||||
构造函数
|
构造函数
|
||||||
</summary>
|
</summary>
|
||||||
</member>
|
</member>
|
||||||
<member name="M:CoreCms.Net.Web.WebApi.Controllers.PayNotify.WeChatPayController.Unifiedorder">
|
<member name="M:CoreCms.Net.Web.WebApi.Controllers.PayNotify.WeChatPayController.Unifiedorder(System.String)">
|
||||||
<summary>
|
<summary>
|
||||||
统一下单支付结果通知
|
统一下单支付结果通知
|
||||||
</summary>
|
</summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user