Esempio n. 1
0
 /// <summary>
 /// 插入数据
 /// </summary>
 /// <param name="obj">对象</param>
 /// <returns>返回:该条数据的主键Id</returns>
 public int Insert(MPayLog obj)
 {
     if (obj == null) throw new ArgumentNullException("obj");
     String stmtId = "MPayLog.Insert";
     return SqlMapper.Instance().QueryForObject<int>(stmtId, obj);
 }
Esempio n. 2
0
        public void Notify()
        {
            try
            {
                QueryNotifyURL = QueryNotifyURL + "&partner=" + partner + "&notify_id=" + HttpContext.Current.Request["notify_id"].ToString();
                //��ȡ֧����ATN���ؽ����true����ȷ�Ķ�����Ϣ��false ����Ч��
                // alipayNotifyURL = alipayNotifyURL + "&partner=" + partner + "&notify_id=" + HttpContext.Current.Request.QueryString["notify_id"];

                //��ȡ֧����ATN���ؽ����true����ȷ�Ķ�����Ϣ��false ����Ч��
                string responseTxt = AliPayPackage.Get_Http(QueryNotifyURL, 120000);

                //*******����ǩ������ʼ//*******
                int i;
                System.Collections.Specialized.NameValueCollection coll;
                //Load Form variables into NameValueCollection variable.
                coll = HttpContext.Current.Request.Form;

                // Get names of all forms into a string array.
                String[] requestarr = coll.AllKeys;

                //��������
                string[] Sortedstr = AliPayPackage.BubbleSort(requestarr);

                //�����md5ժҪ�ַ��� ��

                StringBuilder prestr = new StringBuilder();
               // string temp = "";
                for (i = 0; i < Sortedstr.Length; i++)
                {
                    if (RQ(Sortedstr[i]) != "" && Sortedstr[i] != "sign" && Sortedstr[i] != "sign_type")
                    {
                        if (i == Sortedstr.Length - 1)
                        {
                            prestr.Append(Sortedstr[i] + "=" + RQ(Sortedstr[i]));
                        }
                        else
                        {
                            prestr.Append(Sortedstr[i] + "=" + RQ(Sortedstr[i]) + "&");

                        }
                    }
                   // temp+=Sortedstr[i];
                }
              //  MamShare.Utils.Log4Net.Error(temp);
                prestr.Append(key);

                //����Md5ժҪ��
                string mysign = AliPayPackage.GetMD5(prestr.ToString(), _input_charset);
                //*******����ǩ���������*******

                string sign = RQ("sign");
                //  Response.Write(prestr.ToString());
                string trade_status = RQ("trade_status");
                MPayLog payrecordinfo = new MPayLog();
                payrecordinfo.PayUrl = QueryNotifyURL;//���ص�ַ
                payrecordinfo.OrderId = decimal.Parse(RQ("out_trade_no"));//HttpContext.Current.Request.QueryString["out_trade_no"]);
                if (responseTxt == "true")
                    payrecordinfo.PayResult = "1";
                else
                    payrecordinfo.PayResult = "0";
                payrecordinfo.PayMoney = decimal.Parse(RQ("total_fee")); //decimal.Parse(HttpContext.Current.Request.QueryString["total_fee"]);
                payrecordinfo.TransactionId = RQ("trade_no"); //HttpContext.Current.Request.QueryString["trade_no"];
                payrecordinfo.PayWay = PayWay;
                payrecordinfo.BackUrl = HttpContext.Current.Request.Url.AbsoluteUri;
                payrecordinfo.CreateTime = DateTime.Now;
                TMM.Service.Bll.Order.MPayLogBLL pbll = new TMM.Service.Bll.Order.MPayLogBLL();
                pbll.Insert(payrecordinfo);

                if (responseTxt == "true")   //��֤֧������������Ϣ��ǩ���Ƿ���ȷ
                {

                    //�����Լ����ݿ�Ķ�����䣬���Լ���дһ��
                    if (trade_status == "TRADE_FINISHED" || trade_status == "TRADE_SUCCESS")
                    {
                        Service.Bll.Order.TOrderBLL obll = new TMM.Service.Bll.Order.TOrderBLL();
                        Service.Bll.User.MAccountBLL abll = new TMM.Service.Bll.User.MAccountBLL();
                        TOrder o = obll.GetOrderAndDetail(payrecordinfo.OrderId);
                        if (o.Status >= 0 && o.Status < 10) //�¶��� -- �Ѹ��� ֮��Ĺ���
                        {
                            //��ֵ
                            abll.AddAmount(payrecordinfo.OrderId, payrecordinfo.PayMoney, Utils.TmmUtils.IPAddress(), this.PayWay);
                            bool expandResult = true;
                            //docidС��0 �����Ϊ���ⶩ������ִ���˻������Ķ���
                            if (o.SingleDetail.DocId > 0)
                            {
                                expandResult = abll.AccountExpend(payrecordinfo.OrderId, Utils.TmmUtils.IPAddress());
                            }

                            if (expandResult)
                            {
                                Common.OrderCallBack oCallBack = new TMM.Core.Common.OrderCallBack();
                                oCallBack.UserId = o.UserId;
                                oCallBack.OrderId = o.OrderId;
                                oCallBack.PayWay = PayWay;
                                oCallBack.Status = (int)OrderStatus.IsPaied;
                                oCallBack.PayDetail = "�Ա�֧��";

                                oCallBack.ExecAfterPaid();
                                Utils.Log4Net.Error(string.Format("֧�����ӿ��첽���ûص������ɹ�����ת��URL��{0}", payOkUrl));

                            }
                            else
                            {
                                payErrorUrl = payErrorUrl.Replace("{1}", payrecordinfo.OrderId.ToString());
                                payErrorUrl = payErrorUrl.Replace("{2}", "�˻����㣡");

                            }
                        }
                    }
                    HttpContext.Current.Response.Write("success");
                    // Response.Write("success");     //���ظ�֧������Ϣ���ɹ�

                }
                else
                {
                    //HttpContext.Current.Response.Write("------------------------------------------");
                    //HttpContext.Current.Response.Write("<br>Result:responseTxt=" + responseTxt);
                    //HttpContext.Current.Response.Write("<br>Result:mysign=" + mysign);
                    //HttpContext.Current.Response.Write("<br>Result:sign=" + sign);
                    //HttpContext.Current.Response.Write("fail");
                    payErrorUrl = payErrorUrl.Replace("{1}", payrecordinfo.OrderId.ToString());
                    payErrorUrl = payErrorUrl.Replace("{2}", "У��ʧ��,֧��ʧ��" + responseTxt);
                    HttpContext.Current.Response.Write("fail");
                    //  HttpContext.Current.Response.Redirect(payErrorUrl);
                }
            }
            catch(Exception e)
            {
                Utils.Log4Net.Error(e);
                HttpContext.Current.Response.Write("fail");
            }
        }
