Ejemplo n.º 1
0
        public static string TenPaySubmit(HttpContext Context)
        {
            string sRes = string.Empty;

            //创建PayResponseHandler实例
            PayResponseHandler resHandler = new PayResponseHandler(Context);

            resHandler.setKey(key);

            //判断签名
            if (resHandler.isTenpaySign())
            {
                //交易单号
                string transaction_id = resHandler.getParameter("transaction_id");

                //金额,以分为单位
                string total_fee = resHandler.getParameter("total_fee");

                //支付结果
                string pay_result = resHandler.getParameter("pay_result");

                string sp_billno = resHandler.getParameter("sp_billno");

                string attach = resHandler.getParameter("attach");
                if ("0".Equals(pay_result))
                {
                    //注意交易单不要重复处理
                    //注意判断返回金额
                    string  sTranID  = string.Format("{0}{1}", sp_billno, attach.Split('|')[0]);
                    decimal dPrice   = decimal.Parse(total_fee) / 100;
                    string  sAccount = attach.Split('|')[1];
                    int     j        = TransPBLL.PointSalesCommit(sTranID, sAccount, dPrice); //确认返回信息无误后提交此定单
                    if (0 == j)
                    {
                        resHandler.doShow(string.Format("PayPSucc.aspx?TranID={0}", sTranID));
                    }
                    sRes = j.ToString();
                }
                else
                {
                    sRes = "-1";
                }
            }
            else
            {
                sRes = "-2";
            }
            return(sRes);
        }
Ejemplo n.º 2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        //创建PayResponseHandler实例
        PayResponseHandler resHandler = new PayResponseHandler(Context);

        resHandler.setKey(TenpayUtil.tenpay_key);

        //判断签名
        if (resHandler.isTenpaySign())
        {
            //交易单号
            string transaction_id = resHandler.getParameter("transaction_id");

            //金额金额,以分为单位
            string total_fee = resHandler.getParameter("total_fee");

            //支付结果
            string pay_result = resHandler.getParameter("pay_result");

            if ("0".Equals(pay_result))
            {
                //------------------------------
                //处理业务开始
                //------------------------------

                //注意交易单不要重复处理
                //注意判断返回金额

                //------------------------------
                //处理业务完毕
                //------------------------------

                //调用doShow, 打印meta值跟js代码,告诉财付通处理成功,并在用户浏览器显示$show页面.
                resHandler.doShow(TenpayUtil.tenpay_show);
            }
            else
            {
                //当做不成功处理
                Response.Write("支付失败");
            }
        }
        else
        {
            Response.Write("认证签名失败");
            //string debugInfo = resHandler.getDebugInfo();
            //Response.Write("<br/>debugInfo:" + debugInfo);
        }
    }
Ejemplo n.º 3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Page.User.Identity.Name == null || Page.User.Identity.Name.Trim() == "")
        {
            Response.Redirect("../Login.aspx");
        }
        string loginname = Page.User.Identity.Name;

        string             key        = OnlineStrike.getTenKey();        //密钥
        PayResponseHandler resHandler = new PayResponseHandler(Context); //创建PayResponseHandler实例

        resHandler.setKey(key);

        if (resHandler.isTenpaySign())                                         //判断签名
        {
            string transaction_id = resHandler.getParameter("transaction_id"); //交易单号
            string total_fee      = resHandler.getParameter("total_fee");      //金额金额,以分为单位
            total_fee = Convert.ToString(Convert.ToInt32(total_fee) / 100);
            string pay_result = resHandler.getParameter("pay_result");         //支付结果
            string orderNo    = transaction_id.Substring(17, 10).Trim();

            lab_OrderNo.Text = orderNo;
            lab_Point.Text   = total_fee.Trim();
            lab_TenNo.Text   = transaction_id.Trim();

            if ("0".Equals(pay_result))
            {
                //开始处理业务
                Tz888.BLL.StrikeOrder dal = new Tz888.BLL.StrikeOrder();
                bool b = dal.StrikeSuccess(orderNo, "tenpay", transaction_id, loginname);

                //调用doShow, 打印meta值跟js代码,告诉财付通处理成功,并在用户浏览器显示$show页面.
                resHandler.doShow("http://member.topfo.com/PayManage/show.aspx");
            }
            else
            {
                Response.Write("支付失败");         //当做不成功处理
            }
        }
        else
        {
            Response.Write("认证签名失败");
            //string debugInfo = resHandler.getDebugInfo();
            //Response.Write("<br/>debugInfo:" + debugInfo);
        }
    }
