Example #1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (string.IsNullOrEmpty(PayNo))
            {
                function.WriteErrMsg("请传入订单号");
            }
            payMod = paymentBll.SelModelByPayNo(PayNo);
            if (payMod == null || payMod.PaymentID < 1)
            {
                function.WriteErrMsg("支付单不存在");
            }
            //Remind_L.Text=payMod.MoneyPay.ToString()+":"+payMod.PayNo;
            try
            {
                TimeSpan ts = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0);
                timestr = Convert.ToInt64(ts.TotalSeconds).ToString();
                WeiXinPay();

                string stringA        = "appId=" + WxPayConfig.APPID + "&nonceStr=" + nonceStr + "&package=prepay_id=" + prepay_id + "&signType=MD5&timeStamp=" + timestr;
                string stringSignTemp = stringA + "&key=" + WxPayConfig.KEY;
                //BVowfoezoomlahx008flwelfwefweoif
                paySign = StringHelper.MD5(stringSignTemp).ToUpper();
            }
            catch (Exception ex) { Remind_L.Text = ex.Message; }
        }
    }
Example #2
0
 protected void Page_Load(object sender, EventArgs e)
 {
     B_User.CheckIsLogged(Request.RawUrl);
     if (!IsPostBack)
     {
         M_Payment payMod  = new M_Payment();
         DataTable orderDT = new DataTable();
         purseli.Visible = SiteConfig.SiteOption.SiteID.Contains("purse");
         siconli.Visible = SiteConfig.SiteOption.SiteID.Contains("sicon");
         pointli.Visible = SiteConfig.SiteOption.SiteID.Contains("point");
         if (Money > 0)//直接传要充多少,用于充值余额等,生成一条临时记录
         {
             virtual_ul.Visible = false;
             orderDT            = orderBll.GetOrderbyOrderNo("-1");
             DataRow dr = orderDT.NewRow();
             dr["Balance_price"] = Money;
             dr["Freight"]       = 0;
             dr["Ordersamount"]  = Money;
             orderDT.Rows.Add(dr);
         }
         else if (!string.IsNullOrEmpty(PayNo))
         {
             payMod = payBll.SelModelByPayNo(PayNo);
             OrderHelper.OrdersCheck(payMod);
             orderDT = orderBll.GetOrderbyOrderNo(payMod.PaymentNum);
         }
         else
         {
             M_OrderList orderMod = orderBll.SelModelByOrderNo(OrderNo);
             OrderHelper.OrdersCheck(orderMod);
             orderDT = orderBll.GetOrderbyOrderNo(OrderNo);
         }
         if (orderDT != null && orderDT.Rows.Count > 0)
         {
             //如果是跳转回来的,检测其是否包含充值订单
             foreach (DataRow dr in orderDT.Rows)
             {
                 if (DataConverter.CLng(dr["Ordertype"]) == (int)M_OrderList.OrderEnum.Purse)
                 {
                     virtual_ul.Visible = false; break;
                 }
             }
             //总金额,如有支付单,以支付单的为准
             GetTotal(orderDT, ref price, ref fare, ref allamount);
             if (!string.IsNullOrEmpty(PayNo))
             {
                 allamount = (double)payMod.MoneyPay;
                 arrive    = payMod.ArriveMoney;
             }
             TxtvMoney.Text = price.ToString("f2");// + " + " + fare.ToString("f2") + " - " + arrive.ToString("f2") + " = " + allamount.ToString("f2")
             TxtvMoney.Text = TxtvMoney.Text + "";
             OrderCode.Text = OrderNo;
         }
         //支付币种
         //BindMoney();
         //支付平台
         BindPlat();
     }
 }
Example #3
0
    //支付成功时执行的操作
    private void PayOrder_Success(WxPayData result)
    {
        ZLLog.L(ZLEnum.Log.pay, PayPlat + " 支付单:" + result.GetValue("out_trade_no") + " 金额:" + result.GetValue("total_fee"));
        try
        {
            M_Order_PayLog paylogMod = new M_Order_PayLog();
            M_Payment      pinfo     = payBll.SelModelByPayNo(result.GetValue("out_trade_no").ToString());
            if (pinfo == null)
            {
                throw new Exception("支付单不存在");
            }                                                    //支付单检测合为一个方法
            if (pinfo.Status != (int)M_Payment.PayStatus.NoPay)
            {
                throw new Exception("支付单状态不为未支付");
            }
            pinfo.Status       = (int)M_Payment.PayStatus.HasPayed;
            pinfo.PlatformInfo = PayPlat;
            pinfo.SuccessTime  = DateTime.Now;
            pinfo.PayTime      = DateTime.Now;
            pinfo.CStatus      = true;
            //1=100,
            double tradeAmt = Convert.ToDouble(result.GetValue("total_fee")) / 100;
            pinfo.MoneyTrue = tradeAmt;
            payBll.Update(pinfo);
            DataTable orderDT = orderBll.GetOrderbyOrderNo(pinfo.PaymentNum);
            foreach (DataRow dr in orderDT.Rows)
            {
                M_OrderList orderMod = orderBll.SelModelByOrderNo(dr["OrderNo"].ToString());
                OrderHelper.FinalStep(pinfo, orderMod, paylogMod);
                //if (orderMod.Ordertype == (int)M_OrderList.OrderEnum.Purse)
                //{

                //    M_UserInfo mu = buser.SelReturnModel(orderMod.Userid);
                //    new B_Shop_MoneyRegular().AddMoneyByMin(mu, orderMod.Ordersamount, ",订单号[" + orderMod.OrderNo + "]");
                //}
                orderCom.SendMessage(orderMod, paylogMod, "payed");
                //orderCom.SaveSnapShot(orderMod);
                //发送微信消息
                B_UserAPP  userappBll = new B_UserAPP();
                M_UserAPP  userappMod = new M_UserAPP();
                M_UserInfo mu         = buser.GetUserByUserID(orderMod.Userid);
                userappMod = userappBll.SelModelByUid(mu.UserID, "wechat");
                if (userappMod != null)
                {
                    WxAPI  wxapi = WxAPI.Code_Get(1);
                    string json  = "{\"first\":{\"value\":\"您已成功支付" + orderMod.Ordersamount.ToString("0.00") + "元\",\"color\":\"#000\"},\"DateTime\":{\"value\":\"" + DateTime.Now.ToString("yyyy年MM月dd日 HH:mm:ss") + "\",\"color\":\"#173177\"},\"PayAmount\":{\"value\":\"" + orderMod.Ordersamount.ToString("0.00") + "元\",\"color\":\"#173177\"},\"remark\":{\"value\":\"您的订单已成功付款!订单号:" + orderMod.OrderNo + "\",\"color\":\"#173177\"}}";
                    wxapi.Tlp_SendTlpMsg(userappMod.OpenID, "jAP4eGIOPvCdg33KBVDcClxRGYNNgcUpmHlVdO_FRV0", SiteConfig.SiteInfo.SiteUrl + "/User/Order/OrderProList?OrderNo=" + orderMod.OrderNo, json);
                }
            }
            ZLLog.L(ZLEnum.Log.pay, PayPlat + "成功!支付单:" + result.GetValue("out_trade_no").ToString());
        }
        catch (Exception ex)
        {
            ZLLog.L(ZLEnum.Log.pay, new M_Log()
            {
                Action  = "支付回调报错",
                Message = PayPlat + ",支付单:" + result.GetValue("out_trade_no").ToString() + ",原因:" + ex.Message
            });
        }
    }
Example #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (function.isAjax())
            {
                string action = Request.Form["action"];
                string result = "";
                switch (action)
                {
                case "getpay":
                    M_Payment paymod = payBll.SelModelByPayNo(PayNo);
                    if (paymod.Status == (int)M_Payment.PayStatus.HasPayed)
                    {
                        DataTable   orderDT  = orderBll.GetOrderbyOrderNo(paymod.PaymentNum);
                        M_OrderList ordermod = orderBll.SelModelByOrderNo(orderDT.Rows[0]["OrderNo"].ToString());
                        if ((int)M_OrderList.OrderEnum.Purse == ordermod.Ordertype)
                        {
                            result = "/user/Info/UserInfo";
                        }
                        else
                        {
                            result = "/User/Order/OrderProList?OrderNo=" + paymod.PaymentNum;
                        }
                    }
                    else
                    {
                        result = "0";
                    }
                    break;

                default:
                    break;
                }
                Response.Write(result); Response.Flush(); Response.End();
            }
            if (!IsPostBack)
            {
                if (string.IsNullOrEmpty(PayNo))
                {
                    function.WriteErrMsg("未指定支付单号");
                }
                if (string.IsNullOrEmpty(Request.QueryString["wxcode"]))
                {
                    function.WriteErrMsg("未指定二维码");
                }
                MyBind();
            }
        }
Example #5
0
        public string ProcessNotify()
        {
            //如果有多个公众号支付,此处要取返回中的公众号ID,再取Key验证
            WxPayData notifyData = wxnotify.GetNotifyData();
            WxPayData res        = GetWxDataMod();

            //检查支付结果中transaction_id是否存在
            if (!notifyData.IsSet("out_trade_no"))
            {
                //若transaction_id不存在,则立即返回结果给微信支付后台
                res.SetValue("return_code", "FAIL");
                res.SetValue("return_msg", "支付结果中订单号不存在");
                ZLLog.L(ZLEnum.Log.pay, new M_Log()
                {
                    Action  = "支付平台异常",
                    Message = PayPlat + ",原因:支付结果中订单号不存在!XML:" + notifyData.ToXml()
                });
                return(res.ToXml());
            }
            string transaction_id = notifyData.GetValue("out_trade_no").ToString();
            //查询订单,判断订单真实性
            //if (!QueryOrder(transaction_id))
            //{
            //    //若订单查询失败,则立即返回结果给微信支付后台
            //    WxPayData res = GetWxDataMod();
            //    res.SetValue("return_code", "FAIL");
            //    res.SetValue("return_msg", "订单查询失败");
            //    ZLLog.L(ZLEnum.Log.pay, new M_Log()
            //    {
            //        Action = "支付平台异常",
            //        Message = PayPlat + ",支付单:" + transaction_id + ",原因:订单查询失败!XML:" + notifyData.ToXml()
            //    });
            //    return res.ToXml();
            //}
            //查询订单成功
            //else
            //{
            //}
            //未指定,则默认加载PC扫码配置
            M_Payment  pinfo  = payBll.SelModelByPayNo(notifyData.GetValue("out_trade_no").ToString());
            M_WX_APPID appMod = WxPayApi.Pay_GetByID(DataConvert.CLng(pinfo.PlatformInfo));

            notifyData.PayKey = appMod.Pay_Key;
            try
            {
                notifyData.CheckSign();
                PayOrder_Success(pinfo, notifyData);
            }
            catch (Exception ex)
            {
                ZLLog.L(ZLEnum.Log.pay, new M_Log()
                {
                    Action = PayPlat + "报错,支付单:" + transaction_id, Message = ex.Message + "||XML:" + notifyData.ToXml()
                });
            }
            res.SetValue("return_code", "SUCCESS");
            res.SetValue("return_msg", "OK");
            return(res.ToXml());
        }
Example #6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            M_PayPlat platmod  = platBll.SelModelByClass(M_PayPlat.Plat.ECPSS);
            string    md5key   = platmod.MD5Key;
            string    billno   = Request["BillNo"];
            string    amount   = Request["Amount"];
            string    result   = Request["Result"];
            string    Succeed  = Request["Succeed"];
            string    signinfo = Request["SignMD5info"];
            string    md5src   = billno + "&" + amount + "&" + Succeed + "&" + md5key;

            if (signinfo.Equals(FormsAuthentication.HashPasswordForStoringInConfigFile(md5src, "MD5")))
            {
                ZLLog.L(ZLEnum.Log.pay, "汇潮支付 交易状态:" + result + " 支付单:" + billno + " 金额:" + amount);
                if (!Succeed.Equals("88"))
                {
                    ZLLog.L(ZLEnum.Log.pay, "贝付交易失败!支付单:" + billno); return;
                }
                try
                {
                    M_Payment pinfo = payBll.SelModelByPayNo(billno);
                    if (pinfo.Status != (int)M_Payment.PayStatus.NoPay)
                    {
                        return;
                    }
                    pinfo.Status       = (int)M_Payment.PayStatus.HasPayed;
                    pinfo.PlatformInfo = "汇潮支付";       //平台反馈信息
                    pinfo.SuccessTime  = DateTime.Now; //交易成功时间
                    pinfo.CStatus      = true;         //处理状态
                    pinfo.MoneyTrue    = Convert.ToDouble(amount);
                    payBll.Update(pinfo);
                    DataTable orderDT = orderBll.GetOrderbyOrderNo(pinfo.PaymentNum);
                    foreach (DataRow dr in orderDT.Rows)
                    {
                        M_Order_PayLog paylogMod = new M_Order_PayLog();
                        M_OrderList    orderMod  = orderBll.SelModelByOrderNo(dr["OrderNo"].ToString());
                        OrderHelper.FinalStep(pinfo, orderMod, paylogMod);
                    }
                    Response.Write("ok");
                    ZLLog.L(ZLEnum.Log.pay, "汇潮平台支付成功!支付单:" + billno);
                }
                catch (Exception ex)
                {
                    ZLLog.L(ZLEnum.Log.pay, new M_Log()
                    {
                        Action  = "支付回调报错",
                        Message = "平台:汇潮,支付单:" + billno + ",原因:" + ex.Message
                    });
                    Response.Write("erro");
                }
            }
            else
            {
                ZLLog.L(ZLEnum.Log.safe, "汇潮验证失败!支付单:" + billno);
                Response.Write("erro");
            }
        }
Example #7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            payMod = payBll.SelModelByPayNo(PayNo);
            CommonReturn retMod = payBll.IsCanPay(payMod);

            if (!retMod.isok)
            {
                function.WriteErrMsg("Orders are not allowed to be paid"); ZLLog.L(retMod.err);
            }
            //-----------------------
            ZoomLa.BLL.Pay.ZLPayPal.PayPalHelper.RedirectToPay(payMod);
        }
Example #8
0
        //----------------------------订单申请退款
        public IActionResult DrawBack()
        {
            M_OrderList orderMod = orderBll.SelReturnModel(Mid);

            if (!DrawBackCheck(orderMod, ref err))
            {
                return(WriteErr(err));
            }
            M_Payment payMod = payBll.SelModelByPayNo(orderMod.PaymentNo);

            orderMod.Ordersamount = payMod.MoneyTrue;
            return(View(orderMod));
        }
Example #9
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (string.IsNullOrEmpty(PayNo))
     {
         function.WriteErrMsg("Unspecified order number");
     }
     pinfo = paymentBll.SelModelByPayNo(PayNo);
     if (pinfo == null || pinfo.PaymentID < 1)
     {
         function.WriteErrMsg("Order does not exist");
     }
     Response.Redirect("PP/Pay.aspx?Payno=" + pinfo.PayNo);
 }
Example #10
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (function.isAjax())
        {
            string action = Request.Form["action"];
            string result = "";
            switch (action)
            {
            case "getpay":
                M_Payment paymod = payBll.SelModelByPayNo(PayNo);
                if (paymod.Status == (int)M_Payment.PayStatus.HasPayed)
                {
                    result = "1";
                }
                else
                {
                    result = "0";
                }
                break;

            default:
                break;
            }
            Response.Write(result); Response.Flush(); Response.End();
        }
        if (!IsPostBack)
        {
            if (string.IsNullOrEmpty(PayNo))
            {
                function.WriteErrMsg("未指定支付单号");
            }
            if (string.IsNullOrEmpty(Request.QueryString["wxcode"]))
            {
                function.WriteErrMsg("未指定二维码");
            }
            MyBind();
        }
    }
