Пример #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string cur_order_id = this.Request["order_id"];

            if (!bllPay.IsMobile)
            {
                errorMsg = "请用手机浏览器访问";
                return;
            }
            if (string.IsNullOrWhiteSpace(cur_order_id))
            {
                errorMsg = "订单号未找到";
                return;
            }
            orderPay = bllOrder.GetOrderPay(cur_order_id, websiteOwner: bllOrder.WebsiteOwner, payType: 1);
            if (orderPay == null)
            {
                errorMsg = "订单未找到";
                return;
            }
            if (orderPay.Status == 1)
            {
                errorMsg = "订单已经付款";
                //formString = "<div style=\"height:100%;color:red;font-size:24px;text-algin:center;\">订单已经付款</div>";
                return;
            }
            if (bllPay.IsWeiXinBrowser)
            {
                return;
            }

            try
            {
                PayConfig payConfig  = bllPay.GetPayConfig();
                string    baseUrl    = string.Format("http://{0}", this.Request.Url.Authority);
                string    notifyUrl  = baseUrl + "/Alipay/ShMemberNotifyUrl.aspx";
                string    formString = bllPay.GetAliPayRequestMobile(orderPay.OrderId, (double)orderPay.Total_Fee,
                                                                     payConfig.Seller_Account_Name, payConfig.Partner, payConfig.PartnerKey, notifyUrl);
                Response.Write(formString);
            }
            catch (Exception ex)
            {
                errorMsg = "支付页生成失败";
            }
        }
Пример #2
0
        /// <summary>
        /// 支付宝支付
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        private string BuildAlipayRequest(HttpContext context)
        {
            string orderId = context.Request["order_id"];

            if (bllPay.IsWeiXinBrowser)
            {
                resp.errcode = 1;
                resp.errmsg  = "请不要在微信中打开";
                return(ZentCloud.Common.JSONHelper.ObjectToJson(resp));
            }
            if (!bllPay.IsMobile)
            {
                resp.errcode = 1;
                resp.errmsg  = "请用手机浏览器访问";
                return(ZentCloud.Common.JSONHelper.ObjectToJson(resp));
            }
            if (string.IsNullOrEmpty(orderId))
            {
                resp.errcode = 1;
                resp.errmsg  = "order_id 必传";
                return(ZentCloud.Common.JSONHelper.ObjectToJson(resp));
            }
            var orderInfo = bllMall.GetOrderInfo(orderId);

            if (orderInfo == null)
            {
                resp.errcode = 1;
                resp.errmsg  = "订单号不存在";
                return(ZentCloud.Common.JSONHelper.ObjectToJson(resp));
            }
            //if (orderInfo.OrderUserID != CurrentUserInfo.UserID)
            //{
            //    resp.errcode = 1;
            //    resp.errmsg = "订单号无效";
            //    return ZentCloud.Common.JSONHelper.ObjectToJson(resp);
            //}
            if (orderInfo.PaymentStatus == 1)
            {
                resp.errcode = 1;
                resp.errmsg  = "订单已经支付,不需重复支付";
                return(ZentCloud.Common.JSONHelper.ObjectToJson(resp));
            }

            //更改支付方式
            bllMall.Update(orderInfo, " PaymentType=1 ", string.Format(" (OrderID = '{0}' Or ParentOrderId='{0}') ", orderInfo.OrderID));

            PayConfig payConfig = bllPay.GetPayConfig();

            if (payConfig == null)
            {
                resp.errcode = 1;
                resp.errmsg  = "请先填写支付配置信息";
                return(ZentCloud.Common.JSONHelper.ObjectToJson(resp));
            }
            if ((string.IsNullOrEmpty(payConfig.Seller_Account_Name)) || (string.IsNullOrEmpty(payConfig.Partner)) || (string.IsNullOrEmpty(payConfig.PartnerKey)))
            {
                resp.errcode = 1;
                resp.errmsg  = "请先填写支付配置信息";
                return(ZentCloud.Common.JSONHelper.ObjectToJson(resp));
            }
            string notifyUrl = baseUrl + "/Alipay/MallNotifyUrlV2.aspx";
            var    payForm   = bllPay.GetAliPayRequestMobile(orderInfo.OrderID, (double)orderInfo.TotalAmount, payConfig.Seller_Account_Name, payConfig.Partner, payConfig.PartnerKey, notifyUrl);


            if (!string.IsNullOrEmpty(payForm))
            {
                return(ZentCloud.Common.JSONHelper.ObjectToJson(new
                {
                    errcode = 0,
                    pay_req = payForm
                }));
            }
            resp.errcode = 1;
            resp.errmsg  = "fail";
            return(ZentCloud.Common.JSONHelper.ObjectToJson(resp));
        }