Exemple #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            SiteSettings siteSettings = HiContext.Current.SiteSettings;
            NotifyClient notifyClient = null;

            notifyClient = ((string.IsNullOrEmpty(siteSettings.Main_Mch_ID) || string.IsNullOrEmpty(siteSettings.Main_AppId)) ? new NotifyClient(siteSettings.AppWxAppId, siteSettings.AppWxAppSecret, siteSettings.AppWxMchId, siteSettings.AppWxPartnerKey, "", "", "") : new NotifyClient(siteSettings.AppWX_Main_AppId, siteSettings.AppWxAppSecret, siteSettings.AppWX_Main_MchID, siteSettings.AppWxPartnerKey, "", siteSettings.AppWxAppId, siteSettings.AppWxMchId));
            PayNotify payNotify = notifyClient.GetPayNotify(base.Request.InputStream);

            if (payNotify != null)
            {
                this.OrderId = payNotify.PayInfo.OutTradeNo;
                string attach = payNotify.PayInfo.Attach;
                if (attach == "1")
                {
                    this.IsRecharge = true;
                }
                NameValueCollection nameValueCollection = new NameValueCollection
                {
                    base.Request.Form,
                    base.Request.QueryString
                };
                if (this.IsRecharge)
                {
                    InpourRequestInfo inpourBlance = MemberProcessor.GetInpourBlance(this.OrderId);
                    if (inpourBlance == null)
                    {
                        this.ResponseReturn(true, "");
                    }
                    else
                    {
                        MemberProcessor.AddBalanceDetailInfo(inpourBlance, "APP微信支付");
                    }
                }
                else
                {
                    this.Order = ShoppingProcessor.GetOrderInfo(this.OrderId);
                    if (this.Order == null && !string.IsNullOrEmpty(payNotify.PayInfo.OutTradeNo))
                    {
                        this.Order = ShoppingProcessor.GetOrderInfo(payNotify.PayInfo.OutTradeNo);
                    }
                    if (this.Order == null)
                    {
                        this.ResponseReturn(true, "");
                    }
                    else if (this.Order.PreSaleId > 0 && this.Order.DepositGatewayOrderId.ToNullString() == payNotify.PayInfo.TransactionId)
                    {
                        this.ResponseReturn(true, "");
                    }
                    else
                    {
                        this.hasNotify = !string.IsNullOrEmpty(this.Order.GatewayOrderId);
                        if (this.Order.PreSaleId > 0 && !this.Order.DepositDate.HasValue)
                        {
                            this.Order.DepositGatewayOrderId = payNotify.PayInfo.TransactionId;
                        }
                        else
                        {
                            this.Order.GatewayOrderId = payNotify.PayInfo.TransactionId;
                        }
                        this.UserPayOrder();
                    }
                }
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            SortedDictionary <string, string> requestPost = this.GetRequestPost();

            if (requestPost.Count > 0)
            {
                Notify notify = new Notify();
                if (notify.Verify(requestPost, base.Request.Form["notify_id"], base.Request.Form["sign"]))
                {
                    string text  = base.Request.Form["out_trade_no"];
                    string text2 = base.Request.Form["trade_no"];
                    string text3 = base.Request.Form["subject"];
                    string a     = base.Request.Form["trade_status"];
                    if (!(a == "TRADE_FINISHED") && a == "TRADE_SUCCESS")
                    {
                        if (text3.Trim().Equals("预付款充值"))
                        {
                            InpourRequestInfo inpourBlance = MemberProcessor.GetInpourBlance(text);
                            if (inpourBlance == null)
                            {
                                app_alipay_notify_url.writeLog("没有找到充值申请记录");
                                base.Response.Write("success");
                                return;
                            }
                            MemberProcessor.AddBalanceDetailInfo(inpourBlance, "支付宝app支付");
                        }
                        else if (text3.Trim().Equals("订单支付"))
                        {
                            if (!string.IsNullOrEmpty(text) && text.Length > 5)
                            {
                                text = text.Substring(0, text.Length - 5);
                            }
                            OrderInfo orderInfo = ShoppingProcessor.GetOrderInfo(text);
                            if (orderInfo == null)
                            {
                                base.Response.Write("success");
                                base.Response.End();
                                return;
                            }
                            this.hasNotify = !string.IsNullOrEmpty(orderInfo.GatewayOrderId);
                            if (orderInfo.PreSaleId > 0 && orderInfo.DepositGatewayOrderId.ToNullString() == text2)
                            {
                                base.Response.Write("success");
                                base.Response.End();
                                return;
                            }
                            if (orderInfo.PreSaleId > 0 && !orderInfo.DepositDate.HasValue)
                            {
                                orderInfo.DepositGatewayOrderId = text2;
                            }
                            else
                            {
                                orderInfo.GatewayOrderId = text2;
                            }
                            this.UserPayOrder(orderInfo);
                        }
                    }
                    base.Response.Write("success");
                    base.Response.End();
                }
                else
                {
                    base.Response.Write("fail");
                    base.Response.End();
                }
            }
            else
            {
                base.Response.Write("无通知参数");
                base.Response.End();
            }
        }