Example #11
0
    public void WeiXinPay()
    {
        M_Payment payMod = payBll.SelModelByPayNo(PayNo);

        if (string.IsNullOrEmpty(PayNo))
        {
            function.WriteErrMsg("0x53,支付单号或为空");
        }
        else if (payMod == null)
        {
            function.WriteErrMsg("支付单号不存在");
        }
        else if (payMod.Status != (int)M_Payment.PayStatus.NoPay)
        {
            function.WriteErrMsg("0x14,支付单已付过款,不能重复支付");
        }
        else if (payMod.MoneyReal <= 0)
        {
            function.WriteErrMsg("0x56,支付单金额异常");
        }

        string  code      = Request.QueryString["code"];
        string  resultStr = APIHelper.GetWebResult("https://api.weixin.qq.com/sns/oauth2/access_token?appid=" + appMod.APPID + "&secret=" + appMod.Secret + "&code=" + code + "&grant_type=authorization_code");
        JObject obj       = (JObject)JsonConvert.DeserializeObject(resultStr);

        if (AppID > 1)
        {
            notifyUrl = SiteConfig.SiteInfo.SiteUrl + "/payonline/return/WxPayReturn1.aspx";
        }

        WxPayData wxdata = new WxPayData();

        wxdata.SetValue("out_trade_no", payMod.PayNo);
        wxdata.SetValue("body", payMod.Remark);
        wxdata.SetValue("total_fee", (int)(payMod.MoneyReal * 100));
        wxdata.SetValue("trade_type", "JSAPI");
        wxdata.SetValue("notify_url", notifyUrl);
        wxdata.SetValue("product_id", payMod.PayNo);         //必填
        wxdata.SetValue("openid", obj["openid"].ToString()); //公众号支付必填
        wxdata.SetValue("nonce_str", WxAPI.nonce);

        //获取预支付单号
        WxPayData result = WxPayApi.UnifiedOrder(wxdata, appMod);

        if (result.GetValue("return_code").ToString().Equals("FAIL"))
        {
            function.WriteErrMsg("商户" + result.GetValue("return_msg"));
        }
        prepay_id = result.GetValue("prepay_id").ToString();
    }
Example #12
0
    public string GetTureMoney(string OrderNo)
    {
        M_OrderList orderMod = new M_OrderList();

        orderMod = orderBll.SelModelByOrderNo(OrderNo);
        double    allamount = orderMod.Ordersamount;
        DataTable dt1       = SqlHelper.ExecuteTable("select * from ZL_Payment where PaymentNum='" + orderMod.OrderNo + "' order by PayTime DESC");

        if (dt1.Rows.Count > 0)
        {
            payMod    = payBll.SelModelByPayNo(dt1.Rows[0]["PayNo"].ToString());
            allamount = (double)payMod.MoneyPay;
        }
        return(allamount.ToString("f2"));
    }
Example #13
0
 //支付成功时执行的操作
 private void PayOrder_Success(WxPayData result)
 {
     ZLLog.L(ZLEnum.Log.pay, PayPlat + " 支付单:" + result.GetValue("out_trade_no") + " 金额:" + result.GetValue("total_fee"));
     try
     {
         M_Order_PayLog paylogMod = new M_Order_PayLog();
         M_Payment      pinfo     = payBll.SelModelByPayNo(result.GetValue("out_trade_no").ToString());
         if (pinfo == null)
         {
             throw new Exception("支付单不存在");
         }                                                    //支付单检测合为一个方法
         if (pinfo.Status != (int)M_Payment.PayStatus.NoPay)
         {
             throw new Exception("支付单状态不为未支付");
         }
         pinfo.Status       = (int)M_Payment.PayStatus.HasPayed;
         pinfo.PlatformInfo = PayPlat;
         pinfo.SuccessTime  = DateTime.Now;
         pinfo.PayTime      = DateTime.Now;
         pinfo.CStatus      = true;
         //1=100,
         double tradeAmt = Convert.ToDouble(result.GetValue("total_fee")) / 100;
         pinfo.MoneyTrue = tradeAmt;
         payBll.Update(pinfo);
         DataTable orderDT = orderBll.GetOrderbyOrderNo(pinfo.PaymentNum);
         foreach (DataRow dr in orderDT.Rows)
         {
             M_OrderList orderMod = orderBll.SelModelByOrderNo(dr["OrderNo"].ToString());
             OrderHelper.FinalStep(pinfo, orderMod, paylogMod);
             orderCom.SendMessage(orderMod, paylogMod, "payed");
             //orderCom.SaveSnapShot(orderMod);
         }
         ZLLog.L(ZLEnum.Log.pay, PayPlat + "支付成功,支付单:" + result.GetValue("out_trade_no").ToString());
     }
     catch (Exception ex)
     {
         ZLLog.L(ZLEnum.Log.pay, new M_Log()
         {
             Action  = "支付回调报错",
             Message = PayPlat + ",支付单:" + result.GetValue("out_trade_no").ToString() + ",原因:" + ex.Message
         });
     }
 }
        //宝付用户回调显示页
        protected void Page_Load(object sender, EventArgs e)
        {
            string    MemberID       = Request.Params["MemberID"];          //商户号
            string    TerminalID     = Request.Params["TerminalID"];        //商户终端号
            string    TransID        = Request.Params["TransID"];           //商户流水号
            string    Result         = Request.Params["Result"];            //支付结果(1:成功,0:失败)
            string    ResultDesc     = Request.Params["ResultDesc"];        //支付结果描述
            string    FactMoney      = Request.Params["FactMoney"];         //实际成交金额
            string    AdditionalInfo = Request.Params["AdditionalInfo"];    //订单附加消息
            string    SuccTime       = Request.Params["SuccTime"];          //交易成功时间
            string    Md5Sign        = Request.Params["Md5Sign"].ToLower(); //md5签名
            M_Payment payMod         = payBll.SelModelByPayNo(TransID);
            M_PayPlat platMod        = platBll.SelReturnModel(payMod.PayPlatID);

            if (platMod.PayClass != (int)M_PayPlat.Plat.BaoFo)
            {
                function.WriteErrMsg("回调页面错误");
            }
            //string Md5Key = ConfigurationManager.AppSettings["Md5key"];//密钥 双方约定
            //String mark = "~|~";//分隔符



            //string _Md5Key = WebConfigurationManager.AppSettings["Md5key"];

            //string _WaitSign = "MemberID=" + MemberID + mark + "TerminalID=" + TerminalID + mark + "TransID=" + TransID + mark + "Result=" + Result + mark + "ResultDesc=" + ResultDesc + mark
            //     + "FactMoney=" + FactMoney + mark + "AdditionalInfo=" + AdditionalInfo + mark + "SuccTime=" + SuccTime
            //     + mark + "Md5Sign=" + Md5Key;
            lbMoney.Text   = (float.Parse(FactMoney) / 100).ToString() + " 元";
            lbDate.Text    = SuccTime;
            lbFlag.Text    = baofa.GetErrorInfo(Result, ResultDesc) + "-====";
            lbOrderID.Text = TransID;

            //if (Md5Sign.ToLower() == StringHelper.MD5(_WaitSign).ToLower())
            //{

            //}
            //else
            //{
            //    Response.Write("校验失败");
            //}
        }
Example #15
0
        public static M_Payment GetPaymentByOrderNo(string payno, string orderno, double allmoney)
        {
            B_Payment payBll = new B_Payment();
            M_Payment payMod = null;

            if (!string.IsNullOrEmpty(payno))
            {
                payMod = payBll.SelModelByPayNo(payno);
            }
            else if (!string.IsNullOrEmpty(orderno))
            {
                payMod = payBll.SelModelByOrderNo(orderno);
            }
            if (payMod == null)
            {
                payMod           = new M_Payment();
                payMod.MoneyReal = allmoney;
            }
            return(payMod);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            SortedDictionary <string, string> sArrary = GetRequestGet();

            ///////////////////////以下参数是需要设置的相关配置参数,设置后不会更改的//////////////////////
            ZoomLa.BLL.B_PayPlat payBLL = new ZoomLa.BLL.B_PayPlat();
            DataTable            pay    = payBLL.GetPayPlatByClassid(12);

            ZoomLa.Model.M_Alipay_config con = new ZoomLa.Model.M_Alipay_config();
            if (pay == null || pay.Rows.Count < 1)
            {
                function.WriteErrMsg("请先配置支付平台信息!![系统设置-->支付平台-->在线支付平台]");
            }
            string partner       = pay.Rows[0]["AccountID"].ToString();
            string key           = pay.Rows[0]["MD5Key"].ToString();
            string input_charset = con.Input_charset;
            string sign_type     = con.Sign_type;
            string transport     = con.Transport;

            //////////////////////////////////////////////////////////////////////////////////////////////

            if (sArrary.Count > 0)//判断是否有带返回参数
            {
                B_Alipay_notify aliNotify = new B_Alipay_notify(sArrary, Request.QueryString["notify_id"], partner, key, input_charset, sign_type, transport);
                //AlipayNotify aliNotify = new AlipayNotify(sArrary, Request.QueryString["notify_id"], partner, key, input_charset, sign_type, transport);
                string responseTxt = aliNotify.ResponseTxt;       //获取远程服务器ATN结果,验证是否是支付宝服务器发来的请求
                string sign        = Request.QueryString["sign"]; //获取支付宝反馈回来的sign结果
                string mysign      = aliNotify.Mysign;            //获取通知返回后计算后(验证)的签名结果

                //写日志记录(若要调试,请取消下面两行注释)
                //string sWord = "responseTxt=" + responseTxt + "\n return_url_log:sign=" + Request.QueryString["sign"] + "&mysign=" + mysign + "\n return回来的参数:" + aliNotify.PreSignStr;
                //AlipayFunction.log_result(Server.MapPath("log/" + DateTime.Now.ToString().Replace(":", "")) + ".txt",sWord);

                //判断responsetTxt是否为ture,生成的签名结果mysign与获得的签名结果sign是否一致
                //responsetTxt的结果不是true,与服务器设置问题、合作身份者ID、notify_id一分钟失效有关
                //mysign与sign不等,与安全校验码、请求时的参数格式(如:带自定义参数等)、编码格式有关
                if (responseTxt == "true" && sign == mysign)//验证成功
                {
                    /////////////////////////////////////////////////////////////////////////////////////////////////////////////
                    //请在这里加上商户的业务逻辑程序代码

                    //——请根据您的业务逻辑来编写程序(以下代码仅作参考)——
                    //获取支付宝的通知返回参数,可参考技术文档中页面跳转同步通知参数列表
                    string trade_no    = Request.QueryString["trade_no"];           //支付宝交易号
                    string order_no    = Request.QueryString["out_trade_no"];       //获取订单号
                    string total_fee   = Request.QueryString["total_fee"];          //获取总金额
                    string subject     = Request.QueryString["subject"];            //商品名称、订单名称
                    string body        = Request.QueryString["body"];               //商品描述、订单备注、描述
                    string buyer_email = Request.QueryString["buyer_email"];        //买家支付宝账号
                                                                                    //string receive_name = Request["receive_name"];      //收货人姓名
                                                                                    //string receive_address = Request["receive_address"];//收货人地址
                                                                                    //string receive_zip = Request["receive_zip"];        //收货人邮编
                                                                                    //string receive_phone = Request["receive_phone"];    //收货人电话
                                                                                    //string receive_mobile = Request["receive_mobile"];  //收货人手机
                    string trade_status = Request.QueryString["trade_status"];      //交易状态

                    //打印页面
                    lbTrade_no.Text     = trade_no;
                    lbOut_trade_no.Text = order_no;
                    lbTotal_fee.Text    = total_fee;
                    lbSubject.Text      = subject;
                    lbBody.Text         = body;
                    lbBuyer_email.Text  = buyer_email;
                    lbTrade_status.Text = trade_status;
                    lbVerify.Text       = "验证成功";

                    if (Request.QueryString["trade_status"] == "WAIT_SELLER_SEND_GOODS" || Request.QueryString["trade_status"] == "TRADE_SUCCESS")//买家已经付款,等待卖家发货
                    {
                        M_Payment   payMod = payBll.SelModelByPayNo(order_no);
                        M_OrderList omod   = orderBll.SelModelByOrderNo(payMod.PaymentNum.Split(',')[0]);
                        LbName.Text    = omod.Receiver;
                        LbAddress.Text = omod.Jiedao;
                        LbZip.Text     = omod.ZipCode;
                        LbPhone.Text   = omod.Phone;
                        LbMobile.Text  = omod.Mobile.ToString();
                        FinalStep(omod);
                    }
                    else if (Request.QueryString["trade_status"] == "TRADE_FINISHED")//交易成功结束
                    {
                        lbVerify.Text = "该交易已经成功结束!";
                    }
                    else
                    {
                        Response.Write("trade_status=" + Request.QueryString["trade_status"]);
                    }
                }
                else//验证失败
                {
                    lbVerify.Text = "验证失败";
                }
            }
            else
            {
                lbVerify.Text = "无返回参数";
            }
        }
