支付成功事件添加返回值

This commit is contained in:
varorbc
2017-12-21 20:22:13 +08:00
parent 596f893d6c
commit 96c0ca4dc7
2 changed files with 15 additions and 5 deletions
@@ -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)
+11 -4
View File
@@ -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
{