mirror of
https://github.com/Varorbc/PaySharp.git
synced 2026-10-29 12:41:43 +08:00
支付成功事件添加返回值
This commit is contained in:
@@ -25,7 +25,7 @@ namespace ICanPay.Demo.Controllers
|
||||
await notify.ReceivedAsync();
|
||||
}
|
||||
|
||||
private void Notify_PaymentSucceed(object sender, PaymentSucceedEventArgs e)
|
||||
private bool Notify_PaymentSucceed(object sender, PaymentSucceedEventArgs e)
|
||||
{
|
||||
// 支付成功时时的处理代码
|
||||
/* 建议添加以下校验。
|
||||
@@ -36,6 +36,9 @@ namespace ICanPay.Demo.Controllers
|
||||
{
|
||||
var alipayNotify = (Alipay.Notify)e.Notify;
|
||||
}
|
||||
|
||||
//处理成功返回true
|
||||
return true;
|
||||
}
|
||||
|
||||
private void Notify_PaymentFailed(object sender, PaymentFailedEventArgs e)
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace ICanPay.Core
|
||||
/// <summary>
|
||||
/// 网关异步返回的支付通知验证成功时触发
|
||||
/// </summary>
|
||||
public event Action<object, PaymentSucceedEventArgs> PaymentSucceed;
|
||||
public event Func<object, PaymentSucceedEventArgs, bool> PaymentSucceed;
|
||||
|
||||
/// <summary>
|
||||
/// 网关异步返回的支付通知无法识别时触发
|
||||
@@ -51,7 +51,7 @@ namespace ICanPay.Core
|
||||
|
||||
private void OnPaymentFailed(PaymentFailedEventArgs e) => PaymentFailed?.Invoke(this, e);
|
||||
|
||||
private void OnPaymentSucceed(PaymentSucceedEventArgs e) => PaymentSucceed?.Invoke(this, e);
|
||||
private bool OnPaymentSucceed(PaymentSucceedEventArgs e) => PaymentSucceed?.Invoke(this, e) ?? false;
|
||||
|
||||
private void OnUnknownGateway(UnknownGatewayEventArgs e) => UnknownGateway?.Invoke(this, e);
|
||||
|
||||
@@ -71,8 +71,15 @@ namespace ICanPay.Core
|
||||
{
|
||||
if (await gateway.ValidateNotifyAsync())
|
||||
{
|
||||
OnPaymentSucceed(new PaymentSucceedEventArgs(gateway));
|
||||
gateway.WriteSuccessFlag();
|
||||
bool result = OnPaymentSucceed(new PaymentSucceedEventArgs(gateway));
|
||||
if (result)
|
||||
{
|
||||
gateway.WriteSuccessFlag();
|
||||
}
|
||||
else
|
||||
{
|
||||
gateway.WriteFailureFlag();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user