Example #17
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string    MemberID       = Request.Params["MemberID"];          //商户号
            string    TerminalID     = Request.Params["TerminalID"];        //商户终端号
            string    TransID        = Request.Params["TransID"];           //商户流水号
            string    Result         = Request.Params["Result"];            //支付结果(1:成功,0:失败)
            string    ResultDesc     = Request.Params["ResultDesc"];        //支付结果描述
            string    FactMoney      = Request.Params["FactMoney"];         //实际成交金额
            string    AdditionalInfo = Request.Params["AdditionalInfo"];    //订单附加消息
            string    SuccTime       = Request.Params["SuccTime"];          //交易成功时间
            string    Md5Sign        = Request.Params["Md5Sign"].ToLower(); //md5签名
            M_Payment payMod         = payBll.SelModelByPayNo(TransID);
            M_PayPlat platMod        = new M_PayPlat();

            platMod = platBll.SelReturnModel(payMod.PayPlatID);
            if (platMod.PayClass != (int)M_PayPlat.Plat.BaoFo)
            {
                function.WriteErrMsg("回调页面错误");
            }
            String mark      = "~|~";//分隔符
            string _WaitSign = "MemberID=" + MemberID + mark + "TerminalID=" + TerminalID + mark + "TransID=" + TransID + mark + "Result=" + Result + mark + "ResultDesc=" + ResultDesc + mark
                               + "FactMoney=" + FactMoney + mark + "AdditionalInfo=" + AdditionalInfo + mark + "SuccTime=" + SuccTime
                               + mark + "Md5Sign=" + platMod.MD5Key;

            if (Md5Sign.ToLower() == StringHelper.MD5(_WaitSign).ToLower())
            {
                ZLLog.L(ZLEnum.Log.pay, "宝付:" + ResultDesc + " 支付结果:" + Result + " 支付单:" + TransID + " 金额:" + FactMoney);
                try
                {
                    M_Payment pinfo = payBll.SelModelByPayNo(TransID);
                    if (pinfo.Status != (int)M_Payment.PayStatus.NoPay)
                    {
                        return;
                    }
                    pinfo.Status       = (int)M_Payment.PayStatus.HasPayed;
                    pinfo.PlatformInfo = "宝付在线付款";                            //平台反馈信息
                    pinfo.SuccessTime  = DateTime.Now;                        //交易成功时间
                    pinfo.CStatus      = true;                                //处理状态
                    pinfo.MoneyTrue    = (Convert.ToDouble(FactMoney) / 100); //其以分为单位
                    payBll.Update(pinfo);
                    DataTable orderDT = orderBll.GetOrderbyOrderNo(pinfo.PaymentNum);
                    foreach (DataRow dr in orderDT.Rows)
                    {
                        M_Order_PayLog paylogMod = new M_Order_PayLog();
                        M_OrderList    orderMod  = orderBll.SelModelByOrderNo(dr["OrderNo"].ToString());
                        OrderHelper.FinalStep(pinfo, orderMod, paylogMod);
                        orderCom.SendMessage(orderMod, paylogMod, "payed");
                        //orderCom.SaveSnapShot(orderMod);
                    }
                    Response.Write("OK");
                    ZLLog.L(ZLEnum.Log.pay, "宝付平台支付成功!支付单:" + TransID);
                }
                catch (Exception ex)
                {
                    ZLLog.L(ZLEnum.Log.pay, new M_Log()
                    {
                        Action  = "支付回调报错",
                        Message = "平台:宝付,支付单:" + TransID + ",原因:" + ex.Message
                    });
                }
            }
            else
            {
                ZLLog.L(ZLEnum.Log.pay, new M_Log()
                {
                    Action  = "支付验证失败",
                    Message = "平台:宝付,支付单:" + TransID
                });
                Response.Write("Md5CheckFail");
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!B_ARoleAuth.Check(ZLEnum.Auth.shop, "OrderList"))
            {
                function.WriteErrMsg("没有权限进行此项操作");
            }
            if (Mid < 1 && string.IsNullOrEmpty(OrderNO))
            {
                function.WriteErrMsg("未指定订单");
            }
            if (!IsPostBack)
            {
                if (Mid > 0)
                {
                    orderinfo = oll.GetOrderListByid(Mid);
                }
                else if (!string.IsNullOrEmpty(Request["OrderNo"]))
                {
                    orderinfo = oll.GetByOrder(Request["OrderNo"], "0");
                }
                if (orderinfo == null || orderinfo.id < 1)
                {
                    function.WriteErrMsg("订单不存在");
                }
                OrderNO = orderinfo.OrderNo;
                //----------------------------------------------------------
                M_UserInfo mu = buser.SelReturnModel(orderinfo.Userid);
                HeadTitle_L.Text = "订 单 信 息(订单编号:" + orderinfo.OrderNo + ")";
                string giveurl = customPath2 + "User/Userexp.aspx?UserID=" + orderinfo.Userid
                                 + "&orderid=" + orderinfo.id;
                give_score_a.HRef   = giveurl + "&type=" + (int)M_UserExpHis.SType.Point;
                give_purse_a.HRef   = giveurl + "&type=" + (int)M_UserExpHis.SType.Purse;
                OrderNo_L.Text      = orderinfo.OrderNo;
                Orderamounts_L.Text = orderinfo.Ordersamount.ToString("f2");
                isCheckRe_L.Text    = orderinfo.Guojia;
                Cdate_L.Text        = orderinfo.AddTime.ToString("yyyy年MM月dd日 HH:mm");
                Reuser.Text         = StringHelper.SubStr(orderinfo.Reuser, 12);
                UName_L.Text        = "<a href='javascript:;' onclick='showuinfo(" + mu.UserID + ");' title='查看用户'>" + mu.UserName + "</a>";
                if (orderinfo.StateLogistics != 0)
                {
                    Exp_Send_Btn.Enabled = false;
                }
                if (orderinfo.StateLogistics == 1)
                {
                    Exp_ClientSign_Btn.Enabled = true;
                }
                if (orderinfo.StateLogistics == 0)
                {
                    function.Script(this, "hiddLogistics();");
                }
                if (orderinfo.Paymentstatus >= (int)M_OrderList.PayEnum.HasPayed)
                {
                    Paymentstatus.Text   = "<span  style='color:green';>已经汇款</span>";
                    Pay_Has_Btn.Disabled = true;
                }
                else
                {
                    Paymentstatus.Text   = "<span style='color:red;'>等待汇款</span>";
                    Pay_Has_Btn.Disabled = false;
                    Exp_Send_Btn.Enabled = false;
                }
                switch ((M_OrderList.StatusEnum)orderinfo.OrderStatus)
                {
                case M_OrderList.StatusEnum.Normal:
                    OS_Sure_Btn.Enabled = true;
                    break;

                case M_OrderList.StatusEnum.DrawBack:
                    OS_Sure_Btn.Enabled       = false;
                    OS_NoSure_Btn.Enabled     = false;
                    CheckReturn.Enabled       = true;
                    UnCheckRetrun.Enabled     = true;
                    Exp_Send_Btn.Enabled      = false;
                    CompleteOrder_Btn.Enabled = false;
                    break;

                case M_OrderList.StatusEnum.UnDrawBack:
                case M_OrderList.StatusEnum.CheckDrawBack:
                    OS_Invoice_Btn.Enabled    = false;
                    OS_Sure_Btn.Enabled       = false;
                    OS_NoSure_Btn.Enabled     = false;
                    Exp_Send_Btn.Enabled      = false;
                    CompleteOrder_Btn.Enabled = false;
                    break;

                case M_OrderList.StatusEnum.OrderFinish:
                case M_OrderList.StatusEnum.UnitFinish:
                    CompleteOrder_Btn.Enabled = false;
                    break;

                default:
                    break;
                }
                #region 物流信息
                ExpStatus_L.Text = OrderHelper.GetExpStatus(orderinfo.StateLogistics);
                M_Order_Exp expMod = expBll.SelReturnModel(DataConverter.CLng(orderinfo.ExpressNum));
                if (expMod != null)
                {
                    ExpName_L.Text    = expMod.ExpComp;
                    ExpCode_L.Text    = expMod.ExpNo;
                    ExpStatus_L.Text += "(公司:" + expMod.ExpComp + "/单号:" + expMod.ExpNo + ")";
                }
                switch ((M_OrderList.ExpEnum)orderinfo.StateLogistics)
                {
                case M_OrderList.ExpEnum.NoSend:
                    Exp_Cancel_Btn.Enabled = false;
                    ExpPrint_B.Disabled    = true;
                    break;

                case M_OrderList.ExpEnum.HasSend:
                    Exp_ClientSign_Btn.Enabled = true;
                    break;

                case M_OrderList.ExpEnum.HasReceived:
                    Exp_Send_Btn.Enabled = false;
                    break;
                }
                DrawBackStr.Text  = orderinfo.Merchandiser;
                Deliverytime.Text = orderinfo.Deliverytime.ToString();//送货时间
                switch (orderinfo.Deliverytime)
                {
                case 1:
                    Deliverytime.Text = "对送货时间没有特殊要求";
                    break;

                case 2:
                    Deliverytime.Text = "双休日或者周一至周五的晚上送达";
                    break;

                case 3:
                    Deliverytime.Text = "周一至周五的白天送达";
                    break;

                default:
                    break;
                }
                Phone.Text   = orderinfo.Phone.ToString();                  //联系电话
                ZipCode.Text = orderinfo.ZipCode.ToString();                //邮政编码
                Mobile.Text  = orderinfo.MobileNum;                         //手机
                Reusers.Text = orderinfo.Reuser.ToString();                 //订货人
                Jiedao.Text  = orderinfo.Shengfen + " " + orderinfo.Jiedao; //地址
                #endregion
                OrderStatus.Text = OrderHelper.GetOrderStatus(orderinfo.OrderStatus);
                adddate.Text     = orderinfo.AddTime.ToShortDateString();
                OrderType_L.Text = orderinfo.AddTime.ToString();

                Invoiceneeds.Text   = orderinfo.Invoiceneeds == 1 ? ComRE.Icon_OK : ComRE.Icon_Error;
                Developedvotes.Text = orderinfo.Developedvotes == 1 ? ComRE.Icon_OK : ComRE.Icon_Error;
                //如果已支付
                if (orderinfo.Integral > 0 && orderinfo.Paymentstatus >= (int)M_OrderList.PayEnum.HasPayed)
                {
                    if (orderinfo.SendPointStatus == 1)
                    {
                        ISsend.Text = "已送出";
                    }
                }
                Pay_Has_Btn.Disabled  = orderinfo.Paymentstatus == 1 ? true : false; //更改状态,已支付
                OS_Freeze_Btn.Enabled = orderinfo.Settle == 1 ? false : true;        //冻结
                OS_Pause_Btn.Enabled  = orderinfo.Suspended == 1 ? false : true;     //暂停
                if (orderinfo.Aside == 1)                                            //已作废
                {
                    Pay_Has_Btn.Disabled = true;
                    //ShowSend_Btn.Enabled = false;
                    OS_Sure_Btn.Enabled             = false;
                    OS_NoSure_Btn.Enabled           = false;
                    CompleteOrder_Btn.Enabled       = false;
                    Exp_ClientSign_Btn.Enabled      = false;
                    OS_Freeze_Btn.Enabled           = false;
                    OS_Invoice_Btn.Enabled          = false;
                    OS_Pause_Btn.Enabled            = false;
                    OS_Aside_Btn.Enabled            = false;
                    Pay_Cancel_Btn.Enabled          = false;
                    Refund_B.Attributes["disabled"] = "disabled";
                }
                else
                {
                    OS_Aside_Btn.Enabled = true;
                }
                if (orderinfo.Settle == 1)//结清
                {
                    Pay_Has_Btn.Disabled = true;
                    //ShowSend_Btn.Enabled = false;
                    OS_Sure_Btn.Enabled        = false;
                    OS_NoSure_Btn.Enabled      = false;
                    OS_Aside_Btn.Enabled       = false;
                    Exp_ClientSign_Btn.Enabled = false;
                    OS_Invoice_Btn.Enabled     = false;
                    OS_Pause_Btn.Enabled       = false;
                }
                if (!string.IsNullOrEmpty(orderinfo.PaymentNo))//支付后才有值
                {
                    M_Payment payMod = payBll.SelModelByPayNo(orderinfo.PaymentNo);
                    if (payMod.PayPlatID == 0)
                    {
                        Payment.Text = "虚拟币支付";
                    }
                    else
                    {
                        M_PayPlat payPlatMod = platBll.GetPayPlatByid(payMod.PayPlatID);
                        Payment.Text = payPlatMod.PayPlatName.ToString();
                    }
                }
                Email.Text   = orderinfo.Email.ToString();   //电子信
                Invoice.Text = orderinfo.Invoice.ToString(); //发票信息
                if (orderinfo.Outstock == 1)
                {
                    Outstock.Text = "缺货时,取消此订单";
                }
                else
                {
                    Outstock.Text = "缺货时,将有货的商品发出,取消无货商品的订购";
                }
                AddUser.Text           = orderinfo.AddUser.ToString();         //负责跟单人员
                Internalrecords_T.Text = orderinfo.Internalrecords.ToString(); //内部记录
                Ordermessage_T.Text    = orderinfo.Ordermessage;               //订货留言
                LabScore.Text          = orderinfo.Integral.ToString();        //积分
                                                                               //-------购物车
                DataTable cplist = cartProBll.GetCartProOrderID(Mid);
                Procart_RPT.DataSource = cplist;
                Procart_RPT.DataBind();
                if (cplist.Rows.Count > 0 && !string.IsNullOrEmpty(cplist.Rows[0]["Additional"].ToString()))
                {
                    M_Cart_Travel          model     = JsonConvert.DeserializeObject <M_Cart_Travel>(cplist.Rows[0]["Additional"].ToString());
                    List <M_Cart_Contract> modelList = new List <M_Cart_Contract>();
                    modelList.AddRange(model.Guest);
                    modelList.AddRange(model.Contract);
                    UserRPT.DataSource = modelList;
                    UserRPT.DataBind();
                }
                DataTable newtable = cplist.DefaultView.ToTable(false, "Shijia", "Pronum");
                double    allmoney = 0;
                for (int i = 0; i < newtable.Rows.Count; i++)
                {
                    allmoney = allmoney + DataConverter.CDouble(cplist.Rows[i]["Allmoney"]);
                }
                //-------
                Label2.Text      = orderinfo.Ordersamount.ToString();
                Label29.Text     = orderinfo.Ordersamount.ToString("f2");
                Label31.Text     = (orderinfo.Ordersamount).ToString("f2") + "元";
                ReceMoney_L.Text = orderinfo.Receivablesamount.ToString("f2") + "元";
                //判断订单所处状态
                {
                    if (orderinfo.OrderStatus < (int)M_OrderList.StatusEnum.Normal || orderinfo.Aside == 1)
                    {
                        prog_order_div.InnerHtml = OrderHelper.GetOrderStatus(orderinfo.OrderStatus, orderinfo.Aside, orderinfo.StateLogistics);
                    }
                    else
                    {
                        int current = 2;
                        if (orderinfo.OrderStatus >= (int)M_OrderList.StatusEnum.OrderFinish)
                        {
                            current = 5;
                        }
                        else if (orderinfo.Paymentstatus >= (int)M_OrderList.PayEnum.HasPayed)
                        {
                            current++;
                            switch (orderinfo.StateLogistics)
                            {
                            case (int)M_OrderList.ExpEnum.HasSend:
                                current++;
                                break;

                            case (int)M_OrderList.ExpEnum.HasReceived:
                                current += 2;
                                break;
                            }
                        }
                        function.Script(this, "$('#prog_order_div').ZLSteps('订单生成,等待用户支付,等待商户发货,等待用户签收,订单完结'," + current + ")");
                    }
                }
                Call.SetBreadCrumb(Master, "<li><a href='" + CustomerPageAction.customPath2 + "Main.aspx'>工作台</a></li><li><a href='ProductManage.aspx'>商城管理</a></li><li><a href='OrderList.aspx'>订单管理</a></li><li class='active'><a href='" + Request.RawUrl + "'>订单详情</a></li>");
            }
        }