Ejemplo n.º 4
0
        public bool ReturnPay()
        {
            //密钥
            String key = Model.SitePayAPI.GetModel(t => t.ApiType == "财付通").AppKey;


            PayResponseHandler resHandler = new PayResponseHandler(context);

            resHandler.setKey(key);

            //判断签名
            if (resHandler.isTenpaySign())
            {
                //交易单号
                string transaction_id = resHandler.getParameter("transaction_id");

                //金额金额,以分为单位
                string total_fee = resHandler.getParameter("total_fee");

                //支付结果
                string pay_result = resHandler.getParameter("pay_result");

                //会员ID
                string userid = resHandler.getParameter("attach");

                if ("0".Equals(pay_result))
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //密钥
            string key = TenpayParameters.Key;

            //创建PayResponseHandler实例
            PayResponseHandler resHandler = new PayResponseHandler(Context);

            resHandler.setKey(key);

            //判断签名
            if (resHandler.isTenpaySign())
            {
                //交易单号
                string trade_no = resHandler.getParameter("transaction_id");
                //金额金额,以分为单位
                decimal total_fee = Convert.ToDecimal(resHandler.getParameter("total_fee")) / 100;
                //支付结果
                string pay_result = resHandler.getParameter("pay_result");
                //订单号
                string order_no = resHandler.getParameter("sp_billno");
                //支付账号
                string buyer_email = "";
                EyouSoft.IBLL.TicketStructure.ITicketOrder orderBll = EyouSoft.BLL.TicketStructure.TicketOrder.CreateInstance();
                string sWord = "Notify_URL:trade_no=" + trade_no + "\n total_fee:sign=" + total_fee + "&order_no=" + order_no + "";

                IList <EyouSoft.Model.TicketStructure.TicketPay> payList = orderBll.GetPayList("", EyouSoft.Model.TicketStructure.ItemType.供应商付款到平台_购买运价, order_no, "");
                if ("0".Equals(pay_result))
                {
                    //为了保证不被重复调用,或重复执行数据库更新程序,请判断该笔交易状态是否是订单未处理状态
                    //string order_no="201011080010";
                    //string trade_no="2010110861004313";
                    //string total_fee="0.01";
                    //string buyer_email="*****@*****.**";
                    //string seller_mailer="*****@*****.**";
                    if (payList != null && payList.Count > 0)
                    {
                        if (payList[0].PayState != EyouSoft.Model.TicketStructure.PayState.交易完成)
                        {
                            EyouSoft.BLL.TicketStructure.FreightBuyLog.CreateInstance().PayAfter(trade_no, total_fee, EyouSoft.Model.TicketStructure.PayState.交易完成, EyouSoft.Model.TicketStructure.TicketAccountType.财付通, "", order_no, DateTime.Now, "");
                            //调用doShow, 打印meta值跟js代码,告诉财付通处理成功,并在用户浏览器显示show.aspx页面.

                            // AlipayFunction.log_result(Server.MapPath("../log/运价购买 " + order_no + "-" + DateTime.Now.ToString().Replace(":", "")) + ".txt", sWord + "||支付完成,修改状态完成");
                            resHandler.doShow(string.Format(Domain.UserBackCenter + "/TicketsCenter/tenpay/Show.aspx?logId={0}", payList[0].ItemId));
                        }
                        if (payList[0].PayState != EyouSoft.Model.TicketStructure.PayState.交易完成)
                        {
                            // AlipayFunction.log_result(Server.MapPath("../log/运价购买 " + order_no + "-" + DateTime.Now.ToString().Replace(":", "")) + ".txt", sWord + "||支付完成,修改状态未完成!");
                            resHandler.doShow(string.Format(Domain.UserBackCenter + "/TicketsCenter/tenpay/Show.aspx?logId={0}", payList[0].ItemId));
                        }
                    }
                    else
                    {
                        // AlipayFunction.log_result(Server.MapPath("../log/运价购买 " + order_no + "-" + DateTime.Now.ToString().Replace(":", "")) + ".txt", sWord + "||payList count 为0!");
                        Response.Write("未找到相关订单!");
                        //Response.Write("trade_status=" + Request.QueryString["trade_status"]);
                    }
                }
                else
                {
                    // AlipayFunction.log_result(Server.MapPath("../log/运价购买 " + order_no + "-" + DateTime.Now.ToString().Replace(":", "")) + ".txt", sWord + "||交易失败");
                    Response.Write("交易失败");
                    Response.Write("trade_status=" + Request.QueryString["trade_status"]);
                }
            }

            //获取debug信息,建议把debug信息写入日志,方便定位问题

            else
            {
                Response.Write("认证签名失败");
            }
        }
Ejemplo n.º 6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //密钥
            string key = TenpayParameters.Key;

            //创建PayResponseHandler实例
            PayResponseHandler resHandler = new PayResponseHandler(Context);

            resHandler.setKey(key);

            //判断签名
            if (resHandler.isTenpaySign())
            {
                //交易单号
                string trade_no = resHandler.getParameter("transaction_id");
                //金额金额,以分为单位
                decimal total_fee = decimal.Parse(resHandler.getParameter("total_fee")) / 100;
                //支付结果
                string pay_result = resHandler.getParameter("pay_result");
                //订单号
                string order_no = resHandler.getParameter("sp_billno");
                //支付账号
                string buyer_email = "";


                EyouSoft.IBLL.TicketStructure.ITicketOrder orderBll = EyouSoft.BLL.TicketStructure.TicketOrder.CreateInstance();
                EyouSoft.Model.TicketStructure.OrderInfo   info     = orderBll.GetOrderInfoByNo(order_no);
                if (info.OrderState == EyouSoft.Model.TicketStructure.OrderState.审核通过)
                {
                    IList <EyouSoft.Model.TicketStructure.TicketCompanyAccount> list = EyouSoft.BLL.TicketStructure.TicketCompanyAccount.CreateInstance().GetTicketCompanyAccountList(info.SupplierCId); //获取供应商所有账户
                    string sellAccount = "";                                                                                                                                                             //供应商账户
                    EyouSoft.Model.TicketStructure.TicketCompanyAccount accountModel = list.FirstOrDefault(i => i.InterfaceType == EyouSoft.Model.TicketStructure.TicketAccountType.财付通);                //获取供应商账户实体
                    if (accountModel != null)
                    {
                        sellAccount = accountModel.AccountNumber;//赋值供应商账户
                    }
                    string  batchNo   = "";
                    decimal IntoRatio = decimal.Parse(TenpayParameters.TongyeFee);
                    IList <EyouSoft.Model.TicketStructure.TicketPay> payList = orderBll.GetPayList(info.OrderId, EyouSoft.Model.TicketStructure.ItemType.采购商付款到平台_订单, order_no, null);
                    if ("0".Equals(pay_result))
                    {
                        if (payList != null && payList.Count > 0)
                        {
                            orderBll.PayAfterCallBack(trade_no, total_fee, EyouSoft.Model.TicketStructure.PayState.交易完成, EyouSoft.Model.TicketStructure.TicketAccountType.财付通, buyer_email, "", order_no, DateTime.Now, "");
                        }
                        else
                        {
                            orderBll.PayBefore(info.OrderId, order_no, sellAccount, IntoRatio, info.BuyerUId, info.BuyerCId, total_fee, EyouSoft.Model.TicketStructure.TicketAccountType.支付宝, info.SupplierCId, "", out batchNo);
                            orderBll.PayAfterCallBack(trade_no, total_fee, EyouSoft.Model.TicketStructure.PayState.交易完成, EyouSoft.Model.TicketStructure.TicketAccountType.财付通, buyer_email, "", order_no, DateTime.Now, "");
                        }

                        //调用doShow, 打印meta值跟js代码,告诉财付通处理成功,并在用户浏览器显示show.aspx页面.
                        resHandler.doShow(string.Format("/AirTickets/tenpay/directpay/Show.aspx?order_no={0}&total_fee={1}&result={2}", order_no, total_fee, "1"));
                    }
                    else
                    {
                        //当做不成功处理
                        if (payList != null && payList.Count > 0)
                        {
                            orderBll.PayAfterCallBack(trade_no, total_fee, EyouSoft.Model.TicketStructure.PayState.交易失败, EyouSoft.Model.TicketStructure.TicketAccountType.财付通, buyer_email, "", order_no, DateTime.Now, "");
                        }
                        else
                        {
                            orderBll.PayBefore(info.OrderId, order_no, sellAccount, IntoRatio, info.BuyerUId, info.BuyerCId, total_fee, EyouSoft.Model.TicketStructure.TicketAccountType.支付宝, info.SupplierCId, "", out batchNo);
                            orderBll.PayAfterCallBack(trade_no, total_fee, EyouSoft.Model.TicketStructure.PayState.交易失败, EyouSoft.Model.TicketStructure.TicketAccountType.财付通, buyer_email, "", order_no, DateTime.Now, "");
                        }
                        resHandler.doShow(string.Format("/AirTickets/tenpay/directpay/Show.aspx?order_no={0}&total_fee={1}&result={2}", order_no, total_fee, "0"));
                        //Response.Write("支付失败");
                    }
                }

                //获取debug信息,建议把debug信息写入日志,方便定位问题
                //string debuginfo = resHandler.getDebugInfo();
                //Response.Write("<br/>debuginfo:" + debuginfo + "<br/>");
            }
            else
            {
                Response.Write("认证签名失败");
            }
        }