Esempio n. 3
0
 /// <summary>
 /// 更新数据
 /// </summary>
 /// <param name="obj"></param>
 /// <returns>返回:ture 成功,false 失败</returns>
 public bool Update(MPayLog obj)
 {
     if (obj == null) throw new ArgumentNullException("obj");
     String stmtId = "MPayLog.Update";
     int result = SqlMapper.Instance().QueryForObject<int>(stmtId, obj);
     return result > 0 ? true : false;
 }
Esempio n. 4
0
        /// <summary>
        /// ����֧���ɹ�����
        /// </summary>
        public void Receive()
        {
            string suchtml = "<meta content=\"China TENCENT\" name=\"TENCENT_ONLINE_PAYMENT\">\n"
                    + "<script language=\"javascript\">\n"
                    + "window.location.href='" + payOkUrl + "';\n"
                    + "</script>";

            string errmsg = "";

            //string key = "tenpaytesttenpaytesttenpaytest12";
            // string bargainor_id = "1202437801";

            Md5Pay md5pay = new Md5Pay();

            //md5pay.Key = key;
            //md5pay.Bargainor_id = bargainorId;

            //�ж�ǩ��
            if (md5pay.GetPayValueFromUrl(HttpContext.Current.Request.QueryString, out errmsg))
            {
                Decimal orderid = 0;
                orderid = Decimal.Parse(md5pay.Sp_billno);
                MPayLog payrecordinfo = new MPayLog();

                payrecordinfo.PayUrl = HttpContext.Current.Request.UrlReferrer+"";
                payrecordinfo.OrderId = orderid;
                payrecordinfo.PayResult = md5pay.Pay_Result.ToString();
                payrecordinfo.PayMoney = decimal.Parse(md5pay.Total_fee.ToString())/100;
                payrecordinfo.PayWay = PayWay;
                payrecordinfo.TransactionId = md5pay.Transaction_id;
                payrecordinfo.BackUrl = HttpContext.Current.Request.Url.AbsoluteUri;
                payrecordinfo.CreateTime = DateTime.Now;
                TMM.Service.Bll.Order.MPayLogBLL pbll = new TMM.Service.Bll.Order.MPayLogBLL();
                pbll.Insert(payrecordinfo);
                //��֤ǩ���ɹ�
                //֧���ж�
                if (md5pay.Pay_Result == Md5Pay.PAYOK)
                {
                    Service.Bll.Order.TOrderBLL obll = new TMM.Service.Bll.Order.TOrderBLL();
                    Service.Bll.User.MAccountBLL abll = new TMM.Service.Bll.User.MAccountBLL();
                    TOrder o = obll.GetOrderAndDetail(payrecordinfo.OrderId);
                    if (o.Status >= 0 && o.Status < 10) //�¶��� -- �Ѹ��� ֮��Ĺ���
                    {
                        //��ֵ
                        abll.AddAmount(payrecordinfo.OrderId, payrecordinfo.PayMoney, Utils.TmmUtils.IPAddress(),this.PayWay);

                        bool expandResult = true;
                        //docidС��0 �����Ϊ���ⶩ������ִ���˻������Ķ���
                        if (o.SingleDetail.DocId > 0)
                        {
                            expandResult = abll.AccountExpend(payrecordinfo.OrderId, Utils.TmmUtils.IPAddress());
                        }
                        //�������ûص��ӿ�
                        if (expandResult)
                        {
                            #region �����ص��ӿ�
                            //obll.UpdateOrder2Paid(payrecordinfo.OrderId, PayWay, "�Ƹ�֧ͨ��", (int)Models.MOrderStateInfo.������);
                            Common.OrderCallBack oCallBack = new TMM.Core.Common.OrderCallBack();
                            oCallBack.UserId = o.UserId;
                            oCallBack.OrderId = o.OrderId;
                            oCallBack.PayWay = PayWay;
                            oCallBack.Status = (int)OrderStatus.IsPaied;
                            oCallBack.PayDetail = "�Ƹ�֧ͨ��";

                            oCallBack.ExecAfterPaid();
                            suchtml = suchtml.Replace("{1}", orderid.ToString());
                            //֧���ɹ���ͬ������md5pay.Transaction_id���ܻ���֪ͨ�������ע���ж϶����Ƿ��ظ����߼�
                            //����ҵ���߼�������db֮���
                            //errmsg = "֧���ɹ�";
                            //Response.Write(errmsg+"<br/>");
                            //Response.Write("�Ƹ�ͨ������:"+ md5pay.Transaction_id +"(���μǶ�����)"+"<br/>");
                            //��ת���ɹ�ҳ�棬�Ƹ�ͨ�յ�<meta content=\"China TENCENT\" name=\"TENCENT_ONLINE_PAYMENT\">����Ϊ֪ͨ�ɹ�
                            payOkUrl = payOkUrl.Replace("{1}", payrecordinfo.OrderId.ToString());
                            Utils.Log4Net.Error(string.Format("���Ƹ�ͨ��-��ͬ���ص���-���ɹ���-��{0}��", payOkUrl));
                            HttpContext.Current.Response.Write(suchtml);
                            #endregion

                        }
                        else
                        {
                            Utils.Log4Net.Error(string.Format("���Ƹ�ͨ��-��ͬ���ص���-��ʧ��AccountExpend��-��{0}��", payOkUrl));
                            payErrorUrl = payErrorUrl.Replace("{1}", payrecordinfo.OrderId.ToString());
                            payErrorUrl = payErrorUrl.Replace("{2}", "�˻����㣡");
                        }
                    }
                    else
                    {
                        Utils.Log4Net.Error(string.Format("���Ƹ�ͨ��-��ͬ���ص���-��ʧ�ܡ�-��{0}��������״̬{1}��", payOkUrl,o.Status));
                        payErrorUrl = payErrorUrl.Replace("{1}", payrecordinfo.OrderId.ToString());
                        payErrorUrl = payErrorUrl.Replace("{2}", "��������");
                    }
                }
                else
                {
                    //֧��ʧ�ܣ��벻Ҫ���ɹ�����
                    //  Response.Write(md5pay.Pay_Result+"  "+Md5Pay.PAYOK);
                    payErrorUrl = payErrorUrl.Replace("{1}", md5pay.Sp_billno);
                    payErrorUrl = payErrorUrl.Replace("{2}", "֧��ʧ��" + errmsg);
                    HttpContext.Current.Response.Redirect(payErrorUrl);
                    //HttpContext.Current.Response.Write("֧��ʧ��" + errmsg + "<br/>");
                }

            }
            else
            {
                //��֤ǩ��ʧ��
                payErrorUrl = payErrorUrl.Replace("{1}", md5pay.Sp_billno);
                payErrorUrl = payErrorUrl.Replace("{2}", "��֤ǩ��ʧ��");
                HttpContext.Current.Response.Redirect(payErrorUrl);
               // errmsg = "��֤ǩ��ʧ��";
               // HttpContext.Current.Response.Write("��֤ǩ��ʧ��" + "<br/>");
            }
        }
