コード例 #1
0
ファイル: PaymentNotify.cs プロジェクト: jjg0519/ICanPay-1
        /// <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();
                }
            }
        }
コード例 #2
0
ファイル: PaymentNotify.cs プロジェクト: ziyou268/ICanPay
        /// <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();
            }
        }
コード例 #3
0
ファイル: PaymentNotify.cs プロジェクト: hardweight/ICanPay
        /// <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));
            }
        }