Exemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            this.nPram = new NameValueCollection
            {
                base.Request.QueryString,
                base.Request.Form
            };
            SiteSettings masterSettings = SettingsManager.GetMasterSettings();
            NotifyClient notifyClient   = null;

            notifyClient = new NotifyClient(masterSettings.WxAppletAppId, masterSettings.WxAppletAppSecrect, masterSettings.WxApplectMchId, masterSettings.WxApplectKey, "", "", "");
            PayNotify payNotify = notifyClient.GetPayNotify(base.Request.InputStream);

            if (payNotify == null)
            {
                Globals.AppendLog(this.nPram, "获取通知信息错误", this.ReadString(base.Request.InputStream), "", "wxappletPay1");
            }
            else
            {
                this.OrderId = payNotify.PayInfo.OutTradeNo;
                this.Order   = ShoppingProcessor.GetOrderInfo(this.OrderId);
                if (this.Order == null && !string.IsNullOrEmpty(payNotify.PayInfo.OutTradeNo))
                {
                    Globals.AppendLog(this.nPram, "订单ID错误", this.OrderId, "wxPay", "");
                    this.Order = ShoppingProcessor.GetOrderInfo(payNotify.PayInfo.OutTradeNo);
                }
                if (this.Order == null)
                {
                    Globals.AppendLog(this.nPram, "订单ID错误", payNotify.PayInfo.OutTradeNo, "wxPay", "");
                    this.ResponseReturn(true, "");
                }
                else
                {
                    this.hasNotify = !string.IsNullOrEmpty(this.Order.GatewayOrderId);
                    if (this.Order.PreSaleId > 0 && this.Order.DepositGatewayOrderId.ToNullString() == payNotify.PayInfo.TransactionId)
                    {
                        this.ResponseReturn(true, "");
                    }
                    else
                    {
                        if ((this.Order.PreSaleId > 0 && !this.Order.DepositDate.HasValue) || this.Order.DepositGatewayOrderId.ToNullString() == payNotify.PayInfo.TransactionId)
                        {
                            this.Order.DepositGatewayOrderId = payNotify.PayInfo.TransactionId;
                        }
                        else
                        {
                            this.Order.GatewayOrderId = payNotify.PayInfo.TransactionId;
                        }
                        this.UserPayOrder();
                    }
                }
            }
        }
Exemplo n.º 2
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            SiteSettings siteSettings = SettingsManager.GetMasterSettings(false);
            NotifyClient client       = new NotifyClient(siteSettings.WeixinAppId, siteSettings.WeixinAppSecret, siteSettings.WeixinPartnerID, siteSettings.WeixinPartnerKey, siteSettings.WeixinPaySignKey);
            PayNotify    notify       = client.GetPayNotify(base.Request.InputStream);

            if (notify == null)
            {
                return;
            }
            this.OrderId = notify.PayInfo.OutTradeNo;
            this.Order   = ShoppingProcessor.GetOrderInfo(this.OrderId);
            if (this.Order == null)
            {
                base.Response.Write("success");
                return;
            }
            this.Order.GatewayOrderId = notify.PayInfo.TransactionId;
            this.UserPayOrder();
        }
Exemplo n.º 3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            SiteSettings masterSettings = SettingsManager.GetMasterSettings();
            NotifyClient notifyClient   = null;

            notifyClient = ((string.IsNullOrEmpty(masterSettings.Main_Mch_ID) || string.IsNullOrEmpty(masterSettings.Main_AppId)) ? new NotifyClient(masterSettings.WeixinAppId, masterSettings.WeixinAppSecret, masterSettings.WeixinPartnerID, masterSettings.WeixinPartnerKey, masterSettings.WeixinPaySignKey, "", "") : new NotifyClient(masterSettings.Main_AppId, masterSettings.WeixinAppSecret, masterSettings.Main_Mch_ID, masterSettings.WeixinPartnerKey, masterSettings.WeixinPaySignKey, masterSettings.WeixinAppId, masterSettings.WeixinPartnerID));
            PayNotify payNotify = notifyClient.GetPayNotify(base.Request.InputStream);

            if (payNotify != null)
            {
                string outTradeNo = payNotify.PayInfo.OutTradeNo;
                this.inpourRequest = MemberProcessor.GetInpourBlance(outTradeNo);
                if (this.inpourRequest == null)
                {
                    base.Response.Write("success");
                }
                else
                {
                    this.Notify_Finished(this.inpourRequest);
                }
            }
        }
Exemplo n.º 4
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();
                    }
                }
            }
        }