Example #19
0
        /*
         * 仅支持支付单
         */
        protected void Page_Load(object sender, EventArgs e)
        {
            B_User.CheckIsLogged(Request.RawUrl);
            M_UserInfo mu = buser.GetLogin(false);

            if (string.IsNullOrEmpty(SiteConfig.SiteInfo.SiteUrl))
            {
                function.WriteErrMsg("错误,管理员未定义网站地址,SiteUrl");
            }
            string siteurl = (SiteConfig.SiteInfo.SiteUrl.TrimEnd('/') + "/PayOnline/");

            if (string.IsNullOrEmpty(PayNo))
            {
                function.WriteErrMsg("请传入支付单号");
            }
            pinfo = paymentBll.SelModelByPayNo(PayNo);
            if (pinfo == null || pinfo.PaymentID < 1)
            {
                function.WriteErrMsg("支付单不存在");
            }
            M_PayPlat payPlat = payPlatBll.SelReturnModel(pinfo.PayPlatID);

            if (!IsPostBack)
            {
                #region 母版页中信息
                logged_div.Visible = true;
                #endregion
                if (pinfo.Status != (int)M_Payment.PayStatus.NoPay)
                {
                    function.WriteErrMsg("支付单不能重复付款");
                }
                Rurl_Href.NavigateUrl = "/Extend/order.aspx";//返回我的订单
                if (pinfo.PaymentNum.Contains("IDC"))
                {
                    Rurl_Href.NavigateUrl = "/Plugins/Domain/ViewHave.aspx";
                }
                string url = Request.CurrentExecutionFilePath;
                urlReq1 = Request.Url.AbsoluteUri.ToString().Substring(0, Request.Url.AbsoluteUri.ToString().LastIndexOf('/'));
                double vmoney   = pinfo.MoneyReal;                //支付金额
                string v_amount = pinfo.MoneyReal.ToString("f2"); //实际支付金额
                if (string.IsNullOrEmpty(PayMethod))
                {
                    #region 现金支付
                    DataTable orderDB1  = orderBll.GetOrderbyOrderNo(pinfo.PaymentNum);//订单表,ZL_OrderInfo
                    int       orderType = 0;
                    if (orderDB1.Rows.Count > 0)
                    {
                        orderType = DataConvert.CLng(orderDB1.Rows[0]["OrderType"]);
                    }
                    DataTable ordertable = orderBll.GetOrderbyOrderNo(pinfo.PaymentNum);
                    if (pinfo.PayPlatID == 0 && !string.IsNullOrEmpty(pinfo.PlatformInfo))//支付宝网银支付
                    {
                        payPlat = payPlatBll.SelModelByClass(M_PayPlat.Plat.Alipay_Bank);
                        alipayBank(pinfo.PlatformInfo);
                    }
                    if (payPlat.PayClass == 99)//线下支付
                    {
                        function.WriteSuccessMsg("信息已记录,请等待商家联系完成线下付款", Rurl_Href.NavigateUrl);
                    }
                    if (payPlat == null || payPlat.PayPlatID < 1)
                    {
                        function.WriteErrMsg("没有找到对应的支付平台信息!");
                    }
                    if (payPlat.PayClass == 100)//货到付款
                    {
                        payinfo_div.Visible = false;
                        AfterPay_Tb.Visible = true;
                        Title = "下单成功!";
                    }
                    else
                    {
                        payinfo_div.Visible = true;
                        AfterPay_Tb.Visible = false;
                    }
                    switch ((M_PayPlat.Plat)payPlat.PayClass)//现仅开通 12:支付宝即时到账和支付宝网银服务,15支付宝网银服务(上方代码中处理),银币与余额服务
                    {
                        #region 各种支付方式
                    case M_PayPlat.Plat.UnionPay:
                        #region 银联在线
                        //gateway = "https://pay3.chinabank.com.cn/PayGate?encoding=UTF-8";
                        //必要的交易信息
                        string wv_amount    = v_amount;                              // 订单金额
                        string wv_moneytype = "CNY";                                 // 币种
                        string wv_md5info;                                           // 对拼凑串MD5私钥加密后的值
                        string wv_mid = payPlat.AccountID;                           // 商户号
                        //v_urlBuilder.Append("http://localhost:86/PayOnline/PayReceive.aspx?PayID=" +payid);
                        string wv_url = urlReq1 + "/PayReceive.aspx?PayNo=" + PayNo; // 返回页地址
                        string wv_oid = pinfo.PayNo;                                 // 推荐订单号构成格式为 年月日-商户号-小时分钟秒
                        //两个备注

                        // wv_mid = "1001";				 商户号,这里为测试商户号20000400,替换为自己的商户号即可
                        // wv_url = "http://localhost/chinabank/Receive.aspx";  商户自定义返回接收支付结果的页面
                        // MD5密钥要跟订单提交页相同,如Send.asp里的 key = "test" ,修改""号内 test 为您的密钥
                        string wkey = payPlat.MD5Key;                                    // 如果您还没有设置MD5密钥请登录我们为您提供商户后台,地址:https://merchant3.chinabank.com.cn/
                        // 登录后在上面的导航栏里可能找到“B2C”,在二级导航栏里有“MD5密钥设置”
                        // 建议您设置一个16位以上的密钥或更高,密钥最多64位,但设置16位已经足够了
                        wv_amount    = v_amount;    // 订单金额
                        wv_moneytype = "CNY";       // 币种
                        //对拼凑串MD5私钥加密后的值
                        wv_mid = payPlat.AccountID; // 商户号
                        wv_oid = pinfo.PayNo;       // 推荐订单号构成格式为 年月日-商户号-小时分钟秒

                        if (wv_oid == null || wv_oid.Equals(""))
                        {
                            DateTime dt       = DateTime.Now;
                            string   wv_ymd   = dt.ToString("yyyyMMdd"); // yyyyMMdd
                            string   wtimeStr = dt.ToString("HHmmss");   // HHmmss
                            wv_oid = wv_ymd + wv_mid + wtimeStr;
                        }
                        string text = wv_amount + wv_moneytype + wv_oid + wv_mid + wv_url + wkey;     // 拼凑加密串
                        wv_md5info = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(text, "md5").ToUpper();
                        //strHiddenField.Append("<input type='hidden' name='v_md5info' value='" + wv_md5info + "'>\n");
                        //strHiddenField.Append("<input type='hidden' name='v_mid' value='" + wv_mid + "'>\n");
                        //strHiddenField.Append("<input type='hidden' name='v_oid' value='" + wv_oid + "'>\n");
                        //strHiddenField.Append("<input type='hidden' name='v_amount' value='" + wv_amount + "' >\n");
                        //strHiddenField.Append("<input type='hidden' name='v_moneytype' value='" + wv_moneytype + "'>\n");
                        //strHiddenField.Append("<input type='hidden' name='v_url' value='" + wv_url + "'>\n");
                        //    //以下几项只是用来记录客户信息,可以不用,不影响支付
                        //    strHiddenField.Append("<input type='hidden' name='v_rcvname' value='" + "" + "'>\n");
                        //    strHiddenField.Append("<input type='hidden' name='v_rcvaddr' value='" + "" + "'>\n");
                        //    strHiddenField.Append("<input type='hidden' name='v_rcvtel' value='" + "" + "'>\n");
                        //    strHiddenField.Append("<input type='hidden' name='v_rcvpost' value='" + "" + "' >\n");
                        //    strHiddenField.Append("<input type='hidden' name='v_rcvemail' value='" + "" + "'>\n");
                        //    strHiddenField.Append("<input type='hidden' name='v_rcvmobile' value='" + "" + "'>\n");
                        //    strHiddenField.Append("<input type='hidden' name='v_ordername' value='" + "" + "' >\n");
                        //    strHiddenField.Append("<input type='hidden' name='v_orderaddr' value='" + "" + "'>\n");
                        //    strHiddenField.Append("<input type='hidden' name='v_ordertel' value='" + "" + "'>\n");
                        //    strHiddenField.Append("<input type='hidden' name='v_orderpost' value='" + "" + "' >\n");
                        //    strHiddenField.Append("<input type='hidden' name='v_orderemail' value='" + "" + "'>\n");
                        //    strHiddenField.Append("<input type='hidden' name='v_ordermobile' value='" + "" + "'>\n");
                        //    strHiddenField.Append("<input type='hidden' name='Package' value='" + Request.QueryString["Package"] + "'>\n");
                        #endregion
                        break;

                    case M_PayPlat.Plat.ChinaUnionPay:
                    {
                        #region 中国银联
                        Dictionary <string, string> param = new Dictionary <string, string>();

                        //以下信息非特殊情况不需要改动
                        param["version"]      = "5.0.0";                                      //版本号
                        param["encoding"]     = "UTF-8";                                      //编码方式
                        param["txnType"]      = "01";                                         //交易类型
                        param["txnSubType"]   = "01";                                         //交易子类
                        param["bizType"]      = "000201";                                     //业务类型
                        param["signMethod"]   = "01";                                         //签名方法
                        param["channelType"]  = "08";                                         //渠道类型
                        param["accessType"]   = "0";                                          //接入类型
                        param["frontUrl"]     = siteurl + "/Return/ChinaUnionPay.aspx";       //前台通知地址
                        param["backUrl"]      = siteurl + "/Return/ChinaUnionPayNotify.aspx"; //后台通知地址
                        param["currencyCode"] = "156";                                        //交易币种

                        //TODO 以下信息需要填写
                        param["merId"]           = payPlat.AccountID;                         //商户号,请改自己的测试商户号,此处默认取demo演示页面传递的参数
                        param["orderId"]         = pinfo.PayNo;                               //商户订单号,8-32位数字字母,不能含“-”或“_”,此处默认取demo演示页面传递的参数,可以自行定制规则
                        param["txnTime"]         = DateTime.Now.ToString("yyyyMMddHHmmss");   //订单发送时间,格式为YYYYMMDDhhmmss,取北京时间,此处默认取demo演示页面传递的参数,参考取法: DateTime.Now.ToString("yyyyMMddHHmmss")
                        param["txnAmt"]          = ((int)(pinfo.MoneyReal * 100)).ToString(); //交易金额,单位分,此处默认取demo演示页面传递的参数
                        LblHiddenValue.InnerHtml = PayHelper.BuildForm("https://101.231.204.80:5000/gateway/api/frontTransReq.do", param);
                        Alipay_Btn.Visible       = true;
                        #endregion
                    }
                    break;

                    case M_PayPlat.Plat.Alipay_Instant:
                        #region 支付宝[即时到帐]
                        string input_charset1 = "utf-8";
                        string notify_url1    = urlReq1 + "/Return/AlipayNotify.aspx"; //付完款后服务器AJAX通知的页面 要用 http://格式的完整路径,不允许加?id=123这类自定义参数
                        string return_url1    = urlReq1 + "/Return/AlipayReturn.aspx"; //付完款后跳转的页面 要用 http://格式的完整路径,不允许加?id=123这类自定义参数
                        string show_url1      = "";
                        string sign_type1     = "MD5";
                        ///////////////////////以下参数是需要通过下单时的订单数据传入进来获得////////////////////////////////
                        //必填参数
                        string price1             = pinfo.MoneyReal.ToString("f2");  //订单总金额,显示在支付宝收银台里的“商品单价”里
                        string logistics_fee1     = "0.00";                          //物流费用,即运费。
                        string logistics_type1    = "POST";                          //物流类型,三个值可选:EXPRESS(快递)、POST(平邮)、EMS(EMS)
                        string logistics_payment1 = "SELLER_PAY";                    //物流支付方式,两个值可选:SELLER_PAY(卖家承担运费)、BUYER_PAY(买家承担运费)
                        string out_trade_no1      = pinfo.PayNo;                     //请与贵网站订单系统中的唯一订单号匹配
                        string subject1           = pinfo.Remark;                    //订单名称,显示在支付宝收银台里的“商品名称”里,显示在支付宝的交易管理的“商品名称”的列表里。
                        string body1            = pinfo.Remark;                      //订单描述、订单详细、订单备注,显示在支付宝收银台里的“商品描述”里
                        string quantity1        = "1";                               //商品数量,建议默认为1,不改变值,把一次交易看成是一次下订单而非购买一件商品。
                        string receive_name1    = "";                                //收货人姓名,如:张三
                        string receive_address1 = "";                                //收货人地址,如:XX省XXX市XXX区XXX路XXX小区XXX栋XXX单元XXX号
                        string receive_zip1     = "";                                //收货人邮编,如:123456
                        string receive_phone1   = "";                                //收货人电话号码,如:0571-81234567
                        string receive_mobile1  = "";                                //收货人手机号码,如:13312341234
                        //---------------------
                        string receive_name    = orderDB1.Rows[0]["Reuser"] + "";    //收货人姓名,如:张三
                        string receive_address = orderDB1.Rows[0]["Jiedao"] + "";    //收货人地址,如:XX省XXX市XXX区XXX路XXX小区XXX栋XXX单元XXX号
                        string receive_zip     = orderDB1.Rows[0]["ZipCode"] + "";   //收货人邮编,如:123456
                        string receive_phone   = orderDB1.Rows[0]["Phone"] + "";     //收货人电话号码,如:0571-81234567
                        string receive_mobile  = orderDB1.Rows[0]["MobileNum"] + ""; //收货人手机号码,如:13312341234
                        //扩展参数——第二组物流方式
                        //物流方式是三个为一组成组出现。若要使用,三个参数都需要填上数据;若不使用,三个参数都需要为空
                        //有了第一组物流方式,才能有第二组物流方式,且不能与第一个物流方式中的物流类型相同,
                        //即logistics_type="EXPRESS",那么logistics_type_1就必须在剩下的两个值(POST、EMS)中选择
                        string logistics_fee_3     = "";                                                    //物流费用,即运费。
                        string logistics_type_3    = "";                                                    //物流类型,三个值可选:EXPRESS(快递)、POST(平邮)、EMS(EMS)
                        string logistics_payment_3 = "";                                                    //物流支付方式,两个值可选:SELLER_PAY(卖家承担运费)、BUYER_PAY(买家承担运费)

                        //扩展参数——第三组物流方式
                        //物流方式是三个为一组成组出现。若要使用,三个参数都需要填上数据;若不使用,三个参数都需要为空
                        //有了第一组物流方式和第二组物流方式,才能有第三组物流方式,且不能与第一组物流方式和第二组物流方式中的物流类型相同,
                        //即logistics_type="EXPRESS"、logistics_type_1="EMS",那么logistics_type_2就只能选择"POST"
                        string logistics_fee_4     = "";                                                        //物流费用,即运费。
                        string logistics_type_4    = "";                                                        //物流类型,三个值可选:EXPRESS(快递)、POST(平邮)、EMS(EMS)
                        string logistics_payment_4 = "";                                                        //物流支付方式,两个值可选:SELLER_PAY(卖家承担运费)、BUYER_PAY(买家承担运费)
                        //扩展功能参数——其他
                        string buyer_email1 = "";                                                               //默认买家支付宝账号
                        string discount1    = "";                                                               //折扣,是具体的金额,而不是百分比。若要使用打折,请使用负数,并保证小数点最多两位数
                        /////////////////////////////////////////////////////////////////////////////////////////////////////
                        //构造请求函数,无需修改
                        B_AliPay_trades_Services aliService1 = new B_AliPay_trades_Services(
                            payPlat.AccountID,
                            payPlat.SellerEmail,
                            return_url1,
                            notify_url1,
                            show_url1,
                            out_trade_no1,
                            subject1,
                            body1,
                            price1,
                            logistics_fee1,
                            logistics_type1,
                            logistics_payment1,
                            quantity1,
                            receive_name1,
                            receive_address1,
                            receive_zip1,
                            receive_phone1,
                            receive_mobile1,
                            logistics_fee_3,
                            logistics_type_3,
                            logistics_payment_3,
                            logistics_fee_4,
                            logistics_type_4,
                            logistics_payment_4,
                            buyer_email1,
                            discount1,
                            payPlat.MD5Key,
                            input_charset1,
                            sign_type1);
                        Alipay_Btn.Visible       = true;
                        LblHiddenValue.InnerHtml = aliService1.Build_Form();
                        #endregion
                        break;

                    case M_PayPlat.Plat.Alipay_H5:
                    {
                        Response.Redirect("/API/Pay/Alipay_H5.aspx?Payno=" + PayNo);
                    }
                    break;

                    case M_PayPlat.Plat.Alipay_Bank:    //支付宝网银,已上方处理
                        break;

                    case M_PayPlat.Plat.Bill:
                        #region 快钱支付
                    {
                        //人民币网关账户号
                        ///请登录快钱系统获取用户编号,用户编号后加01即为人民币网关账户号。
                        string merchantAcctId = payPlat.AccountID;
                        //人民币网关密钥
                        ///区分大小写.请与快钱联系索取
                        String key = payPlat.MD5Key;
                        //字符集.固定选择值。可为空。
                        ///只能选择1、2、3.
                        ///1代表UTF-8; 2代表GBK; 3代表gb2312
                        ///默认值为1
                        string inputCharset = "1";
                        //接受支付结果的页面地址.与[bgUrl]不能同时为空。必须是绝对地址。
                        ///如果[bgUrl]为空,快钱将支付结果Post到[pageUrl]对应的地址。
                        ///如果[bgUrl]不为空,并且[bgUrl]页面指定的<redirecturl>地址不为空,则转向到<redirecturl>对应的地址
                        ///
                        ///快钱通过服务器连接的方式将交易结果发送到[bgUrl]对应的页面地址,在商户处理完成后输出的<result>如果为1,页面会转向到<redirecturl>对应的地址。
                        ///如果快钱未接收到<redirecturl>对应的地址,快钱将把支付结果post到[pageUrl]对应的页面。
                        string bgUrl = "PayOnline/PayResultAlipayInstant.aspx?";
                        //网关版本.固定值
                        ///快钱会根据版本号来调用对应的接口处理程序。
                        ///本代码版本号固定为v2.0
                        string version = "v2.0";
                        //语言种类.固定选择值。
                        ///只能选择1、2、3
                        ///1代表中文;2代表英文
                        ///默认值为1
                        string language = "1";
                        //签名类型.固定值
                        ///1代表MD5签名
                        ///当前版本固定为1
                        string signType = "1";
                        //支付人姓名
                        ///可为中文或英文字符
                        string payerName = "payerName";
                        //支付人联系方式类型.固定选择值
                        ///只能选择1
                        ///1代表Email
                        string payerContactType = "1";
                        //支付人联系方式
                        ///只能选择Email或手机号
                        string payerContact = "";
                        //商户订单号
                        ///由字母、数字、或[-][_]组成
                        string orderId = pinfo.PayNo;        // DateTime.Now.ToString("yyyyMMddHHmmss");
                                                             //订单金额
                        ///以分为单位,必须是整型数字
                        ///比方2,代表0.02元
                        double moneys = DataConverter.CDouble(v_amount);
                        moneys = moneys * 100;
                        string orderAmount = DataConverter.CLng(moneys).ToString();

                        //订单提交时间
                        ///14位数字。年[4位]月[2位]日[2位]时[2位]分[2位]秒[2位]
                        ///如;20080101010101
                        string orderTime = DateTime.Now.ToString("yyyyMMddHHmmss");
                        //商品名称
                        ///可为中文或英文字符
                        string productName = "product";
                        //商品数量
                        ///可为空,非空时必须为数字
                        string productNum = "1";
                        //商品代码
                        ///可为字符或者数字
                        string productId = "1";
                        //商品描述
                        string productDesc = pinfo.Remark;
                        //扩展字段1
                        ///在支付结束后原样返回给商户
                        string ext1 = "";
                        //扩展字段2
                        ///在支付结束后原样返回给商户
                        string ext2 = "";
                        //支付方式.固定选择值
                        ///只能选择00、10、11、12、13、14
                        ///00:组合支付(网关支付页面显示快钱支持的各种支付方式,推荐使用)10:银行卡支付(网关支付页面只显示银行卡支付).11:电话银行支付(网关支付页面只显示电话支付).12:快钱账户支付(网关支付页面只显示快钱账户支付).13:线下支付(网关支付页面只显示线下支付方式).14:B2B支付(网关支付页面只显示B2B支付,但需要向快钱申请开通才能使用)
                        string payType = "00";

                        //银行代码
                        ///实现直接跳转到银行页面去支付,只在payType=10时才需设置参数
                        ///具体代码参见 接口文档银行代码列表
                        string bankId = "";

                        //同一订单禁止重复提交标志
                        ///固定选择值: 1、0
                        ///1代表同一订单号只允许提交1次;0表示同一订单号在没有支付成功的前提下可重复提交多次。默认为0建议实物购物车结算类商户采用0;虚拟产品类商户采用1
                        string redoFlag = "0";

                        //快钱的合作伙伴的账户号
                        ///如未和快钱签订代理合作协议,不需要填写本参数
                        string pid = "";
                        //生成加密签名串
                        ///请务必按照如下顺序和规则组成加密串!
                        String signMsgVal = "";
                        signMsgVal = Bill99Helper.appendParam(signMsgVal, "inputCharset", inputCharset);
                        signMsgVal = Bill99Helper.appendParam(signMsgVal, "pageUrl", siteurl + "Return/Bill99Notify.aspx");
                        signMsgVal = Bill99Helper.appendParam(signMsgVal, "bgUrl", bgUrl);
                        signMsgVal = Bill99Helper.appendParam(signMsgVal, "version", version);
                        signMsgVal = Bill99Helper.appendParam(signMsgVal, "language", language);
                        signMsgVal = Bill99Helper.appendParam(signMsgVal, "signType", signType);
                        signMsgVal = Bill99Helper.appendParam(signMsgVal, "merchantAcctId", merchantAcctId);        //merchantAcctId
                        signMsgVal = Bill99Helper.appendParam(signMsgVal, "payerName", payerName);
                        signMsgVal = Bill99Helper.appendParam(signMsgVal, "payerContactType", payerContactType);
                        signMsgVal = Bill99Helper.appendParam(signMsgVal, "payerContact", payerContact);
                        signMsgVal = Bill99Helper.appendParam(signMsgVal, "orderId", orderId);
                        signMsgVal = Bill99Helper.appendParam(signMsgVal, "orderAmount", orderAmount);
                        signMsgVal = Bill99Helper.appendParam(signMsgVal, "orderTime", orderTime);
                        signMsgVal = Bill99Helper.appendParam(signMsgVal, "productName", productName);
                        signMsgVal = Bill99Helper.appendParam(signMsgVal, "productNum", productNum);
                        signMsgVal = Bill99Helper.appendParam(signMsgVal, "productId", productId);
                        signMsgVal = Bill99Helper.appendParam(signMsgVal, "productDesc", productDesc);
                        signMsgVal = Bill99Helper.appendParam(signMsgVal, "ext1", ext1);
                        signMsgVal = Bill99Helper.appendParam(signMsgVal, "ext2", ext2);
                        signMsgVal = Bill99Helper.appendParam(signMsgVal, "payType", payType);
                        signMsgVal = Bill99Helper.appendParam(signMsgVal, "bankId", bankId);
                        signMsgVal = Bill99Helper.appendParam(signMsgVal, "redoFlag", redoFlag);
                        signMsgVal = Bill99Helper.appendParam(signMsgVal, "pid", pid);
                        signMsgVal = Bill99Helper.appendParam(signMsgVal, "key", key);
                        string signMsg = StringHelper.MD5(signMsgVal).ToUpper();

                        Dictionary <string, string> payform_dics = new Dictionary <string, string>();
                        payform_dics.Add("inputCharset", inputCharset);
                        payform_dics.Add("bgUrl", bgUrl);
                        payform_dics.Add("pageUrl", siteurl + "Return/Bill99Notify.aspx");        //服务器接受支付结果的后台地址.与[pageUrl]不能同时为空。必须是绝对地址。
                        payform_dics.Add("version", version);
                        payform_dics.Add("language", language);
                        payform_dics.Add("signType", signType);
                        payform_dics.Add("signMsg", signMsg);
                        payform_dics.Add("merchantAcctId", merchantAcctId);
                        payform_dics.Add("payerName", payerName);
                        payform_dics.Add("payerContactType", payerContactType);
                        payform_dics.Add("orderId", orderId);
                        payform_dics.Add("orderAmount", orderAmount);
                        payform_dics.Add("orderTime", orderTime);
                        payform_dics.Add("productName", productName);
                        payform_dics.Add("productNum", productNum);
                        payform_dics.Add("productId", productId);
                        payform_dics.Add("productDesc", productDesc);
                        payform_dics.Add("ext1", ext1);
                        payform_dics.Add("ext2", ext2);
                        payform_dics.Add("payType", payType);
                        payform_dics.Add("bankId", bankId);
                        payform_dics.Add("redoFlag", redoFlag);
                        payform_dics.Add("pid", pid);
                        payform_dics.Add("Package", Request.QueryString["Package"]);
                        LblHiddenValue.InnerHtml = PayHelper.BuildForm("https://www.99bill.com/gateway/recvMerchantInfoAction.htm", payform_dics);
                        Alipay_Btn.Visible       = true;
                    }
                        #endregion
                        break;

                    case M_PayPlat.Plat.WXPay:
                        #region 微信扫码支付
                    {
                        if (DeviceHelper.GetBrower() == DeviceHelper.Brower.Micro)
                        {
                            Response.Redirect("/PayOnline/wxpay_mp.aspx?payno=" + pinfo.PayNo);
                            return;
                        }
                        pinfo.PlatformInfo = "0";
                        paymentBll.Update(pinfo);
                        WxPayData wxdata = new WxPayData();
                        wxdata.SetValue("out_trade_no", pinfo.PayNo);
                        wxdata.SetValue("body", string.IsNullOrEmpty(pinfo.Remark) ? "微信支付" : pinfo.Remark);
                        wxdata.SetValue("total_fee", Convert.ToInt32(pinfo.MoneyReal * 100));
                        wxdata.SetValue("trade_type", "NATIVE");
                        wxdata.SetValue("notify_url", urlReq1 + "/Return/WxPayReturn.aspx");
                        wxdata.SetValue("product_id", "1");
                        WxPayData result = WxPayApi.UnifiedOrder(wxdata, WxPayApi.Pay_GetByID());
                        if (result.GetValue("return_code").ToString().Equals("FAIL"))
                        {
                            function.WriteErrMsg("商户" + result.GetValue("return_msg"));
                        }
                        Response.Redirect("/PayOnline/WxCodePay.aspx?PayNo=" + pinfo.PayNo + "&wxcode=" + result.GetValue("code_url"));
                    }
                        #endregion
                        break;

                    case M_PayPlat.Plat.Ebatong:
                        #region Ebatong
                    {
                        Dictionary <string, string> ebatong_dics = new Dictionary <string, string>();
                        ebatong_dics.Add("sign_type", "MD5");
                        ebatong_dics.Add("service", "create_direct_pay_by_user");
                        ebatong_dics.Add("partner", payPlat.AccountID);
                        ebatong_dics.Add("input_charset", "UTF-8");
                        ebatong_dics.Add("notify_url", siteurl + "Return/EbatongNotify.aspx");        //服务器异步通知页面路径
                        ebatong_dics.Add("return_url", siteurl + "Return/EbatongReturn.aspx");        //服务器跳转页面
                        ebatong_dics.Add("out_trade_no", pinfo.PayNo);
                        ebatong_dics.Add("subject", pinfo.Remark);
                        ebatong_dics.Add("exter_invoke_ip", Request.UserHostAddress);
                        ebatong_dics.Add("payment_type", "1");
                        ebatong_dics.Add("seller_id", payPlat.AccountID);
                        ebatong_dics.Add("total_fee", pinfo.MoneyReal.ToString("f2"));
                        ebatong_dics.Add("error_notify_url", "");
                        ebatong_dics.Add("anti_phishing_key", new ZoomLa.BLL.Ebatong.AskForTimestamp().askFor(payPlat.AccountID, payPlat.MD5Key));
                        ebatong_dics.Add("seller_email", "");
                        ebatong_dics.Add("buyer_email", "");
                        ebatong_dics.Add("buyer_id", "");
                        ebatong_dics.Add("price", "");
                        ebatong_dics.Add("quantity", "");
                        ebatong_dics.Add("body", "");
                        ebatong_dics.Add("show_url", "");
                        ebatong_dics.Add("pay_method", "bankPay");
                        ebatong_dics.Add("extra_common_para", "");
                        ebatong_dics.Add("extend_param", "");
                        ebatong_dics.Add("it_b_pay", "");
                        ebatong_dics.Add("royalty_type", "");
                        ebatong_dics.Add("royalty_parameters", "");
                        ebatong_dics.Add("default_bank", "");
                        string[] paramts = new string[ebatong_dics.Keys.Count]; //参数排序数组
                        ebatong_dics.Keys.CopyTo(paramts, 0);
                        Array.Sort(paramts);                                    //参数排序操作
                        string paramstr = "";
                        foreach (string item in paramts)
                        {
                            paramstr += string.Format("{0}={1}&", item, ebatong_dics[item]);
                        }
                        //throw new Exception(paramstr.Trim('&'));
                        string md5md5 = new ZoomLa.BLL.Ebatong.CommonHelper().md5("UTF-8", paramstr.Trim('&') + payPlat.MD5Key).ToLower();
                        ebatong_dics.Add("sign", md5md5);
                        LblHiddenValue.InnerHtml = PayHelper.BuildForm("https://www.ebatong.com/direct/gateway.htm", ebatong_dics);
                        Alipay_Btn.Visible       = true;
                    }
                        #endregion
                        break;

                    case M_PayPlat.Plat.CCB:
                        #region 江西建行
                    {
                        Dictionary <string, string> ccb_dics = new Dictionary <string, string>();
                        ccb_dics.Add("MERCHANTID", payPlat.AccountID);    //商户代码
                        ccb_dics.Add("POSID", payPlat.PrivateKey);        //柜台代码
                        ccb_dics.Add("BRANCHID", payPlat.PublicKey);      //分行代码
                        ccb_dics.Add("ORDERID", pinfo.PayNo);
                        ccb_dics.Add("PAYMENT", pinfo.MoneyReal.ToString("f2"));
                        ccb_dics.Add("CURCODE", "01");
                        ccb_dics.Add("REMARK1", "");        //备注信息1(具体信息待测试)
                        ccb_dics.Add("REMARK2", "");        //备注信息2
                        ccb_dics.Add("TXCODE", "520100");
                        string ccb_paramstr = "";
                        foreach (String item in ccb_dics.Keys)
                        {
                            ccb_paramstr += string.Format("{0}={1}&", item, ccb_dics[item]);
                        }
                        string md5str = new ZoomLa.BLL.Ebatong.CommonHelper().md5("UTF-8", ccb_paramstr.Trim('&')).ToLower();
                        ccb_dics.Add("MAC", md5str);
                        LblHiddenValue.InnerHtml = PayHelper.BuildForm("https://ibsbjstar.ccb.com.cn/app/ccbMain", ccb_dics);
                        Alipay_Btn.Visible       = true;
                        //Response.Redirect("https://ibsbjstar.ccb.com.cn/app/ccbMain?" + ccb_paramstr + "MAC=" + md5str);
                    }
                        #endregion
                        break;

                    case M_PayPlat.Plat.ECPSS:
                        #region 汇潮支付
                    {
                        Dictionary <string, string> payData = new Dictionary <string, string>();
                        payData.Add("OrderDesc", "test");                              //订单描述
                        payData.Add("Remark", "汇潮支付");                                 //备注
                        payData.Add("AdviceURL", siteurl + "Return/ECPSSNotfy.aspx");  //回调通知地址
                        payData.Add("ReturnURL", siteurl + "Return/ECPSSResult.aspx"); //返回地址
                        payData.Add("BillNo", pinfo.PayNo);                            //订单号
                        payData.Add("MerNo", payPlat.AccountID);                       //商户号
                        payData.Add("Amount", pinfo.MoneyReal.ToString("f2"));         //交易价格
                        string md5key = payPlat.MD5Key;
                        string md5str = payData["MerNo"] + "&" + payData["BillNo"] + "&" + payData["Amount"] + "&" + payData["ReturnURL"] + "&" + md5key;
                        payData.Add("SignInfo", System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(md5str, "MD5")); //签名
                        payData.Add("defaultBankNumber", "");                                                                               //银行代码(选填)
                        payData.Add("orderTime", DateTime.Now.ToString("yyyyMMddHHmmss"));                                                  //交易时间yyyyMMddHHmmss
                        payData.Add("products", pinfo.Remark);                                                                              //物品信息
                        LblHiddenValue.InnerHtml = PayHelper.BuildForm("https://pay.ecpss.com/sslpayment", payData);
                        Alipay_Btn.Visible       = true;
                    }
                        #endregion
                        break;

                    case M_PayPlat.Plat.ICBC_NC:
                        #region 南昌工行
                    {
                        function.WriteErrMsg("工行支付组件未注册,请联系管理员");
                        //ICBCHelper icbc = new ICBCHelper();
                        //infosecapiLib.infosecClass obj = new infosecapiLib.infosecClass();
                        //Dictionary<string, string> dics = new Dictionary<string, string>();
                        //string posturl = "https://B2C.icbc.com.cn/servlet/ICBCINBSEBusinessServlet";
                        //---Debug
                        //payPlat.AccountID = "1502EC24392836";
                        //payPlat.SellerEmail = "1502201009004747554";
                        //payPlat.PrivateKey = "/Cert/cs.key";
                        //payPlat.PublicKey = "/Cert/cs.cer";
                        //posturl = "https://myipad.dccnet.com.cn/servlet/NewB2cMerPayReqServlet";
                        //throw new Exception(payPlat.PrivateKey + ":" + payPlat.PublicKey + ":" + payPlat.AccountID + ":" + payPlat.SellerEmail);
                        //Debug End
                        //*.z01.com根据需要更改如*.hx008.com
                        //string data = icbc.SpliceTranData(pinfo, payPlat.AccountID.Trim(), payPlat.SellerEmail.Trim(), "*.z01.com", siteurl + "ICBCNotify.aspx");
                        //string sign = obj.sign(data, Server.MapPath(payPlat.PrivateKey), payPlat.MD5Key.Trim());//私钥虚拟路径与私钥密钥
                        //dics.Add("interfaceName", "ICBC_PERBANK_B2C");
                        //dics.Add("interfaceVersion", "1.0.0.11");
                        //dics.Add("tranData", obj.base64enc(data));
                        //dics.Add("merSignMsg", sign);
                        //dics.Add("merCert", icbc.ReadCertToBase64(payPlat.PublicKey));//公钥路径
                        //LblHiddenValue.InnerHtml = new Pay_BaoFa().BuildForm(posturl, dics);
                        //Alipay_Btn.Visible = true;
                    }
                        #endregion
                        break;

                    case M_PayPlat.Plat.CashOnDelivery:
                        #region 货到付款
                        zfpt.Text      = payPlat.PayPlatName;
                        ddh.Text       = pinfo.PaymentNum;
                        PayNum_L2.Text = Convert.ToDecimal(vmoney).ToString("F2") + " 元";
                        sxf.Text       = payPlat.Rate.ToString() + " %";
                        sjhbje.Text    = v_amount + " 元";
                        #endregion
                        break;

                    case M_PayPlat.Plat.PayPal:
                    {
                        Response.Redirect("PP/Pay.aspx?Payno=" + pinfo.PayNo);
                    }
                    break;

                    default:
                        throw new Exception("错误:支付方式不存在:" + payPlat.PayClass);
                        #endregion
                    }
                    VMoneyPayed_L.Text = payPlat.PayPlatName;
                    OrderNo_L.Text     = pinfo.PaymentNum;
                    LblRate.Text       = payPlat.Rate.ToString() + " %";
                    #endregion
                }
                else//非现金支付,给用户显示确认支付页,实际支付行为在Confirm_Click
                {
                    spwd_div.Visible    = (!string.IsNullOrEmpty(mu.PayPassWord));
                    nospwd_div.Visible  = string.IsNullOrEmpty(mu.PayPassWord);//如未设定,则不需要输入二级密码
                    payinfo_div.Visible = true;
                    AfterPay_Tb.Visible = false;
                    OrderNo_L.Text      = pinfo.PaymentNum;
                    DataTable ordertable = orderBll.GetOrderbyOrderNo(pinfo.PaymentNum);
                    if (ordertable != null && ordertable.Rows.Count > 0)
                    {
                        switch (PayMethod)
                        {
                        case "Purse":
                            //Titles.Text = "余额支付操作(确认支付款项)";
                            Fee.Text           = "帐户余额:";
                            LblRate.Text       = mu.Purse + " 元";
                            VMoneyPayed_L.Text = "帐户余额";
                            break;

                        case "SilverCoin":
                            //Titles.Text = "银币支付操作(确认支付款项)";
                            Fee.Text           = "帐户银币:";
                            LblRate.Text       = mu.SilverCoin + " 个";
                            VMoneyPayed_L.Text = "账户银币";
                            break;

                        case "Score":
                            //Titles.Text = "积分支付操作(确认支付款项)";
                            Fee.Text           = "帐户积分:";
                            LblRate.Text       = mu.UserExp + " 分";
                            VMoneyPayed_L.Text = "账户积分";
                            break;

                        default:
                            break;
                        }
                    }
                    else
                    {
                        payinfo_div.Visible = false;
                        AfterPay_Tb.Visible = false;
                        function.WriteErrMsg("订单不存在");
                    }
                }
                //显示金额信息
                LblPayMoney.Text = pinfo.MoneyReal.ToString("F2") + " 元";//应付金额
            }
            //------------------检测End;
        }