Ejemplo n.º 7
0
        public ActionResult Success()
        {
            //密钥
            string key = "f24967df0075851d22411c36b04899ac";

            //创建PayResponseHandler实例
            PayResponseHandler resHandler = new PayResponseHandler(System.Web.HttpContext.Current);

            resHandler.setKey(key);

            ViewBag.Money = resHandler.getParameter("total_fee");

            return this.View();
        }
Ejemplo n.º 8
0
        public ActionResult Return()
        {
            LogUtils.Log("接收财付通支付通知消息,订单","财付通支付--支付通知", Category.Info, this.Session.SessionID, this.UserSession.UserID, "Tenpay/Return");

            //密钥
            string key = "f24967df0075851d22411c36b04899ac";

            //创建PayResponseHandler实例
            PayResponseHandler resHandler = new PayResponseHandler(System.Web.HttpContext.Current);

            resHandler.setKey(key);

            string order_code = resHandler.getParameter("sp_billno");

            //判断签名
            if (resHandler.isTenpaySign())
            {
                LogUtils.Log("判断签名合法", "财付通支付--支付通知", Category.Info, this.Session.SessionID, this.UserSession.UserID, "Tenpay/Return");

                //交易单号
                string transaction_id = resHandler.getParameter("transaction_id");

                //支付金额,以分为单位
                string total_fee = resHandler.getParameter("total_fee");

                //支付结果
                string pay_result = resHandler.getParameter("pay_result");

                if (pay_result == "0") //0-已支付,1-未支付,其他为支付错误
                {
                    LogUtils.Log("订单支付成功"+string.Format("订单号:{0},财付通交易号:{1},支付金额:{2}",order_code,transaction_id,total_fee), "财付通支付--支付通知", Category.Info, this.Session.SessionID, this.UserSession.UserID, "Tenpay/Return");
                    //------------------------------
                    //处理业务开始
                    //------------------------------

                    //注意交易单不要重复处理
                    //注意判断返回金额

                    //Common.DataContext ctx = new Common.DataContext();
                    //Model.odr_Order_S os = new Model.odr_Order_S();
                    //os.Action = 14;
                    //os.Number = strNumber;
                    //BLL.Order od = new BLL.Order();
                    //DataTable dt = od.GetOrderInfo(ctx, os);

                    //double totalFee = 0;
                    var orderSevice = new OrderService(this.UserSession.UserID, false);
                    var order = orderSevice.QueryByOrderCode(order_code);

                    //todo:此处应验证订单支付金额是否正确,测试使用1分
                    //if (double.Parse(total_fee) == 1)
                    if (double.Parse(total_fee) == (Math.Round(order.DeliveryCost + order.TotalMoney, 2) * 100))
                    {
                        ViewBag.Message = "财富通--支付成功,"
                                          + string.Format(
                                              "订单号:{0},财付通交易号:{1},支付金额:{2}",
                                              order.OrderCode,
                                              transaction_id,
                                              total_fee);

                        if (order.PaymentStatus != 1)
                        {
                            order.PaymentStatus = 1;
                            order.Status = order.Status == 255 ? 0 : order.Status;
                            //默认5为财富通
                            if (orderSevice.OrderOnLinePayment(order, Math.Round(double.Parse(total_fee)/100,2), 5, transaction_id))
                            {
                                LogUtils.Log(
                                    string.Format(
                                        "订单支付成功,订单状态更新成功,订单号:{0},财付通交易号:{1},支付金额:{2}",
                                        order.OrderCode,
                                        transaction_id,
                                        total_fee),
                                    "财付通支付--支付通知",
                                    Category.Info,
                                    this.Session.SessionID,
                                    this.UserSession.UserID,
                                    "Tenpay/Return");
                            }
                            else
                            {
                                ViewBag.Message = "财富通--支付成功,"
                                                  + string.Format(
                                                      "订单状态更新失败,为了保护您的权益,请立即与客服人员联系。订单号:{0},财付通交易号:{1},支付金额:{2}",
                                                      order.OrderCode,
                                                      transaction_id,
                                                      total_fee);
                                LogUtils.Log(
                                    string.Format(
                                        "订单支付成功,订单状态更新失败,订单号:{0},财付通交易号:{1},支付金额:{2}",
                                        order.OrderCode,
                                        transaction_id,
                                        total_fee),
                                    "财付通支付--支付通知",
                                    Category.Info,
                                    this.Session.SessionID,
                                    this.UserSession.UserID,
                                    "Tenpay/Return");
                            }
                        }
                        ViewBag.Money = total_fee;
                        ViewBag.Url = ConstantParams.SiteUrl + "Tenpay/Success";
                    }
                }
                else
                {
                    LogUtils.Log("订单支付失败(参数指示未支付),"+string.Format("订单号:{0},财付通交易号:{1},支付金额:{2}",order_code,transaction_id,total_fee), "财付通支付--支付通知", Category.Info, this.Session.SessionID, this.UserSession.UserID, "Tenpay/Return");

                    //当做不成功处理
                    ViewBag.Message = "订单支付失败,"
                                      + string.Format(
                                          "订单号:{0},财付通交易号:{1},支付金额:{2}",
                                          order_code,
                                          transaction_id,
                                          total_fee);

                    //Response.Redirect(CONST.Url + "/purchase/PayFinish-Number-" + strNumber + "-Msg-1.htm");
                }

                if (ViewBag.Url == null)
                {
                    ViewBag.Url = ConstantParams.SiteUrl + "Tenpay/Fail";
                }

                return this.View("Return");
            }
            else
            {
                LogUtils.Log("认证签名失败,订单编号:"+order_code, "财付通支付--支付通知", Category.Info, this.Session.SessionID, this.UserSession.UserID, "Tenpay/Return");

                //当做不成功处理
                ViewBag.Message = "订单支付失败," + string.Format("订单号:{0}", order_code);

                return null; //不处理,等待下一次通知
                //Response.Redirect(CONST.Url + "/purchase/PayFinish-Number-" + strNumber + "-Msg-1.htm");
                //string debugInfo = resHandler.getDebugInfo();
                //Response.Write("<br/>debugInfo:" + debugInfo);
            }
        }