Exemplo n.º 5
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            ErrorLog.Write("进入微信扫码支付回调(wx_PayQRcode_notify_url) ...");

            //// 看原始NotifyData
            //string notifyData = "空";
            //if (base.Request.InputStream != null)
            //{
            //    byte[] array = new byte[base.Request.InputStream.Length];
            //    base.Request.InputStream.Read(array, 0, array.Length);
            //    notifyData = Encoding.UTF8.GetString(array);
            //}

            //ErrorLog.Write("微信扫码回调原始数据(wx_PayQRcode_notify_url) :" + notifyData);

            PaymentModeInfo paymentMode = SalesHelper.GetPaymentMode("Ecdev.plugins.payment.WxpayQrCode.QrCodeRequest");
            string          AppId       = "";
            string          Key         = "";
            string          AppSecret   = "";
            string          MchId       = "";

            if (paymentMode != null)
            {
                if (paymentMode.Settings != "")
                {
                    string xml = HiCryptographer.Decrypt(paymentMode.Settings);

                    try
                    {
                        System.Xml.XmlDocument xmlDocument = new System.Xml.XmlDocument();
                        xmlDocument.LoadXml(xml);

                        AppId     = xmlDocument.GetElementsByTagName("AppId")[0].InnerText;
                        Key       = xmlDocument.GetElementsByTagName("Key")[0].InnerText;
                        AppSecret = xmlDocument.GetElementsByTagName("AppSecret")[0].InnerText;
                        MchId     = xmlDocument.GetElementsByTagName("MchId")[0].InnerText;
                    }
                    catch
                    {
                        AppId     = "";
                        Key       = "";
                        AppSecret = "";
                        MchId     = "";

                        ErrorLog.Write("微信扫码回调原始数据(wx_PayQRcode_notify_url) ,支付未配置");
                    }
                }
            }
            NotifyClient notifyClient = new NotifyClient(AppId, AppSecret, MchId, Key, "");

            payNotify = notifyClient.GetPayNotify(base.Request.InputStream);
            if (payNotify == null)
            {
                ErrorLog.Write("微信扫码回调原始数据(wx_PayQRcode_notify_url) ,数据为空");
                return;
            }
            this.OrderId = payNotify.PayInfo.OutTradeNo;
            this.Order   = ShoppingProcessor.GetOrderInfo(this.OrderId);
            if (this.Order == null)
            {
                ErrorLog.Write(string.Format("微信扫码回调原始数据(wx_PayQRcode_notify_url) ,订单不存在,订单号:{0}", this.OrderId));
                base.Response.Write("success");
                return;
            }
            this.Order.GatewayOrderId = payNotify.PayInfo.TransactionId;
            this.UserPayOrder();
        }
Exemplo n.º 6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            this.param = new NameValueCollection
            {
                base.Request.QueryString,
                base.Request.Form
            };
            SiteSettings masterSettings = SettingsManager.GetMasterSettings();
            NotifyClient notifyClient   = null;

            notifyClient = ((string.IsNullOrEmpty(masterSettings.Main_Mch_ID) || string.IsNullOrEmpty(masterSettings.Main_AppId)) ? new NotifyClient(masterSettings.WeixinAppId, masterSettings.WeixinAppSecret, masterSettings.WeixinPartnerID, masterSettings.WeixinPartnerKey, masterSettings.WeixinPaySignKey, "", "") : new NotifyClient(masterSettings.Main_AppId, masterSettings.WeixinAppSecret, masterSettings.Main_Mch_ID, masterSettings.WeixinPartnerKey, masterSettings.WeixinPaySignKey, masterSettings.WeixinAppId, masterSettings.WeixinPartnerID));
            NameValueCollection nameValueCollection = new NameValueCollection
            {
                base.Request.QueryString,
                base.Request.Form
            };
            string    sign      = "";
            PayNotify payNotify = notifyClient.GetPayNotify(base.Request.InputStream);

            if (payNotify == null)
            {
                Globals.AppendLog(this.param, "通知信息为空", sign, "", "AppStore_wxPay");
            }
            else
            {
                this.OrderId      = payNotify.PayInfo.OutTradeNo;
                this.Order        = ShoppingProcessor.GetOrderInfo(this.OrderId);
                this.offlineOrder = StoresHelper.GetStoreCollectionInfo(this.OrderId);
                if (this.Order == null)
                {
                    this.Order = ShoppingProcessor.GetOrderInfo(payNotify.PayInfo.OutTradeNo);
                }
                if (this.offlineOrder == null)
                {
                    this.offlineOrder = StoresHelper.GetStoreCollectionInfo(payNotify.PayInfo.OutTradeNo);
                }
                if (this.Order == null && this.offlineOrder == null)
                {
                    Globals.AppendLog(this.param, "订单信息为空", sign, "", "AppStore_wxPay");
                    base.Response.Write("success");
                }
                else
                {
                    EnumPaymentType enumPaymentType = EnumPaymentType.WXPay;
                    if (this.Order == null)
                    {
                        this.isOfflineOrder = true;
                    }
                    else
                    {
                        this.Order.PaymentTypeId  = (int)enumPaymentType;
                        this.Order.PaymentType    = EnumDescription.GetEnumDescription((Enum)(object)enumPaymentType, 0);
                        this.Order.Gateway        = EnumDescription.GetEnumDescription((Enum)(object)enumPaymentType, 1);
                        this.Order.GatewayOrderId = payNotify.PayInfo.TransactionId;
                        if (this.offlineOrder == null)
                        {
                            this.offlineOrder = StoresHelper.GetStoreCollectionInfoOfOrderId(this.Order.OrderId);
                        }
                    }
                    if (this.offlineOrder != null)
                    {
                        this.offlineOrder.GateWayOrderId  = payNotify.PayInfo.TransactionId;
                        this.offlineOrder.PaymentTypeId   = (int)enumPaymentType;
                        this.offlineOrder.PaymentTypeName = EnumDescription.GetEnumDescription((Enum)(object)enumPaymentType, 0);
                        this.offlineOrder.GateWay         = EnumDescription.GetEnumDescription((Enum)(object)enumPaymentType, 1);
                    }
                    this.UserPayOrder();
                    base.Response.Write("success");
                }
            }
        }