Example #20
0
    protected void Page_Load(object sender, EventArgs e)
    {
        ZLLog.L(ZLEnum.Log.pay, "进入双乾支付页");
        string MerNo     = Request.Params["MerNo"].ToString();
        string BillNo    = Request.Params["BillNo"].ToString();
        string Amount    = Request.Params["Amount"].ToString();
        string Succeed   = Request.Params["Succeed"].ToString();
        string Result    = Request.Params["Result"].ToString();
        string MD5info   = Request.Params["MD5info"].ToString();
        string MerRemark = Request.Params["MerRemark"].ToString();

        M_Payment payMod  = payBll.SelModelByPayNo(BillNo);
        M_PayPlat platMod = new M_PayPlat();

        platMod = platBll.SelReturnModel(payMod.PayPlatID);
        if (platMod.PayClass != (int)M_PayPlat.Plat.EPay95)
        {
            ZLLog.L(ZLEnum.Log.safe, "回调页面错误" + Request.RawUrl);
        }
        string MD5key = platMod.MD5Key;//Md5加密私钥[注册时产生]
        string md5md5 = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(MD5key, "MD5").ToUpper();
        string md5src = "Amount=" + Amount + "&BillNo=" + BillNo + "&MerNo=" + MerNo + "&Succeed=" + Succeed + "&" + md5md5;
        string md5str = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(md5src, "MD5").ToUpper();

        try { ZLLog.L(ZLEnum.Log.labelex, "双乾详情:" + md5src); }
        catch (Exception ex) { ZLLog.L(ZLEnum.Log.labelex, "双乾未完成记录" + ex.Message); }
        if (MD5info.Equals(md5str))
        {
            if (!Succeed.Equals("88"))
            {
                ZLLog.L(ZLEnum.Log.pay, "支付单:" + BillNo + ", 支付状态非成功,取消处理!" + md5src); return;
            }
            try
            {
                M_Payment pinfo = payBll.SelModelByPayNo(BillNo);
                if (pinfo.Status != (int)M_Payment.PayStatus.NoPay)
                {
                    return;
                }
                pinfo.Status       = (int)M_Payment.PayStatus.HasPayed;
                pinfo.PlatformInfo = "双乾坤支付";      //平台反馈信息
                pinfo.SuccessTime  = DateTime.Now; //交易成功时间
                pinfo.CStatus      = true;         //处理状态
                pinfo.MoneyTrue    = Convert.ToDecimal(Amount);
                payBll.Update(pinfo);

                //-------支付成功处理,发送邮件
                M_OrderList orderMod1 = orderBll.SelModelByOrderNo(pinfo.PaymentNum);
                B_User      userBll   = new B_User();
                M_UserInfo  info      = userBll.GetSelect(pinfo.UserID);
                MailInfo    mailInfo  = new MailInfo();
                mailInfo.IsBodyHtml = true;
                mailInfo.FromName   = SiteConfig.SiteInfo.SiteName;
                MailAddress address = new MailAddress(info.Email);
                mailInfo.ToAddress = address;
                mailInfo.MailBody  = "尊敬的" + info.UserName + ",您的入金订单" + orderMod1.OrderNo + "购买生效<br/>金额:" + String.Format("{0:N2}", orderMod1.Ordersamount) + "<br/>您可进入<a href='" + SiteConfig.SiteInfo.SiteUrl + "/User/Info/ConsumeDetail.aspx?SType=1'>会员中心</a>查看充值记录<br/>如有任何问题请访问我们网站<a href='" + SiteConfig.SiteInfo.SiteUrl + "'>" + SiteConfig.SiteInfo.SiteUrl + "</a>,联系我们!";
                mailInfo.Subject   = SiteConfig.SiteInfo.SiteName + "网站会员入金提醒";
                SendMail.Send(mailInfo);

                DataTable orderDT = orderBll.GetOrderbyOrderNo(pinfo.PaymentNum);
                foreach (DataRow dr in orderDT.Rows)
                {
                    M_Order_PayLog paylogMod = new M_Order_PayLog();
                    M_OrderList    orderMod  = orderBll.SelModelByOrderNo(dr["OrderNo"].ToString());
                    FinalStep(pinfo, orderMod, paylogMod);
                    //orderCom.SendMessage(orderMod, paylogMod, "payed");
                    //orderCom.SaveSnapShot(orderMod);
                }
                //Response.Write("OK");
                ZLLog.L(ZLEnum.Log.pay, "完成支付" + BillNo);
            }
            catch (Exception ex)
            {
                ZLLog.L(ZLEnum.Log.pay, new M_Log()
                {
                    Action  = "支付回调报错",
                    Message = "平台:双乾,支付单:" + BillNo + ",原因:" + ex.Message
                });
            }
        }
        else
        {
            ZLLog.L(ZLEnum.Log.pay, "双乾验证失败!支付单:" + BillNo);
        }
    }