Esempio n. 5
0
        public void Send(string orderNo, string total, string remark,int userId)
        {
            //ҵ�������ֵ��
            string gateway = payUrl;	//'֧���ӿ�
            string subject = remark;	//subject		��Ʒ����
            string body = remark;		//body			��Ʒ����
            string price = total;
            string quantity = "1";
            string show_url = productUrl;
            string seller_email = alipayAccount;             //����˺�
            string return_url = returnUrl; //������֪ͨ���ؽӿ�
            string notify_url = NotifyUrl; //������֪ͨ���ؽӿ�
            string logistics_type = "EMS";//���﷢�ͷ�ʽ
            string logistics_fee = "0";//���˷���
            string logistics_payment = "BUYER_PAY";//֧����
            string[] para ={
            "service="+service,
            "partner=" + partner,
            "seller_email=" + seller_email,
            "out_trade_no=" + orderNo,
            "subject=" + subject,
            "body=" + body,
            "total_fee=" + total,
            "show_url=" + show_url,
            "payment_type=1",
            "notify_url=" + notify_url,
            "return_url=" + return_url,
            "_input_charset="+_input_charset
            };
            //֧��URL����
            string aliay_url = AliPayPackage.CreatUrl(
                gateway,//GET��ʽ���ݲ���ʱ��ȥ��ע��
                para,
                _input_charset,
                sign_type,
                key
                );
            //����֧����¼
            MPayLog payrecordinfo = new MPayLog();
            //Models.MPayLogInfo payrecordinfo = new Models.MPayLogInfo();
            payrecordinfo.PayUrl = aliay_url;
            payrecordinfo.UserId = userId;
            payrecordinfo.OrderId = decimal.Parse(orderNo);
            payrecordinfo.PayMoney = decimal.Parse(total);
            payrecordinfo.TransactionId = orderNo;
            payrecordinfo.PayResult = "100";
            payrecordinfo.PayWay = PayWay;
            payrecordinfo.BackUrl = PayReturnUrl;
            payrecordinfo.CreateTime = DateTime.Now;

            TMM.Service.Bll.Order.MPayLogBLL pbll = new TMM.Service.Bll.Order.MPayLogBLL();
            pbll.Insert(payrecordinfo);

            //TMM.Core.Utils.Log4Net.Error(aliay_url);

            HttpContext.Current.Response.Redirect(aliay_url);
        }
