/// <summary> /// 接收并验证网关的支付通知 /// </summary> public async Task ReceivedAsync() { GatewayBase gateway = NotifyProcess.GetGateway(_gateways); if (gateway is NullGateway) { OnUnknownGateway(new UnknownGatewayEventArgs(gateway)); } else { try { if (await gateway.ValidateNotifyAsync()) { OnPaymentSucceed(new PaymentSucceedEventArgs(gateway)); gateway.WriteSuccessFlag(); } else { OnPaymentFailed(new PaymentFailedEventArgs(gateway)); gateway.WriteFailureFlag(); } } catch (GatewayException ex) { OnPaymentFailed(new PaymentFailedEventArgs(gateway) { Message = ex.Message }); gateway.WriteFailureFlag(); } } }
/// <summary> /// 接收并验证网关的支付通知 /// </summary> public async Task ReceivedAsync() { GatewayBase gateway = NotifyProcess.GetGateway(_gateways); if (gateway is NullGateway) { OnUnknownGateway(new UnknownGatewayEventArgs(gateway)); return; } try { if (await gateway.ValidateNotifyAsync()) { if (HttpUtil.RequestType == "GET") { OnPaymentSucceed(new PaymentSucceedEventArgs(gateway)); return; } if (!gateway.IsSuccessPay) { OnPaymentFailed(new PaymentFailedEventArgs(gateway)); gateway.WriteFailureFlag(); return; } bool result = OnPaymentSucceed(new PaymentSucceedEventArgs(gateway)); if (result) { gateway.WriteSuccessFlag(); } else { gateway.WriteFailureFlag(); } } else { OnPaymentFailed(new PaymentFailedEventArgs(gateway)); gateway.WriteFailureFlag(); } } catch (GatewayException ex) { OnPaymentFailed(new PaymentFailedEventArgs(gateway) { Message = ex.Message }); gateway.WriteFailureFlag(); } }
/// <summary> /// 接收并验证网关的支付通知 /// </summary> public async Task ReceivedAsync() { GatewayBase gateway = NotifyProcess.GetGateway(gatewayList); if (gateway.GatewayType != GatewayType.None) { if (await gateway.ValidateNotifyAsync()) { OnPaymentSucceed(new PaymentSucceedEventArgs(gateway)); gateway.WriteSuccessFlag(); } else { OnPaymentFailed(new PaymentFailedEventArgs(gateway)); gateway.WriteFailureFlag(); } } else { OnUnknownGateway(new UnknownGatewayEventArgs(gateway)); } }