Ejemplo n.º 9
0
        public static string QuickTenPaySubmit(HttpContext Context)
        {
            string sRes = string.Empty;

            //创建PayResponseHandler实例
            PayResponseHandler resHandler = new PayResponseHandler(Context);

            resHandler.setKey(key);

            //判断签名
            if (resHandler.isTenpaySign())
            {
                //交易单号
                string transaction_id = resHandler.getParameter("transaction_id");

                //金额金额,以分为单位
                string total_fee = resHandler.getParameter("total_fee");

                //支付结果
                string pay_result = resHandler.getParameter("pay_result");

                string sp_billno = resHandler.getParameter("sp_billno");

                string attach = resHandler.getParameter("attach");
                if ("0".Equals(pay_result))
                {
                    //------------------------------
                    //处理业务开始
                    //------------------------------

                    //注意交易单不要重复处理
                    //注意判断返回金额

                    //------------------------------
                    //处理业务完毕
                    //------------------------------
                    string  sTranID    = string.Format("{0}{1}", sp_billno, attach.Split('|')[0]);
                    decimal dPrice     = decimal.Parse(total_fee) / 100;
                    string  sAccount   = attach.Split('|')[1];
                    string  sGameAbbre = attach.Split('|')[2];

                    string sTranIP  = ProvideCommon.GetRealIP();
                    string sFromUrl = Context.Request.Url.ToString();
                    LastOfPayPointBLL.Add(sTranIP, ' ', sFromUrl, sTranID);

                    int j = TransPBLL.PointSalesCommit(sTranID, sAccount, dPrice);
                    if (0 == j)
                    {
                        string sGTranID = TranQuickBLL.TranQuickGTranIDSel(sTranID);
                        TranQuickBLL.TranQuickUpdateP(sTranID);
                        string sGTRes = string.Empty;
                        if (sGameAbbre.IndexOf("sq") == -1)
                        {
                            sGTRes = PayAll.GameQuickPay(sGameAbbre, sAccount, dPrice, sGTranID);
                        }
                        else
                        {
                            string sRoleID = attach.Split('|')[3];
                            sGTRes = PayAll.sqQuickPay(sGameAbbre, sAccount, dPrice, sGTranID, sRoleID);
                        }

                        string sUrl = string.Empty;
                        if (sGTRes == "0")
                        {
                            TranQuickBLL.TranQuickUpdateG(sGTranID);
                            sUrl = string.Format("PayGSucc.aspx?TranID={0}&gn={1}&type=q", sGTranID, sGameAbbre);
                            //调用doShow, 打印meta值跟js代码,告诉财付通处理成功,并在用户浏览器显示$show页面.
                            resHandler.doShow(sUrl);
                        }
                        sRes = sGTRes;
                    }
                    else if (j == 6)
                    {
                        string sQuickState = TranQuickBLL.TransQuickStateSelByP(sTranID);
                        string sGTranID    = TranQuickBLL.TranQuickGTranIDSel(sTranID);
                        if (sQuickState == "2")
                        {
                            string sUrl = string.Format("PayGSucc.aspx?TranID={0}&gn={1}&type=q", sGTranID, sGameAbbre);
                            //调用doShow, 打印meta值跟js代码,告诉财付通处理成功,并在用户浏览器显示$show页面.
                            resHandler.doShow(sUrl);
                            sRes = "0";
                        }
                        else if (sQuickState == "1")
                        {
                            string sGTRes = string.Empty;
                            if (sGameAbbre.IndexOf("sq") == -1)
                            {
                                sGTRes = PayAll.GameQuickPay(sGameAbbre, sAccount, dPrice, sGTranID);
                            }
                            else
                            {
                                string sRoleID = attach.Split('|')[3];
                                sGTRes = PayAll.sqQuickPay(sGameAbbre, sAccount, dPrice, sGTranID, sRoleID);
                            }

                            if (sGTRes == "0") //游戏兑换成功
                            {
                                TranQuickBLL.TranQuickUpdateG(sGTranID);
                                string sUrl = string.Format("PayGSucc.aspx?TranID={0}&gn={1}&type=q", sGTranID, sGameAbbre);
                                //调用doShow, 打印meta值跟js代码,告诉财付通处理成功,并在用户浏览器显示$show页面.
                                resHandler.doShow(sUrl);
                                sRes = "0";
                            }
                            else
                            {
                                //sMsg = "<script>alert('充值武林币成功!游戏兑换失败!如有问题请与客服联系!');</script>";
                                sRes = "-3";
                            }
                        }
                    }
                    else
                    {
                        sRes = "-4";
                    }
                }
                else
                {
                    //当做不成功处理
                    sRes = "-1";
                }
            }
            else
            {
                sRes = "-2";
            }
            return(sRes);
        }