Esempio n. 6
0
        //public TenPay()
        //{
        //    string domain = HttpContext.Current.Request.Url.Host;
        //    returnUrl = returnUrl.Replace("{0}", domain).Replace("{1}", chargeType.ToString());
        //    payOkUrl = payOkUrl.Replace("{0}", domain);
        //    payErrorUrl = payErrorUrl.Replace("{0}", domain);
        //}
        /// <summary>
        /// ����֧������
        /// </summary>
        /// <param name="orderno"></param>
        /// <param name="total"></param>
        /// <param name="remark"></param>
        public void Send(string orderno, string total, string remark)
        {
            Md5Pay p = new Md5Pay();
            p.Paygateurl = payUrl;
            p.Desc = remark;

            p.Total_fee = (long)(decimal.Parse(total)*100);
            p.Sp_billno = orderno;
            p.Attach = "1";
            p.Return_url = returnUrl;
            p.Transaction_id = p.Bargainor_id + p.Date + p.UnixStamp();
            p.Spbill_create_ip =HttpContext.Current.Request.UserHostAddress;
            string url = "";

            if (!p.GetPayUrl(out url))
            {
                HttpContext.Current.Response.Write("TenPay Error");
                //labErrmsg.Text = Server.HtmlEncode(url);
            }
            else
            {
                /*��������԰�
                 * ���׵���			md5pay.Transaction_id
                 * �̻�������		md5pay.Sp_billno
                 * �������			md5pay.Total_fee
                 * ����Ϣ�������ݿ�.
                 * */

                MPayLog payrecordinfo = new MPayLog();
                payrecordinfo.PayUrl = url;
                payrecordinfo.OrderId = decimal.Parse(orderno);
                payrecordinfo.PayMoney = decimal.Parse(total);
                payrecordinfo.UserId = this.UserId;
                payrecordinfo.PayResult = "100";
                payrecordinfo.PayWay = PayWay;
                payrecordinfo.TransactionId = p.Transaction_id;
                payrecordinfo.BackUrl = p.Return_url;
                payrecordinfo.CreateTime = DateTime.Now;

                TMM.Service.Bll.Order.MPayLogBLL pbll = new TMM.Service.Bll.Order.MPayLogBLL();
                pbll.Insert(payrecordinfo);

                HttpContext.Current.Response.Redirect(url);
            }
        }