Exemplo n.º 7
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            ErrorLog.Write("进入App微信支付回调(wx_Pay_notify_url) ...");

            //// 看原始NotifyData
            //string notifyData = "空";
            //if (base.Request.InputStream != null)
            //{
            //    StreamReader reader = new StreamReader(base.Request.InputStream, Encoding.GetEncoding("UTF-8"));
            //    notifyData = reader.ReadToEnd();
            //}

            //ErrorLog.Write("App微信支付回调原始数据(wx_Pay_notify_url) :" + notifyData);

            PaymentModeInfo paymentMode = SalesHelper.GetPaymentMode("Ecdev.plugins.payment.wx_apppay.wxwappayrequest");
            string          AppId       = "";
            string          Key         = "";
            string          AppSecret   = "";
            string          Mch_id      = "";

            if (paymentMode != null)
            {
                if (paymentMode.Settings != "")
                {
                    string xml = HiCryptographer.Decrypt(paymentMode.Settings);

                    try
                    {
                        System.Xml.XmlDocument xmlDocument = new System.Xml.XmlDocument();
                        xmlDocument.LoadXml(xml);

                        AppId     = xmlDocument.GetElementsByTagName("AppId")[0].InnerText;
                        Key       = xmlDocument.GetElementsByTagName("Key")[0].InnerText;
                        AppSecret = xmlDocument.GetElementsByTagName("AppSecret")[0].InnerText;
                        Mch_id    = xmlDocument.GetElementsByTagName("Mch_id")[0].InnerText;
                    }
                    catch (System.Exception ex)
                    {
                        ErrorLog.Write("微信App支付回调信息未设置:" + ex.Message);
                    }
                }
            }

            ErrorLog.Write("开始获取App微信支付回调数据(wx_Pay_notify_url) ...");

            NotifyClient notifyClient = new NotifyClient(AppId, AppSecret, Mch_id, Key, "");

            payNotify = notifyClient.GetPayNotify(base.Request.InputStream);
            if (payNotify == null)
            {
                ErrorLog.Write("App微信支付回调数据(wx_Pay_notify_url)为空");
                return;
            }

            this.OrderId = payNotify.PayInfo.OutTradeNo;
            ErrorLog.Write("获取App微信支付回调订单数据(wx_Pay_notify_url):" + this.OrderId);

            this.Order = ShoppingProcessor.GetOrderInfo(this.OrderId);
            if (this.Order == null)
            {
                ErrorLog.Write("App微信支付回调数据(wx_Pay_notify_url)没找到订单:" + this.OrderId);
                base.Response.Write("success");
                return;
            }

            ErrorLog.Write("App微信支付回调数据(wx_Pay_notify_url)交易号:" + payNotify.PayInfo.TransactionId);
            this.Order.GatewayOrderId = payNotify.PayInfo.TransactionId;
            this.Order.PaymentTypeId  = paymentMode.ModeId;
            this.Order.PaymentType    = paymentMode.Name;
            this.Order.Gateway        = paymentMode.Gateway;

            ErrorLog.Write("App微信支付回调数据(wx_Pay_notify_url),设置订单状态:" + this.OrderId);
            this.UserPayOrder();
        }