Ejemplo n.º 10
0
        /// <summary>
        /// 回调方法
        /// </summary>
        /// <returns></returns>
        public ActionResult Tenpay_Return()
        {
            bool   isSuccess  = false;
            string AcitonCate = string.Empty;

            try
            {
                /*
                 * attach=&bargainor_id=1208389301&cmdno=1&date=20120111&fee_type=1&pay_info=OK&pay_result=0&pay_time=1326291710&sign=0925C26EA436BAC80010E7F3F6C9FAE3&sp_billno=2220091839&total_fee=1&transaction_id=1208389301201201112220091839&ver=1
                 */

                PayResponseHandler resHandler = new PayResponseHandler(System.Web.HttpContext.Current);
                SitePayAPI         m_entity   = SitePayAPI.GetModel(t => t.ApiType == "财付通");
                resHandler.setKey(m_entity.AppKey);

                //判断签名
                if (resHandler.isTenpaySign())
                {
                    string orderid   = resHandler.getParameter("attach");
                    string cate      = resHandler.getParameter("desc");
                    string total_fee = resHandler.getParameter("total_fee");
                    SqlTranEx.SqlTranExtensions _STE = new SqlTranEx.SqlTranExtensions();
                    #region 付款成功之后的操作
                    switch (cate)
                    {
                    }
                    #endregion

                    isSuccess = _STE.ExecuteSqlTran();
                }
            }
            catch (Exception ex)
            {
                return(Content("error-4" + ex.Message.ToString()));
            }
            if (isSuccess)
            {
                if (AcitonCate == "充值")
                {
                    return(RedirectToAction("MemberAccountInfo", "MSComm"));
                }
                else if (AcitonCate == "活动付款")
                {
                    return(RedirectToAction("SignUpSuccess", "Home"));
                }
                else if (AcitonCate == "会员卡")
                {
                    return(RedirectToAction("MemberCardLog", "MSComm"));
                }
                return(RedirectToAction("MemberAccountInfo", "MSComm"));
            }
            else
            {
                if (AcitonCate == "充值")
                {
                    return(RedirectToAction("MemberAccountInfo", "MSComm"));
                }
                else if (AcitonCate == "活动付款")
                {
                    return(RedirectToAction("SignUpFailed", "Home", new { msg = "支付失败,请重新核对支付信息后重新支付" }));
                }
                else if (AcitonCate == "会员卡")
                {
                    return(RedirectToAction("MemberCardLog", "MSComm"));
                }
                return(RedirectToAction("SignUpFailed", "Home", new { msg = "支付失败,请重新核对支付信息后重新支付" }));
            }
        }