Example #21
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                string spliteFlag  = "&signMsg=";
                string requestStr  = Request.Form.ToString();
                string srcStr      = requestStr.Substring(0, requestStr.IndexOf(spliteFlag));
                string signStr     = requestStr.Substring(requestStr.IndexOf(spliteFlag) + spliteFlag.Length);
                string spliteFlag2 = "&notifyType=";//0为页面通知,1为异步通知
                int    pos         = signStr.IndexOf(spliteFlag2);
                if (pos > 0)
                {
                    signStr = signStr.Substring(0, pos);
                }
                else
                {
                    pos = srcStr.IndexOf(spliteFlag2);
                    if (pos > 0)
                    {
                        srcStr = srcStr.Substring(0, pos);
                    }
                }
                signStr = System.Web.HttpUtility.UrlDecode(signStr);
                bool verifyResult = Mobo360SignUtil.Instance.verifyData(signStr, srcStr);
                //NotifyType 1:异步,0:同步
                //apiName=PAY_RESULT_NOTIFY&notifyTime=20150327093653&tradeAmt=0.01&merchNo=210001110003583&merchParam=&orderNo=PD12&tradeDate=20150327&accNo=761003&accDate=20150327&orderStatus=1&signMsg=YIfQ7JGp4MIe5hu19lEmWF22aM9xcaL5LqMKlddEv4L7V2vv36qtPKwdS40HOLX1aaVHXgCnwoXnHacrXghRxvM3B1yFuKcCC2q5HnRBnN3Pxg%2bmBUt5WKMJwOC6VbJgqAQvW4UYaubVl7V4TGbAoYGjWuuIFWRthAacPdpK%2bH4%3d&notifyType=1
                //apiName=PAY_RESULT_NOTIFY&notifyTime=20150327094538&tradeAmt=0.01&merchNo=210001110003583&merchParam=&orderNo=PD13&tradeDate=20150327&accNo=761140&accDate=20150327&orderStatus=1&notifyType=0&signMsg=dIUoegWS2HgtHlHwz1i62oYPfGyqgNi5HW%2bew734APG0O9xKLHXbR9atFDxwZpXtovQ7wjPuYgqtwD0R0VsNIr5ceA8dlRETepKo0D8Gi1Z4iGtW3UZ%2f92T8ILMRXEw3fUOMTMxyxk265A0VlAla9pCqMMd8QC5pxNoPWOwKFfo%3d
                #region 校验并更改状态
                //if (verifyResult)//其无法通过自己校验
                //{

                //}
                //else { B_Site_Log.Insert("MO宝校验失败", requestStr); }
                string     orderNo    = Request.Form["orderNo"];//订单号
                string     notifyType = Request.Form["notifyType"];
                double     tradeAmt   = DataConverter.CDouble(Request.Form["tradeAmt"]);
                M_UserInfo mu         = buser.GetLogin(false);
                try
                {
                    if (notifyType.Equals("0"))
                    {
                        function.WriteErrMsg("支付成功"); return;
                    }
                    if (notifyType.Equals("1"))
                    {
                        M_Payment pinfo = payBll.SelModelByPayNo(orderNo);
                        if (pinfo.Status == 3)
                        {
                            return;
                        }
                        pinfo.Status       = 3;
                        pinfo.PlatformInfo = "MO宝在线付款";
                        pinfo.SuccessTime  = DateTime.Now;
                        pinfo.PayTime      = DateTime.Now;
                        pinfo.CStatus      = true;
                        pinfo.MoneyTrue    = tradeAmt;
                        payBll.Update(pinfo);
                        DataTable orderDT = orderBll.GetOrderbyOrderNo(pinfo.PaymentNum);
                        foreach (DataRow dr in orderDT.Rows)
                        {
                            M_OrderList orderMod = orderBll.SelModelByOrderNo(dr["OrderNo"].ToString());
                            if (orderMod.OrderStatus >= 99)
                            {
                                return;                            //订单已处理,避免重复
                            }
                            else
                            {
                                orderBll.UpOrderinfo("Paymentstatus=1,Receivablesamount=" + tradeAmt, orderMod.id);
                            }
                            orderCom.SendMessage(orderMod, paylogMod, "payed");
                            paylogMod.Remind += "订单" + orderMod.OrderNo + "购买生效";
                            FinalStep(orderMod);
                            //-------支付成功处理,并写入日志
                            paylogMod.OrderID   = orderMod.id;
                            paylogMod.UserID    = mu.UserID;
                            paylogMod.PayMethod = (int)M_Order_PayLog.PayMethodEnum.Other;
                            paylogMod.PayMoney  = orderMod.Ordersamount;
                            paylogMod.PayPlatID = 16;
                            paylogBll.insert(paylogMod);
                            Response.Write("SUCCESS"); // 验证签名通过后,商户系统回写“SUCCESS”以表明商户收到了通知
                            B_Site_Log.Insert(pinfo.PaymentNum + ":MO宝处理成功", "状态:" + requestStr);
                        }
                    }
                }
                catch (Exception ex) { B_Site_Log.Insert(orderNo + ":MO宝支付处理失败", "原因:" + ex.Message + ":" + requestStr); }
                #endregion
            }
        }
Example #22
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string posid    = Request.Params["POSID"];    //商户柜台代码
            string branchid = Request.Params["BRANCHID"]; //分行代码
            string orderid  = Request.Params["ORDERID"];  //定单号
            string payment  = Request.Params["PAYMENT"];  //付款金额
            string curcode  = Request.Params["CURCODE"];  //币种
            string remark1  = Request.Params["REMARK1"];  //备注1
            string remark2  = Request.Params["REMARK2"];  //备注2
            string acc_type = Request.Params["ACC_TYPE"]; //账户类型
            string success  = Request.Params["SUCCESS"];
            string sign     = Request.Params["SIGN"];     //数字签名

            M_Payment payMod  = payBll.SelModelByPayNo(branchid);
            M_PayPlat platMod = new M_PayPlat();

            platMod = platBll.SelReturnModel(payMod.PayPlatID);
            if (platMod.PayClass != (int)M_PayPlat.Plat.CCB)
            {
                ZLLog.L(ZLEnum.Log.pay, "回调页面错误" + Request.RawUrl);
            }
            string md5key = string.Format("POSID={0}&BRANCHID={1}&ORDERID={2}&PAYMENT={3}&CURCODE={4}&REMARK1={5}&REMARK2={6}&SUCCESS={7}", posid, branchid, orderid, payment, curcode, remark1, remark2, success);//ACC_TYPE参数(待测试)
            string md5md5 = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(md5key, "MD5").ToLower();

            if (md5md5.Equals(sign))
            {
                if (!success.Equals("Y"))
                {
                    ZLLog.L(ZLEnum.Log.pay, "建行交易失败!支付单:" + orderid);
                }
                ZLLog.L(ZLEnum.Log.pay, "建行:" + remark1 + " 支付单:" + orderid + " 金额:" + payment);
                try
                {
                    M_Payment pinfo = payBll.SelModelByPayNo(orderid);
                    if (pinfo.Status != (int)M_Payment.PayStatus.NoPay)
                    {
                        return;
                    }
                    pinfo.Status       = (int)M_Payment.PayStatus.HasPayed;
                    pinfo.PlatformInfo = "建行支付";       //平台反馈信息
                    pinfo.SuccessTime  = DateTime.Now; //交易成功时间
                    pinfo.CStatus      = true;         //处理状态
                    pinfo.MoneyTrue    = Convert.ToDouble(payment);
                    payBll.Update(pinfo);
                    DataTable orderDT = orderBll.GetOrderbyOrderNo(pinfo.PaymentNum);
                    foreach (DataRow dr in orderDT.Rows)
                    {
                        M_Order_PayLog paylogMod = new M_Order_PayLog();
                        M_OrderList    orderMod  = orderBll.SelModelByOrderNo(dr["OrderNo"].ToString());
                        OrderHelper.FinalStep(pinfo, orderMod, paylogMod);
                        //orderCom.SendMessage(orderMod, paylogMod, "payed");
                        //orderCom.SaveSnapShot(orderMod);
                    }
                    Response.Write("OK");
                    ZLLog.L(ZLEnum.Log.pay, "建行支付成功!支付单:" + orderid);
                }
                catch (Exception ex)
                {
                    ZLLog.L(ZLEnum.Log.pay, new M_Log()
                    {
                        Action  = "支付回调报错",
                        Message = "平台:建行,支付单:" + orderid + ",原因:" + ex.Message
                    });
                }
            }
            else
            {
                ZLLog.L(ZLEnum.Log.pay, "建行验证失败!支付单:" + orderid);
            }
        }
    protected void Page_Load(object sender, EventArgs e)
    {
        M_APIResult retMod = new M_APIResult();

        retMod.retcode  = M_APIResult.Failed;
        retMod.callback = Request["callback"];
        if (string.IsNullOrEmpty(PayNo) || string.IsNullOrEmpty(OpenID))
        {
            retMod.retmsg = "0x53,支付单号或OpenID为空"; RepToClient(retMod);
        }
        try
        {
            M_UserInfo mu     = B_User_API.GetLogin(OpenID);
            M_Payment  payMod = payBll.SelModelByPayNo(PayNo);
            if (mu == null)
            {
                retMod.retmsg = "0x59,用户未登录,或登录已失效";
            }
            else if (payMod == null)
            {
                retMod.retmsg = "0x82,支付单号不存在";
            }
            else if (payMod.Status != (int)M_Payment.PayStatus.NoPay)
            {
                retMod.retmsg = "0x14,支付单已付过款,不能重复支付";
            }
            else if (payMod.MoneyReal <= 0)
            {
                retMod.retmsg = "0x56,支付单金额异常";
            }
            //else if (payMod.UserID != mu.UserID) { retMod.retmsg = "x058,该支付单并非你所有"; }
            else
            {
                //*不要看程序内部的报错,直接看Repsonse返回,其才是真正的报错
                TimeSpan ts = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0);
                timestr = Convert.ToInt64(ts.TotalSeconds).ToString();
                //------------统一下单,获取预付单号
                WxPayData wxdata = new WxPayData(PlatConfig.WXPay_Key);
                wxdata.SetValue("appid", PlatConfig.WXPay_APPID);
                wxdata.SetValue("attach", "attach"); //test
                wxdata.SetValue("body", "pay");      //不允许为空,中文需要单独处理
                wxdata.SetValue("mch_id", PlatConfig.WXPay_MCHID);
                wxdata.SetValue("nonce_str", nonceStr);
                wxdata.SetValue("notify_url", notifyUrl);
                wxdata.SetValue("out_trade_no", PayNo);                                //支付单号
                wxdata.SetValue("spbill_create_ip", ip);                               //Can be empty
                wxdata.SetValue("total_fee", (payMod.MoneyReal * 100).ToString("f0")); //(payMod.MoneyReal * 100).ToString("f0")
                wxdata.SetValue("trade_type", "APP");

                WxPayData result = UnifiedOrder(wxdata);
                //if (result.GetValue("return_code") != "SUCCESS") { retMod.retmsg = result.GetValue("return_msg").ToString(); RepToClient(retMod); }
                //------------生成返回给APP端的数据
                timestr = Convert.ToInt64(ts.TotalSeconds).ToString();
                WxPayData appdata = new WxPayData(PlatConfig.WXPay_Key);
                appdata.SetValue("appid", PlatConfig.WXPay_APPID);
                appdata.SetValue("partnerid", PlatConfig.WXPay_MCHID);
                appdata.SetValue("package", "Sign=WXPay");
                appdata.SetValue("noncestr", nonceStr);
                appdata.SetValue("timestamp", timestr);
                appdata.SetValue("prepayid", result.GetValue("prepay_id").ToString());
                appdata.SetValue("sign", appdata.MakeSign());

                retMod.result  = "{\"appid\":\"" + PlatConfig.WXPay_APPID + "\",\"partnerid\":\"" + PlatConfig.WXPay_MCHID + "\",\"package\":\"Sign=WXPay\",\"noncestr\":\"" + nonceStr + "\",\"timestamp\":" + timestr + ",\"prepayid\":\"" + result.GetValue("prepay_id").ToString() + "\",\"sign\":\"" + appdata.GetValue("sign") + "\"}";
                retMod.retcode = M_APIResult.Success;
                ZLLog.L("生成微信预付单完成" + retMod.result);
                payBll.UpdatePlat(payMod.PaymentID, M_PayPlat.Plat.WXPay, appMod.ID.ToString());
            }
        }
        catch (Exception ex) { retMod.retcode = M_APIResult.Failed; retMod.retmsg = "server exception:" + ex.Message; ZLLog.L("微信预付单报错" + retMod.retmsg); }
        RepToClient(retMod);
        //正确返回
        //<xml><return_code><![CDATA[SUCCESS]]></return_code>
        //<return_msg><![CDATA[OK]]></return_msg>
        //<appid><![CDATA[wxe4703a7618738bed]]></appid>
        //<mch_id><![CDATA[1342097701]]></mch_id>
        //<nonce_str><![CDATA[LYJFMZbGIaa2LezS]]></nonce_str>
        //<sign><![CDATA[440C7616B9658FD7102805895E6808CC]]></sign>
        //<result_code><![CDATA[SUCCESS]]></result_code>
        //<prepay_id><![CDATA[wx201605160903248f02bc5ab10976835276]]></prepay_id>
        //<trade_type><![CDATA[APP]]></trade_type>
        //</xml>
        //转成Json回发给APP
        //{"appid":"wxb4ba3c02aa476ea1","partnerid":"1305176001","package":"Sign=WXPay","noncestr":"717cbf90679a1f26d6b8211efaed3ffb","timestamp":1463394698,"prepayid":"wx20160516183138c3ac06576e0471509227","sign":"414C383FA311DAC74DC882BA89A5E296"}
    }