Esempio n. 7
0
        /// <summary>
        /// �첽֪ͨ
        /// </summary>
        public void Notify()
        {
            v_oid = HttpContext.Current.Request["v_oid"];
            v_pstatus = HttpContext.Current.Request["v_pstatus"];
            v_pstring = HttpContext.Current.Request["v_pstring"];
            v_pmode = HttpContext.Current.Request["v_pmode"];
            v_md5str = HttpContext.Current.Request["v_md5str"];
            v_amount = HttpContext.Current.Request["v_amount"];
            v_moneytype = HttpContext.Current.Request["v_moneytype"];
            remark1 = HttpContext.Current.Request["remark1"];
            remark2 = HttpContext.Current.Request["remark2"];

            string str = v_oid + v_pstatus + v_amount + v_moneytype + key;

            str = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(str, "md5").ToUpper();

            MPayLog payrecordinfo = new MPayLog();
            payrecordinfo.PayUrl = HttpContext.Current.Request.UrlReferrer + "";
            payrecordinfo.OrderId = decimal.Parse(v_oid);
            payrecordinfo.PayResult = v_pstatus;
            payrecordinfo.PayMoney = decimal.Parse(v_amount);
            payrecordinfo.TransactionId = v_oid.ToString();
            payrecordinfo.PayWay = PayWay;
            payrecordinfo.BackUrl = HttpContext.Current.Request.Url.ToString();

            TMM.Service.Bll.Order.MPayLogBLL pbll = new TMM.Service.Bll.Order.MPayLogBLL();
            pbll.Insert(payrecordinfo);
            if (str == v_md5str)
            {

                if (v_pstatus.Equals("20"))
                {
                    string domain = HttpContext.Current.Request.Url.Host;
                    //ȷ����m6go�µĶ���
                    if (remark2.ToLower().Contains(domain.ToLower()) == true)
                    {
                        Service.Bll.Order.TOrderBLL obll = new TMM.Service.Bll.Order.TOrderBLL();
                        Service.Bll.User.MAccountBLL abll = new TMM.Service.Bll.User.MAccountBLL();
                        TOrder o = obll.Get(payrecordinfo.OrderId);
                        if (o.Status >= 0 && o.Status < 10) //�¶��� -- �Ѹ��� ֮��Ĺ���
                        {
                            abll.AddAmount(payrecordinfo.OrderId, payrecordinfo.PayMoney,Utils.TmmUtils.IPAddress(),this.PayWay);
                            if (abll.AccountExpend(payrecordinfo.OrderId,Utils.TmmUtils.IPAddress()))
                            {

                                //Web.Common.OrderCallBack oCallBack = new MamShare.Mall.Web.Common.OrderCallBack(
                                //    o.UserId, o.OrderId, PayWay, (int)Models.MOrderStateInfo.������, "ChinaBank֧��");
                                //oCallBack.Update2Paid();
                                //payOkUrl = payOkUrl.Replace("{1}", payrecordinfo.OrderId.ToString());
                                //HttpContext.Current.Response.Redirect(payOkUrl);
                                Common.OrderCallBack oCallBack = new TMM.Core.Common.OrderCallBack();
                                oCallBack.UserId = o.UserId;
                                oCallBack.OrderId = o.OrderId;
                                oCallBack.PayWay = PayWay;
                                oCallBack.Status = (int)OrderStatus.IsPaied;
                                oCallBack.PayDetail = "ChinaBank֧��";

                                oCallBack.ExecAfterPaid();
                            }
                            else
                            {
                                payErrorUrl = payErrorUrl.Replace("{1}", payrecordinfo.OrderId.ToString());
                                payErrorUrl = payErrorUrl.Replace("{2}", "�˻����㣡");
                                HttpContext.Current.Response.Redirect(payErrorUrl);
                            }
                        }
                    }
                    HttpContext.Current.Response.Write("ok");
                }
                else
                    HttpContext.Current.Response.Write("error");
            }
            else
            {
                payErrorUrl = payErrorUrl.Replace("{1}", payrecordinfo.OrderId.ToString());
                payErrorUrl = payErrorUrl.Replace("{2}", "У��ʧ��,���ݿ���");
                HttpContext.Current.Response.Write("error");
                // HttpContext.Current.Response.Redirect(payErrorUrl);
                //  HttpContext.Current.Response.Write("У��ʧ��,���ݿ���");
            }
        }