Ejemplo n.º 11
0
        /// <summary>
        /// 回调地址
        /// </summary>
        /// <returns></returns>
        public ActionResult Tenpay_Return()
        {
            bool isSuccess = false;

            try
            {
                /*
                 * attach=&bargainor_id=1208389301&cmdno=1&date=20120111&fee_type=1&pay_info=OK&pay_result=0&pay_time=1326291710&sign=0925C26EA436BAC80010E7F3F6C9FAE3&sp_billno=2220091839&total_fee=1&transaction_id=1208389301201201112220091839&ver=1
                 */

                PayResponseHandler resHandler = new PayResponseHandler(System.Web.HttpContext.Current);
                SitePayAPI         m_entity   = SitePayAPI.GetModel(t => t.ApiType == "财付通");
                resHandler.setKey(m_entity.AppKey);

                //判断签名
                if (resHandler.isTenpaySign())
                {
                    //交易单号---时间:2012-03-29 21:11 已更新
                    //string transaction_id = resHandler.getParameter("transaction_id");
                    // reqHandler.setParameter("attach", orderid);	//订单ID
                    string orderid = resHandler.getParameter("attach");

                    //金额金额,以分为单位
                    string total_fee = resHandler.getParameter("total_fee");

                    //支付结果
                    string pay_result = resHandler.getParameter("pay_result");

                    if (string.IsNullOrEmpty(orderid))
                    {
                        return(Content("error-7"));
                    }
                    if (!"0".Equals(pay_result))
                    {
                        return(Content("error-8"));
                    }

                    lock (this)
                    {
                        string[] OrderListUID            = orderid.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
                        SqlTranEx.SqlTranExtensions _STE = new SqlTranEx.SqlTranExtensions();
                        //for (int i = 0; i < OrderListUID.Length; i++)
                        //{
                        //    Orders m_now_orders = Orders.GetModel(t => t.O_UID == OrderListUID[i].ToString2());
                        //    if (!m_now_orders.IsNull && m_now_orders.O_IsPay == false)
                        //    {

                        //        #region 更改订单信息

                        //        m_now_orders.O_IsPay = true;
                        //        m_now_orders.O_Status = CommonEnumHelper.OrderStatus.已付款.ToString2();
                        //        m_now_orders.O_PayTime = DateTime.Now;
                        //        m_now_orders.Update(_STE);

                        //        #endregion

                        //        #region 更改商家帐户信息

                        //        MemberAccount m_store_account = MemberAccount.GetModel(t => t.M_UID == m_now_orders.Store_UID);
                        //        if (m_store_account.IsNull)
                        //            return Content("Error");
                        //        else
                        //        {
                        //            m_store_account.M_LockBalance += m_now_orders.O_StoreGetMoney;
                        //            m_store_account.Update(_STE);
                        //        }

                        //        #endregion

                        //        #region 更改会员经验值
                        //        MemberAccount m_member_account = MemberAccount.GetModel(t => t.M_UID == m_now_orders.Member_UID);
                        //        #endregion

                        //        #region 增加会员账户消费记录信息
                        //        MemberAccountLog m_mal = new MemberAccountLog(); //表名:MemberAccountLog 备注:会员账户消费记录
                        //        m_mal.M_UID = m_now_orders.Member_UID;        //M_UID[Type=string] - 会员唯一编号
                        //        m_mal.MA_UID = Common.Globals.CreateNewUniqueID();
                        //        m_mal.M_Cate = CommonEnumHelper.AccountCate.现金.ToString2();        //M_Cate[Type=string] - 分类(积分/现金)
                        //        m_mal.M_PayCate = CommonEnumHelper.AccountLogCate.支出.ToString2();        //M_PayCate[Type=string] - 收入/支出类型
                        //        m_mal.M_ObjectMoney = m_now_orders.O_PayMoney;        //M_ObjectMoney[Type=double?] - 操作金额
                        //        m_mal.M_BalanceMoney = m_member_account.M_AvailableBalance;        //M_BalanceMoney[Type=double?] - 账户余额
                        //        m_mal.M_Remark = "支付订单(订单编号:" + m_now_orders.O_UID + ")";        //M_Remark[Type=string] - 备注
                        //        m_mal.M_Status = "";        //M_Status[Type=string] - 当前状态
                        //        m_mal.M_Time = DateTime.Now;        //M_Time[Type=DateTime?] - 时间
                        //        m_mal.Add(_STE);
                        //        #endregion

                        //        #region 增加商家账户消费记录信息
                        //        MemberAccountLog m_mal_s = new MemberAccountLog(); //表名:MemberAccountLog 备注:会员账户消费记录
                        //        m_mal_s.M_UID = m_now_orders.Store_UID;        //M_UID[Type=string] - 会员唯一编号
                        //        m_mal_s.MA_UID = Common.Globals.CreateNewUniqueID();
                        //        m_mal_s.M_Cate = CommonEnumHelper.AccountCate.现金.ToString2();        //M_Cate[Type=string] - 分类(积分/现金)
                        //        m_mal_s.M_PayCate = CommonEnumHelper.AccountLogCate.收入.ToString2();        //M_PayCate[Type=string] - 收入/支出类型
                        //        m_mal_s.M_ObjectMoney = m_now_orders.O_StoreGetMoney;        //M_ObjectMoney[Type=double?] - 操作金额
                        //        m_mal_s.M_BalanceMoney = m_store_account.M_AvailableBalance;        //M_BalanceMoney[Type=double?] - 账户余额
                        //        m_mal_s.M_Remark = "订单收款(订单编号:" + m_now_orders.O_UID + "),所得金额现为锁定状态,需等买家确认收货/消费后自动解锁";        //M_Remark[Type=string] - 备注
                        //        m_mal_s.M_Status = "";        //M_Status[Type=string] - 当前状态
                        //        m_mal_s.M_Time = DateTime.Now;        //M_Time[Type=DateTime?] - 时间
                        //        m_mal_s.Add(_STE);
                        //        #endregion

                        //        isSuccess = _STE.ExecuteSqlTran();

                        //    }
                        //}
                    }
                }
            }
            catch (Exception ex)
            {
                return(Content(ex.ToString()));
            }
            if (isSuccess)
            {
                return(RedirectToAction("OrderPaySuccess", "Order"));
            }
            else
            {
                return(RedirectToAction("OrderPayFailure", "Order", new { msg = "订单支付失败,请重新核对订单信息及支付信息后重新支付" }));
            }
        }