Example #24
0
        protected void Page_Load(object sender, EventArgs e)
        {
            B_User.CheckIsLogged(Request.RawUrl);
            M_UserInfo mu = buser.GetLogin();

            if (mu.Status != 0)
            {
                function.WriteErrMsg("你的帐户未通过验证或被锁定");
            }
            if (!IsPostBack)
            {
                M_Payment payMod  = new M_Payment();
                DataTable orderDT = new DataTable();
                purseli.Visible = SiteConfig.SiteOption.SiteID.Contains("purse");
                siconli.Visible = SiteConfig.SiteOption.SiteID.Contains("sicon");
                pointli.Visible = SiteConfig.SiteOption.SiteID.Contains("point");
                if (Money > 0)//直接传要充多少,用于充值余额等
                {
                    payMod = CreateChargePay(mu);
                    Response.Redirect("OrderPay.aspx?Payno=" + payMod.PayNo); return;
                }
                else if (!string.IsNullOrEmpty(PayNo))
                {
                    payMod = payBll.SelModelByPayNo(PayNo);
                    OrderHelper.OrdersCheck(payMod);
                    orderDT = orderBll.GetOrderbyOrderNo(payMod.PaymentNum);
                }
                else
                {
                    M_OrderList orderMod = orderBll.SelModelByOrderNo(OrderNo);
                    OrderHelper.CheckIsCanPay(orderMod);
                    orderDT = orderBll.GetOrderbyOrderNo(OrderNo);
                }
                if (orderDT != null && orderDT.Rows.Count > 0)
                {
                    //如果是跳转回来的,检测其是否包含充值订单
                    foreach (DataRow dr in orderDT.Rows)
                    {
                        if (DataConverter.CLng(dr["Ordertype"]) == (int)M_OrderList.OrderEnum.Purse)
                        {
                            virtual_ul.Visible = false; break;
                        }
                    }
                    //总金额,如有支付单,以支付单的为准
                    GetTotal(orderDT, ref price, ref fare, ref allamount);
                    if (!string.IsNullOrEmpty(PayNo))
                    {
                        allamount    = (double)payMod.MoneyPay;
                        arrive       = payMod.ArriveMoney;
                        point        = payMod.UsePoint;
                        point_arrive = payMod.UsePointArrive;
                    }
                    TotalMoney_L.Text     = allamount.ToString("f2");
                    TotalMoneyInfo_T.Text = price.ToString("f2") + " + " + fare.ToString("f2") + " - " + arrive.ToString("f2") + "-" + point_arrive.ToString("f2") + "(" + point + ")" + " = " + allamount.ToString("f2");
                    TotalMoneyInfo_T.Text = TotalMoneyInfo_T.Text + " (商品总价+运费-优惠券-积分兑换=总额)";
                    if (string.IsNullOrEmpty(OrderNo) && Money > 0)
                    {
                        OrderNo_L.Text = "用户充值";
                    }
                    else if (payMod.PaymentID > 0)
                    {
                        OrderNo_L.Text = payMod.PaymentNum.Trim(',');
                    }
                    else
                    {
                        OrderNo_L.Text = OrderNo;
                    }
                }
                //支付平台
                BindPlat();
                if (payMod.SysRemark == "用户充值")
                {
                    virtual_ul.Visible = false;
                }
                //如果已用优惠券|积分,抵扣了金额,则可直接支付
                if (payMod.MoneyReal == 0)
                {
                    FinalStep(payMod);
                }
            }
        }
Example #25
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                B_WX_APPID wxBll  = new B_WX_APPID();
                B_Content  conBll = new B_Content();
                M_Payment  payMod = payBll.SelModelByPayNo(PayNo);
                if (payMod == null)
                {
                    function.WriteErrMsg("支付单不存在");
                }
                if (payMod.Status != (int)M_Payment.PayStatus.NoPay)
                {
                    function.WriteErrMsg("该订单不可付款");
                }
                M_OrderList orderMod = orderBll.SelModelByOrderNo(payMod.PaymentNum.Trim(','));
                if (orderMod.StoreID < 1)
                {
                    function.WriteErrMsg("订单未绑定店铺");
                }
                M_CommonData storeMod = conBll.SelReturnModel(orderMod.StoreID);
                if (storeMod == null)
                {
                    function.WriteErrMsg("店铺信息不存在");
                }
                appMod = wxBll.SelReturnModel(DataConverter.CLng(storeMod.SpecialID));
                if (appMod == null)
                {
                    function.WriteErrMsg("店铺未绑定微信");
                }
                //appMod = WxPayApi.Pay_GetByID(AppID);
                if (string.IsNullOrEmpty(appMod.APPID))
                {
                    throw new Exception("未设置APPID");
                }
                if (string.IsNullOrEmpty(appMod.Secret))
                {
                    throw new Exception("未指定Secret");
                }
                if (string.IsNullOrEmpty(appMod.Pay_AccountID))
                {
                    throw new Exception("未设置商户号");
                }
                if (string.IsNullOrEmpty(appMod.Pay_Key))
                {
                    throw new Exception("未设置支付Key");
                }

                //首次进入自动跳转获取支付code
                if (!State.Equals("redirect"))
                {
                    string siteurl = HttpUtility.UrlEncode(SiteConfig.SiteInfo.SiteUrl + "/PayOnline/wxpay_mp.aspx?payno=" + PayNo + "&appid=" + appMod.ID + "&SuccessUrl=" + SuccessUrl);
                    string url     = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=" + appMod.APPID + "&redirect_uri=" + siteurl + "&response_type=code&scope=snsapi_userinfo&state=redirect#wechat_redirect";
                    Response.Redirect(url);
                }
                WeiXinPay();//统一下单,并填充预付单号
                timestr = WxAPI.HP_GetTimeStamp();
                string stringA        = "appId=" + appMod.APPID + "&nonceStr=" + WxAPI.nonce + "&package=prepay_id=" + prepay_id + "&signType=MD5&timeStamp=" + timestr;
                string stringSignTemp = stringA + "&key=" + appMod.Pay_Key;
                paySign = StringHelper.MD5(stringSignTemp).ToUpper();
            }
        }
Example #26
0
    public void MyBind()
    {
        DataTable  dt = new DataTable();
        M_UserInfo mu = buser.GetLogin();

        switch (SType)
        {
        case 0:    //订单
            orderMod = orderBll.SelModelByOrderNo(OrderNo);

            //Total_L.Text = orderMod.Balance_price.ToString("f2") + "+" + orderMod.Freight.ToString("f2") + "=" + orderMod.Ordersamount.ToString("f2") + "元 (金额+运费)";

            labelmoney01.Text      = orderMod.Receivablesamount.ToString("f2");
            ExpressNum_T.Text      = orderMod.ExpressNum;
            ExpressDelivery_T.Text = orderMod.ExpressDelivery;
            if (orderMod == null || orderMod.id == 0)
            {
                function.WriteErrMsg("订单不存在");
            }
            if (orderMod.Userid != mu.UserID)
            {
                function.WriteErrMsg("该订单不属于你,无法查看");
            }
            dt        = SelByOrderID(orderMod.id);
            price     = orderMod.Balance_price;
            fare      = orderMod.Freight;
            allamount = orderMod.Ordersamount;
            DataTable dt1 = SqlHelper.ExecuteTable("select * from ZL_Payment where PaymentNum='" + orderMod.OrderNo + "' order by PayTime DESC");
            if (dt1.Rows.Count > 0)
            {
                payMod    = payBll.SelModelByPayNo(dt1.Rows[0]["PayNo"].ToString());
                allamount = (double)payMod.MoneyPay;
                arrive    = payMod.ArriveMoney;
                point     = payMod.UsePoint;
            }
            Total_L.Text = price.ToString("f2") + " + " + fare.ToString("f2") + " - " + arrive.ToString("f2") + "-" + (point * 0.01).ToString("f2") + "(" + point + ")" + " = " + allamount.ToString("f2");
            Total_L.Text = Total_L.Text + " (商品总价+运费-优惠券-积分兑换=总额)";
            break;

        case 1:    //购物车
            dt = cartBll.GetCarProList(OrderNo);
            break;
        }
        if (orderMod.Paymentstatus != (int)M_OrderList.PayEnum.HasPayed)
        {
            PayUrl_A.Visible = true;
            DataTable dt1    = SqlHelper.ExecuteTable("select * from ZL_Payment where PaymentNum='" + orderMod.OrderNo + "' order by PayTime DESC");
            string    payurl = "&OrderCode=" + orderMod.OrderNo;
            if (dt1.Rows.Count > 0)
            {
                payurl = "&PayNo=" + dt1.Rows[0]["PayNo"];
            }
            uappMod = uappBll.SelModelByUid(buser.GetLogin().UserID, "wechat");
            if (uappMod != null)
            {
                M_WX_User wxuserMod1 = wxuserBll.SelForOpenid(1, uappMod.OpenID);
                M_WX_User wxuserMod2 = wxuserBll.SelForOpenid(2, uappMod.OpenID);
                if (wxuserMod1 != null && wxuserMod2 == null)
                {
                    PayUrl_A.HRef = "/PayOnline/OrderPay.aspx?appid=1" + payurl;
                }
                else if (wxuserMod2 != null && wxuserMod1 == null)
                {
                    PayUrl_A.HRef = "/PayOnline/OrderPay.aspx?appid=2" + payurl;
                }
                else if (wxuserMod1 == null && wxuserMod2 == null)
                {
                    PayUrl_A.HRef = "/PayOnline/OrderPay.aspx?" + payurl;
                }
            }
            else
            {
                PayUrl_A.HRef = "/PayOnline/OrderPay.aspx?" + payurl;
            }
        }
        if (dt.Rows.Count > 0 && !string.IsNullOrEmpty(dt.Rows[0]["Additional"].ToString()))
        {
            User_Div.Visible = true;
            M_Cart_Travel          model     = JsonConvert.DeserializeObject <M_Cart_Travel>(dt.Rows[0]["Additional"].ToString());
            List <M_Cart_Contract> modelList = new List <M_Cart_Contract>();
            modelList.AddRange(model.Guest);
            modelList.AddRange(model.Contract);
            UserRPT.DataSource = modelList;
            UserRPT.DataBind();
        }
        pronum         = dt.Rows.Count;
        RPT.DataSource = dt;
        RPT.DataBind();
    }
Example #27
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string md5sign      = Request.Params["sign"];
            string notify_id    = Request.Params["notify_id"];
            string out_trade_no = Request.Params["out_trade_no"];
            string subject      = Request.Params["subject"];
            string payment_type = Request.Params["payment_type"];
            string trade_status = Request.Params["trade_status"];//交易状态,TRADE_FINISHED 表示成功
            string total_fee    = Request.Params["total_fee"];
            string seller_id    = Request.Params["seller_id"];

            string[] paramkeys = new string[Request.QueryString.AllKeys.Length];
            Request.QueryString.AllKeys.CopyTo(paramkeys, 0);
            Array.Sort(paramkeys);
            string paramstr = "";

            foreach (string item in paramkeys)
            {
                if (!item.Equals("sign"))
                {
                    paramstr += string.Format("{0}={1}&", item, Request.QueryString[item]);
                }
            }
            M_Payment payMod  = payBll.SelModelByPayNo(out_trade_no);
            M_PayPlat platMod = new M_PayPlat();

            platMod = platBll.SelReturnModel(payMod.PayPlatID);
            if (platMod.PayClass != (int)M_PayPlat.Plat.Ebatong)
            {
                ZLLog.L(ZLEnum.Log.safe, "回调页面错误" + Request.RawUrl);
            }
            string sign = new CommonHelper().md5("UTF-8", paramstr.Trim('&') + platMod.MD5Key).ToLower();

            if (sign.Equals(md5sign))
            {
                ZLLog.L(ZLEnum.Log.pay, "贝付:" + subject + " 交易状态:" + trade_status + " 支付单:" + out_trade_no + " 金额:" + total_fee);

                if (!trade_status.Equals("TRADE_FINISHED"))
                {
                    ZLLog.L(ZLEnum.Log.pay, "贝付交易失败!支付单:" + out_trade_no);
                }
                try
                {
                    M_Payment pinfo = payBll.SelModelByPayNo(out_trade_no);
                    if (pinfo.Status != (int)M_Payment.PayStatus.NoPay)
                    {
                        return;
                    }
                    pinfo.Status       = (int)M_Payment.PayStatus.HasPayed;
                    pinfo.PlatformInfo = "贝付通";        //平台反馈信息
                    pinfo.SuccessTime  = DateTime.Now; //交易成功时间
                    pinfo.CStatus      = true;         //处理状态
                    pinfo.MoneyTrue    = Convert.ToDouble(total_fee);
                    payBll.Update(pinfo);
                    DataTable orderDT = orderBll.GetOrderbyOrderNo(pinfo.PaymentNum);
                    foreach (DataRow dr in orderDT.Rows)
                    {
                        M_Order_PayLog paylogMod = new M_Order_PayLog();
                        M_OrderList    orderMod  = orderBll.SelModelByOrderNo(dr["OrderNo"].ToString());
                        OrderHelper.FinalStep(pinfo, orderMod, paylogMod);
                        //orderCom.SendMessage(orderMod, paylogMod, "payed");
                        //orderCom.SaveSnapShot(orderMod);
                    }
                    Response.Write(notify_id);
                    ZLLog.L(ZLEnum.Log.pay, "贝付平台支付成功!支付单:" + out_trade_no);
                }
                catch (Exception ex)
                {
                    ZLLog.L(ZLEnum.Log.pay, new M_Log()
                    {
                        Action  = "支付回调报错",
                        Message = "平台:贝付,支付单:" + out_trade_no + ",原因:" + ex.Message
                    });
                }
            }
            else
            {
                ZLLog.L(ZLEnum.Log.safe, "贝付通验证失败!支付单:" + out_trade_no);
            }
        }