Esempio n. 8
0
        public void Send(string orderNo, string total, string remark)
        {
            v_oid = orderNo;
            if (v_oid == null || v_oid.Equals(""))
            {
                return;
            }
            v_amount = total;
            string text = v_amount + v_moneytype + v_oid + v_mid + v_url + key; // ƴ�ռ��ܴ�
            v_md5info = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(text, "md5").ToUpper();
            v_remark1 = remark;
            string para = "";
            para += "v_mid=" + v_mid;
            para += "&v_url=" + v_url;
            para += "&v_oid=" + v_oid;
            para += "&v_amount=" + v_amount;
            para += "&v_moneytype=" + v_moneytype;
            para += "&v_md5info=" + v_md5info;
            para += "&v_remark1=" + v_remark1;
            para += "&remark2=" + remark2;
            payUrl += "?" + para;

            MPayLog payrecordinfo = new MPayLog();
            payrecordinfo.PayUrl = payUrl;
            payrecordinfo.OrderId = decimal.Parse(orderNo);
            payrecordinfo.PayMoney = decimal.Parse(v_amount);
            payrecordinfo.TransactionId = orderNo;
            payrecordinfo.PayResult = "100";
            payrecordinfo.PayWay = PayWay;
            payrecordinfo.BackUrl = BackUrl;

            TMM.Service.Bll.Order.MPayLogBLL pbll = new TMM.Service.Bll.Order.MPayLogBLL();
            pbll.Insert(payrecordinfo);

            HttpContext.Current.Response.Redirect(payUrl);
        }
Esempio n. 9
0
 /// <summary>
 /// 更新数据
 /// </summary>
 /// <param name="obj"></param>
 /// <returns>返回:ture 成功,false 失败</returns>
 public bool Update(MPayLog obj)
 {
     return dal.Update(obj);
 }
Esempio n. 10
0
 /// <summary>
 /// 插入数据
 /// </summary>
 /// <param name="obj">对象</param>
 /// <returns>返回:该条数据的主键Id</returns>
 public int Insert(MPayLog obj)
 {
     return dal.Insert(obj);
 }