Пример #1
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");
                }
            }
        }
Пример #2
0
        protected override void AttachChildControls()
        {
            this.isOffline      = this.Page.Request["IsOffline"].ToBool();
            this.orderId        = Globals.StripAllTags(this.Page.Request.QueryString["orderId"].ToNullString());
            this.litOrderId     = (Literal)this.FindControl("litOrderId");
            this.litOrderTotal  = (Literal)this.FindControl("litOrderTotal");
            this.litPaymentType = (HtmlInputHidden)this.FindControl("litPaymentType");
            this.litPaymentName = (Literal)this.FindControl("litPaymentName");
            this.linkToDetail   = (HtmlAnchor)this.FindControl("linkToDetail");
            this.litErrorMsg    = (Literal)this.FindControl("litErrorMsg");
            this.loadPanel      = (HtmlGenericControl)this.FindControl("loadPanel");
            this.errorPanel     = (HtmlGenericControl)this.FindControl("errorPanel");
            this.btnToPay       = (HtmlAnchor)this.FindControl("btnToPay");
            SiteSettings masterSettings = SettingsManager.GetMasterSettings();
            string       text           = "";
            string       userAgent      = HttpContext.Current.Request.UserAgent;

            this.loadPanel.Visible = true;
            StoreCollectionInfo storeCollectionInfo = null;

            if (this.isOffline)
            {
                storeCollectionInfo = StoresHelper.GetStoreCollectionInfo(this.orderId);
                if (storeCollectionInfo == null)
                {
                    this.litErrorMsg.Text   = "错误的订单编号";
                    this.loadPanel.Visible  = false;
                    this.errorPanel.Visible = true;
                    return;
                }
                if (storeCollectionInfo.Status != 0)
                {
                    this.litErrorMsg.Text   = "订单状态不是待支付状态";
                    this.loadPanel.Visible  = false;
                    this.errorPanel.Visible = true;
                    return;
                }
                if (this.linkToDetail != null)
                {
                    this.linkToDetail.Visible = false;
                }
            }
            else
            {
                this.order = ShoppingProcessor.GetOrderInfo(this.orderId);
                if (this.order == null)
                {
                    this.litErrorMsg.Text   = "错误的订单编号";
                    this.loadPanel.Visible  = false;
                    this.errorPanel.Visible = true;
                    return;
                }
                if (this.order.OrderStatus != OrderStatus.WaitBuyerPay)
                {
                    this.litErrorMsg.Text   = "订单状态不是待支付状态";
                    this.loadPanel.Visible  = false;
                    this.errorPanel.Visible = true;
                    return;
                }
                storeCollectionInfo      = StoresHelper.GetStoreCollectionInfoOfOrderId(this.orderId);
                this.litPaymentName.Text = this.order.PaymentType;
                this.litPaymentType.SetWhenIsNotNull(this.order.PaymentTypeId.ToString());
                this.litOrderId.SetWhenIsNotNull(this.orderId);
                this.litOrderTotal.SetWhenIsNotNull(this.order.GetTotal(false).F2ToString("f2"));
                if (this.linkToDetail != null)
                {
                    this.linkToDetail.Visible = true;
                    this.linkToDetail.HRef    = "MemberOrderDetails?OrderId=" + this.orderId;
                }
            }
            if (base.ClientType == ClientType.VShop)
            {
                if (!string.IsNullOrEmpty(masterSettings.WeixinAppId) && !string.IsNullOrEmpty(masterSettings.WeixinAppSecret) && !string.IsNullOrEmpty(masterSettings.WeixinPartnerID) && !string.IsNullOrEmpty(masterSettings.WeixinPartnerKey))
                {
                    if (!this.isOffline)
                    {
                        this.order.Gateway       = "hishop.plugins.payment.weixinrequest";
                        this.order.PaymentTypeId = -2;
                        this.order.PaymentType   = "微信支付";
                        TradeHelper.UpdateOrderPaymentType(this.order);
                    }
                    if (storeCollectionInfo != null)
                    {
                        storeCollectionInfo.GateWay         = "hishop.plugins.payment.weixinrequest";
                        storeCollectionInfo.PaymentTypeName = "微信支付";
                        storeCollectionInfo.PaymentTypeId   = 1;
                        StoresHelper.UpdateStoreCollectionInfo(storeCollectionInfo);
                    }
                    HttpContext.Current.Response.Redirect("~/pay/wx_Submit?orderId=" + this.orderId + "&IsOffline=" + this.isOffline.ToString() + "&from=appstore");
                }
                else
                {
                    this.litErrorMsg.Text   = "未配置微信支付";
                    this.loadPanel.Visible  = false;
                    this.errorPanel.Visible = true;
                }
            }
            else
            {
                PaymentModeInfo paymentMode = ShoppingProcessor.GetPaymentMode("hishop.plugins.payment.ws_wappay.wswappayrequest");
                if (paymentMode != null)
                {
                    decimal  amount     = default(decimal);
                    string   subject    = "门店APP订单支付";
                    string   buyerEmail = "";
                    DateTime date       = DateTime.Now;
                    if (!this.isOffline)
                    {
                        subject                  = "门店APP线下支付";
                        text                     = paymentMode.Gateway;
                        this.order.Gateway       = paymentMode.Gateway;
                        this.order.PaymentTypeId = paymentMode.ModeId;
                        this.order.PaymentType   = paymentMode.Name;
                        TradeHelper.UpdateOrderPaymentType(this.order);
                        amount     = this.order.GetTotal(false);
                        buyerEmail = this.order.EmailAddress;
                        date       = this.order.OrderDate;
                    }
                    if (storeCollectionInfo != null)
                    {
                        amount = storeCollectionInfo.PayAmount;
                        storeCollectionInfo.GateWay         = paymentMode.Gateway;
                        storeCollectionInfo.PaymentTypeName = paymentMode.Name;
                        storeCollectionInfo.PaymentTypeId   = 2;
                        StoresHelper.UpdateStoreCollectionInfo(storeCollectionInfo);
                        date = storeCollectionInfo.CreateTime;
                    }
                    string         attach         = "";
                    string         showUrl        = string.Format("http://{0}/{1}/", HttpContext.Current.Request.Url.Host, "AliOH");
                    PaymentRequest paymentRequest = PaymentRequest.CreateInstance(paymentMode.Gateway, HiCryptographer.Decrypt(paymentMode.Settings), this.orderId, amount, subject, "订单号-" + this.orderId, buyerEmail, date, showUrl, Globals.FullPath("/pay/appstore_wapalipay_return_url"), Globals.FullPath("/pay/appstore_wapalipay_notify_url"), attach);
                    paymentRequest.SendRequest();
                }
                else
                {
                    this.litErrorMsg.Text   = "未配置支付宝网页支付";
                    this.loadPanel.Visible  = false;
                    this.errorPanel.Visible = true;
                }
            }
        }
		protected void Page_Load(object sender, EventArgs e)
		{
			NameValueCollection nameValueCollection = new NameValueCollection
			{
				this.Page.Request.Form,
				this.Page.Request.QueryString
			};
			this.Gateway = "hishop.plugins.payment.ws_wappay.wswappayrequest";
			this.Notify = PaymentNotify.CreateInstance(this.Gateway, nameValueCollection);
			this.OrderId = this.Notify.GetOrderId();
			this.Order = ShoppingProcessor.GetOrderInfo(this.OrderId);
			this.offlineOrder = StoresHelper.GetStoreCollectionInfo(this.OrderId);
			if (this.Order == null && this.offlineOrder == null)
			{
				Globals.AppendLog(nameValueCollection, "通知信息为空", "", "", "AppStore_wxPay");
				base.Response.Write("success");
			}
			else
			{
				PaymentModeInfo paymentMode = ShoppingProcessor.GetPaymentMode("hishop.plugins.payment.ws_wappay.wswappayrequest");
				if (paymentMode == null)
				{
					Globals.WriteLog(nameValueCollection, "支付方式获取失败hishop.plugins.payment.ws_wappay.wswappayrequest", "", "", "alipay");
					base.Response.Write("success");
				}
				else
				{
					this.Amount = this.Notify.GetOrderAmount();
					if (this.Order == null)
					{
						this.isOfflineOrder = true;
					}
					else
					{
						if (this.Amount <= decimal.Zero)
						{
							this.Amount = this.Order.GetTotal(true);
						}
						this.offlineOrder = StoresHelper.GetStoreCollectionInfoOfOrderId(this.OrderId);
						this.Order.GatewayOrderId = this.Notify.GetGatewayOrderId();
						this.Order.PaymentType = paymentMode.Name;
						this.Order.PaymentTypeId = 2;
						this.Order.Gateway = paymentMode.Gateway;
						if (this.offlineOrder == null)
						{
							this.offlineOrder = StoresHelper.GetStoreCollectionInfoOfOrderId(this.Order.OrderId);
						}
					}
					if (this.offlineOrder != null)
					{
						if (this.Amount <= decimal.Zero)
						{
							this.Amount = this.offlineOrder.PayAmount;
						}
						this.offlineOrder.GateWayOrderId = this.Notify.GetGatewayOrderId();
						this.offlineOrder.PaymentTypeId = 2;
						this.offlineOrder.PaymentTypeName = paymentMode.Name;
						this.offlineOrder.GateWay = paymentMode.Gateway;
					}
					this.Notify.Finished += this.Notify_Finished;
					this.Notify.NotifyVerifyFaild += this.Notify_NotifyVerifyFaild;
					this.Notify.Payment += this.Notify_Payment;
					this.Notify.VerifyNotify(30000, HiCryptographer.Decrypt(paymentMode.Settings));
				}
			}
		}
        protected void Page_Load(object sender, EventArgs e)
        {
            base.Response.Write("<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no\"/>");
            NameValueCollection nameValueCollection = new NameValueCollection
            {
                this.Page.Request.Form,
                this.Page.Request.QueryString
            };

            nameValueCollection.Add("IsReturn", "true");
            this.Gateway      = "hishop.plugins.payment.ws_wappay.wswappayrequest";
            this.Notify       = PaymentNotify.CreateInstance(this.Gateway, nameValueCollection);
            this.OrderId      = this.Notify.GetOrderId();
            this.Order        = ShoppingProcessor.GetOrderInfo(this.OrderId);
            this.offlineOrder = StoresHelper.GetStoreCollectionInfo(this.OrderId);
            if (this.Order == null && this.offlineOrder == null)
            {
                base.Response.Write("success");
            }
            else
            {
                PaymentModeInfo paymentMode = ShoppingProcessor.GetPaymentMode("hishop.plugins.payment.ws_wappay.wswappayrequest");
                if (paymentMode == null)
                {
                    Globals.WriteLog(nameValueCollection, "支付方式获取失败hishop.plugins.payment.ws_wappay.wswappayrequest", "", "", "alipay");
                    base.Response.Write("success");
                }
                else
                {
                    this.Amount = this.Notify.GetOrderAmount();
                    if (this.Order == null)
                    {
                        this.isOfflineOrder = true;
                    }
                    else
                    {
                        if (this.Amount <= decimal.Zero)
                        {
                            this.Amount = this.Order.GetTotal(true);
                        }
                        this.offlineOrder         = StoresHelper.GetStoreCollectionInfoOfOrderId(this.OrderId);
                        this.Order.GatewayOrderId = this.Notify.GetGatewayOrderId();
                        this.Order.PaymentType    = paymentMode.Name;
                        this.Order.PaymentTypeId  = paymentMode.ModeId;
                        this.Order.Gateway        = paymentMode.Gateway;
                        if (this.offlineOrder == null)
                        {
                            this.offlineOrder = StoresHelper.GetStoreCollectionInfoOfOrderId(this.Order.OrderId);
                        }
                    }
                    if (this.offlineOrder != null)
                    {
                        if (this.Amount <= decimal.Zero)
                        {
                            this.Amount = this.offlineOrder.PayAmount;
                        }
                        this.offlineOrder.GateWayOrderId  = this.Notify.GetGatewayOrderId();
                        this.offlineOrder.PaymentTypeId   = paymentMode.ModeId;
                        this.offlineOrder.PaymentTypeName = paymentMode.Name;
                        this.offlineOrder.GateWay         = paymentMode.Gateway;
                    }
                    this.Notify.Finished          += this.Notify_Finished;
                    this.Notify.NotifyVerifyFaild += this.Notify_NotifyVerifyFaild;
                    this.Notify.Payment           += this.Notify_Payment;
                    this.Notify.VerifyNotify(30000, HiCryptographer.Decrypt(paymentMode.Settings));
                }
            }
        }