Example #28
0
    //支付成功时执行的操作
    private void PayOrder_Success(WxPayData result)
    {
        ZLLog.L(ZLEnum.Log.pay, "微信:微信支付 支付单:" + result.GetValue("out_trade_no") + " 金额:" + result.GetValue("total_fee"));
        try
        {
            M_Order_PayLog paylogMod = new M_Order_PayLog();
            M_Payment      pinfo     = payBll.SelModelByPayNo(result.GetValue("out_trade_no").ToString());
            if (pinfo == null)
            {
                throw new Exception("支付单不存在");
            }                                                    //支付单检测合为一个方法
            if (pinfo.Status != (int)M_Payment.PayStatus.NoPay)
            {
                throw new Exception("支付单状态不为未支付");
            }
            pinfo.Status       = (int)M_Payment.PayStatus.HasPayed;
            pinfo.PlatformInfo = "微信扫码|公众号支付";
            pinfo.SuccessTime  = DateTime.Now;
            pinfo.PayTime      = DateTime.Now;
            pinfo.CStatus      = true;
            //1=100,
            double tradeAmt = Convert.ToDouble(result.GetValue("total_fee")) / 100;
            pinfo.MoneyTrue = tradeAmt;
            payBll.Update(pinfo);
            DataTable orderDT = orderBll.GetOrderbyOrderNo(pinfo.PaymentNum);
            foreach (DataRow dr in orderDT.Rows)
            {
                M_OrderList orderMod = orderBll.SelModelByOrderNo(dr["OrderNo"].ToString());
                OrderHelper.FinalStep(pinfo, orderMod, paylogMod);
                if (orderMod.Ordertype == (int)M_OrderList.OrderEnum.Purse)
                {
                    M_UserInfo mu = buser.SelReturnModel(orderMod.Userid);
                    new B_Shop_MoneyRegular().AddMoneyByMin(mu, orderMod.Ordersamount, ",订单号[" + orderMod.OrderNo + "]");
                }
                orderCom.SendMessage(orderMod, paylogMod, "payed");
                //orderCom.SaveSnapShot(orderMod);

                if (orderMod.Ordertype != 6)
                {
                    buser.ChangeVirtualMoney(orderMod.Userid, new M_UserExpHis()
                    {
                        score     = orderMod.Ordersamount,
                        ScoreType = 3,
                        detail    = "在线消费赠送积分:" + orderMod.Ordersamount
                    });
                }
                //订单返利
                OrderRebates(orderMod.Userid, orderMod.Ordersamount);
                //订单打印
                int orderID  = DataConvert.CLng(dr["ID"].ToString());
                int StoreID  = DataConvert.CLng(dr["StoreID"].ToString());
                int devID    = GetPrintDevice(StoreID);  //设备ID
                int tlpID    = GetPrintModelID(StoreID); //模板ID
                int printnum = GetPrintNum(StoreID);
                //------------------------------
                DataTable          orderDT1 = DBCenter.Sel("ZL_OrderInfo", "ID=" + orderID);
                M_Shop_PrintTlp    tlpMod   = tlpBll.SelReturnModel(tlpID);
                M_Shop_PrintDevice devMod   = devBll.SelReturnModel(devID);
                string             msg      = orderCOM.TlpDeal(tlpMod.Content, orderDT1);
                ZLLog.L(ZLEnum.Log.pay, msg);
                msgBll.Insert(msg, tlpMod.ID, devMod, printnum);
                //function.WriteSuccessMsg("信息已发送", "MessageList.aspx");

                //发送微信通知
                try
                {
                    userappMod = userappBll.SelModelByUid(DataConvert.CLng(dr["UserID"]), "wechat");
                    if (userappMod != null)
                    {
                        WxAPI wxapi = WxAPI.Code_Get(1);
                        if (dr["Ordertype"].ToString() == "6")
                        {
                            M_UserInfo userMod = buser.GetUserByUserID(DataConvert.CLng(dr["UserID"]));
                            wxapi.Tlp_SendTlpMsg(userappMod.OpenID, "vRUiDj-k6EGjwQC2GO4oU1G37CJjiu2fZ-ePBj1jJ60", "http://v.wodian8.com/User/Order/OrderList1.aspx", "{\"first\": {\"value\":\"您好,您已经充值成功。\",\"color\":\"#173177\"},\"keyword1\":{\"value\":\"" + DataConvert.CDouble(dr["Ordersamount"]).ToString("0.00") + "\",\"color\":\"#173177\"},\"keyword2\": {\"value\":\"" + DateTime.Now.ToString("yyyy年MM月dd日 HH:mm:ss") + "\",\"color\":\"#173177\"},\"keyword3\": {\"value\":\"" + userMod.Purse.ToString("0.00") + "\",\"color\":\"#173177\"},\"remark\":{\"value\":\"感谢您对我们的信任,我们将为您提供更优质的服务。\",\"color\":\"#173177\"}}");
                        }
                        else
                        {
                            wxapi.Tlp_SendTlpMsg(userappMod.OpenID, "E-yWv8GVKeJHymtTB0zOGKnEv6LXodjr-M6tj1sLzfM", "http://v.wodian8.com/User/Order/OrderList1.aspx", "{\"first\": {\"value\":\"您的订单支付成功!\",\"color\":\"#173177\"},\"keyword1\":{\"value\":\"" + dr["OrderNo"].ToString() + "\",\"color\":\"#173177\"},\"keyword2\": {\"value\":\"" + GetProname(DataConvert.CLng(dr["ID"])) + "\",\"color\":\"#173177\"},\"keyword3\": {\"value\":\"" + DataConvert.CDouble(dr["Ordersamount"]).ToString("0.00") + "\",\"color\":\"#173177\"},\"keyword4\": {\"value\":\"" + DateTime.Now.ToString("yyyy年MM月dd日 HH:mm:ss") + "\",\"color\":\"#173177\"},\"remark\":{\"value\":\"点击查看订单详情!\",\"color\":\"#173177\"}}");
                        }
                    }
                }
                catch (Exception ex)
                {
                    ZLLog.L(ZLEnum.Log.pay, new M_Log()
                    {
                        Action  = "发送微信通知报错",
                        Message = "原因:" + ex.Message
                    });
                    throw;
                }
            }
            ZLLog.L(ZLEnum.Log.pay, "微信支付成功!支付单:" + result.GetValue("out_trade_no").ToString());
        }
        catch (Exception ex)
        {
            ZLLog.L(ZLEnum.Log.pay, new M_Log()
            {
                Action  = "支付回调报错",
                Message = "平台:微信,支付单:" + result.GetValue("out_trade_no").ToString() + ",原因:" + ex.Message
            });
        }
    }
Example #29
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //DataTable pay = payPlatBll.GetPayPlatByClassid(12);
            M_PayPlat platMod = payPlatBll.SelModelByClass(M_PayPlat.Plat.Alipay_Instant);
            SortedDictionary <string, string> sArrary = GetRequestPost();

            ///////////////////////以下参数是需要设置的相关配置参数,设置后不会更改的//////////////////////
            ZoomLa.Model.M_Alipay_config con = new ZoomLa.Model.M_Alipay_config();
            string partner       = platMod.AccountID;
            string key           = platMod.MD5Key;
            string input_charset = con.Input_charset;
            string sign_type     = con.Sign_type;
            string transport     = con.Transport;

            //////////////////////////////////////////////////////////////////////////////////////////////
            if (sArrary.Count > 0)//判断是否有带返回参数
            {
                ZoomLa.BLL.B_Alipay_notify aliNotify = new ZoomLa.BLL.B_Alipay_notify(sArrary, Request.Form["notify_id"], partner, key, input_charset, sign_type, transport);
                string responseTxt = aliNotify.ResponseTxt;     //获取远程服务器ATN结果,验证是否是支付宝服务器发来的请求
                string sign        = Request.Form["sign"];
                string mysign      = aliNotify.Mysign;          //获取通知返回后计算后(验证)的签名结果
                                                                //判断responsetTxt是否为ture,生成的签名结果mysign与获得的签名结果sign是否一致
                                                                //responsetTxt的结果不是true,与服务器设置问题、合作身份者ID、notify_id一分钟失效有关
                                                                //mysign与sign不等,与安全校验码、请求时的参数格式(如:带自定义参数等)、编码格式有关
                string order_no = Request.Form["out_trade_no"]; //获取订单号
                ZLLog.L(ZLEnum.Log.pay, PayPlat + aliNotify.ResponseTxt + ":" + order_no + ":" + Request.Form["buyer_email"] + ":" + Request.Form["trade_status"] + ":" + Request.Form["price"] + ":" + Request.Form["subject"]);
                if (responseTxt == "true" && sign == mysign)    //验证成功
                {
                    //——请根据您的业务逻辑来编写程序(以下代码仅作参考)——
                    //获取通知返回参数,可参考技术文档中服务器异步通知参数列表
                    string trade_no     = Request.Form["trade_no"];       //交易号
                    string total_fee    = Request.Form["price"];          //获取总金额
                    string subject      = Request.Form["subject"];        //商品名称、
                    string body         = Request.Form["body"];           //商品描述、订单备注、描述
                    string buyer_email  = Request.Form["buyer_email"];    //买家账号
                    string trade_status = Request.Form["trade_status"];   //交易状态
                    if (Request.Form["trade_status"] == "WAIT_BUYER_PAY") //没有付款
                    {
                    }
                    else if (trade_status.Equals("WAIT_SELLER_SEND_GOODS"))//付款成功,但是卖家没有发货
                    {
                    }
                    else if (trade_status.Equals("TRADE_SUCCESS"))//付款成功
                    {
                        try
                        {
                            M_Payment pinfo = payBll.SelModelByPayNo(order_no);
                            if (pinfo.Status != (int)M_Payment.PayStatus.NoPay)
                            {
                                return;
                            }
                            pinfo.Status       = (int)M_Payment.PayStatus.HasPayed;
                            pinfo.PlatformInfo = PayPlat;      //平台反馈信息
                            pinfo.SuccessTime  = DateTime.Now; //交易成功时间
                            pinfo.CStatus      = true;         //处理状态
                            pinfo.AlipayNO     = trade_no;     //保存支付宝交易号
                            pinfo.MoneyTrue    = Convert.ToDouble(total_fee);
                            payBll.Update(pinfo);
                            DataTable orderDT = orderBll.GetOrderbyOrderNo(pinfo.PaymentNum);
                            foreach (DataRow dr in orderDT.Rows)
                            {
                                M_Order_PayLog paylogMod = new M_Order_PayLog();
                                M_OrderList    orderMod  = orderBll.SelModelByOrderNo(dr["OrderNo"].ToString());
                                OrderHelper.FinalStep(pinfo, orderMod, paylogMod);
                                orderCOM.SendMessage(orderMod, paylogMod, "payed");
                            }
                            Response.Write("success");
                            ZLLog.L(ZLEnum.Log.pay, PayPlat + "成功!支付单:" + order_no);
                        }
                        catch (Exception ex)
                        {
                            ZLLog.L(ZLEnum.Log.pay, new M_Log()
                            {
                                Action  = "支付回调报错",
                                Message = PayPlat + ",支付单:" + order_no + ",原因:" + ex.Message
                            });
                        }
                    }
                    else if (Request.Form["trade_status"] == "WAIT_BUYER_CONFIRM_GOODS")//卖家已经发货,等待买家确认
                    {
                    }
                    else if (Request.Form["trade_status"] == "TRADE_FINISHED")
                    {
                    }
                    else//其他状态判断。普通即时到帐中,其他状态不用判断,直接打印success。
                    {
                        ZLLog.L(PayPlat + "付款未成功截获,单号:[" + trade_status + "]");
                    }
                }
                else//验证失败
                {
                    ZLLog.L(ZLEnum.Log.pay, new M_Log()
                    {
                        Action  = "支付验证失败",
                        Message = PayPlat + ",支付单:" + order_no
                    });
                    Response.Write("fail");
                }
            }
            else
            {
                Response.Write("success");
            }
        }
Example #30
0
 protected void Page_Load(object sender, EventArgs e)
 {
     platMod = new B_PayPlat().SelModelByClass(M_PayPlat.Plat.PayPal);
     try
     {
         if (CheckSign())
         {
             string payno  = executedPayment.transactions[0].invoice_number;
             double amount = DataConvert.CDouble(executedPayment.transactions[0].related_resources[0].sale.amount.total);
             PaySuccess(payno, amount);
             //-----------------
             payMod   = payBll.SelModelByPayNo(payno);
             orderMod = orderBll.SelModelByOrderNo(payMod.PaymentNum.Trim(','));
             M_Order_Contact conMod = new B_Order_Contact().SelModelByOid(orderMod.id);
             PayNo_L.Text   = payMod.PayNo;
             OrderNo_L.Text = orderMod.OrderNo;
             Amount_L.Text  = payMod.MoneyPay.ToString("F2");
             Email_L.Text   = conMod.Email;
             DBCenter.DelByWhere("ZL_Cart", "CartId=@cartid", new List <SqlParameter>()
             {
                 new SqlParameter("cartid", B_Cart.GetCartID(Context))
             });
             EventDeal.SendOrderEmailByType(orderMod.id, "payed", SiteConfig.SiteInfo.WebmasterEmail);
             EventDeal.SendOrderEmailByType(orderMod.id, "payed");
         }
         else
         {
             ZLLog.L(ZLEnum.Log.pay, "[" + PayPlat + "]签名验证失败,返回:" + ServerReturn);
             function.WriteErrMsg("Validation failed, information mismatch");
         }
     }
     catch (Exception ex)
     {
         Log("[" + PayPlat + "]出错,原因:" + ex.Message + ",返回:" + ServerReturn);
         success_div.Visible = false;
         fail_div.Visible    = true;
         //------------------------------------
         payMod = payBll.SelModelByPayNo(Request["payno"]);
         if (payMod == null)
         {
             function.WriteErrMsg("order does not exist");
         }
         if (payMod.Status != (int)M_Payment.PayStatus.NoPay)
         {
             function.WriteErrMsg("The order has been paid and cannot be repeated");
         }
         orderMod            = orderBll.SelModelByOrderNo(payMod.PaymentNum.Trim(','));
         Fail_PayNo_L.Text   = payMod.PayNo;
         Fail_OrderNo_L.Text = orderMod.OrderNo;
         Fail_Amount_L.Text  = payMod.MoneyPay.ToString("F2");
         //------------------------------------
         //if (string.IsNullOrEmpty(payMod.code))
         //{
         //    string cartId = B_Cart.GetCartID(Context);
         //    B_Cart cartBll = new B_Cart();
         //    B_CartPro cpBll = new B_CartPro();
         //    DataTable cartDT = cpBll.SelByOrderID(orderMod.id);
         //    foreach (DataRow cartDR in cartDT.Rows)
         //    {
         //        M_Cart cartMod = new M_Cart().GetModelFromReader(cartDR);
         //        cartMod.userid = 10000;
         //        cartMod.Cartid = cartId;
         //        cartMod.ProAttr = DataConvert.CStr(cartDR["Attribute"]);
         //        cartBll.insert(cartMod);
         //    }
         //    DBCenter.UpdateSQL(payMod.TbName,"Code='1'", "PaymentID=" + payMod.PaymentID);
         //}
         //function.WriteErrMsg("Error:Unfinished payment");
     }
 }