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); }
//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); } }
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); }
public void Notify() { try { QueryNotifyURL = QueryNotifyURL + "&partner=" + partner + "¬ify_id=" + HttpContext.Current.Request["notify_id"].ToString(); //��ȡ֧����ATN���ؽ����true����ȷ�Ķ�����Ϣ��false ����Ч�� // alipayNotifyURL = alipayNotifyURL + "&partner=" + partner + "¬ify_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"); } }
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); }
/// <summary> /// 链接接收 /// </summary> public void Receive() { 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")) { 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}", "账户余额不足!"); } } else { Utils.Log4Net.Error(string.Format("支付接口直接调用回调方法【失败】,跳转到URL:{0}", payOkUrl)); payErrorUrl = payErrorUrl.Replace("{1}", payrecordinfo.OrderId.ToString()); payErrorUrl = payErrorUrl.Replace("{2}", "订单错误!"); } } } else { payErrorUrl = payErrorUrl.Replace("{1}", payrecordinfo.OrderId.ToString()); payErrorUrl = payErrorUrl.Replace("{2}", "校验失败,数据可疑"); HttpContext.Current.Response.Redirect(payErrorUrl); // HttpContext.Current.Response.Write("校验失败,数据可疑"); } }
/// <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/>"); } }
//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); } }
/// <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("У��ʧ��,���ݿ���"); } }
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); }
public void Notify() { try { QueryNotifyURL = QueryNotifyURL + "&partner=" + partner + "¬ify_id=" + HttpContext.Current.Request["notify_id"].ToString(); //获取支付宝ATN返回结果,true是正确的订单信息,false 是无效的 // alipayNotifyURL = alipayNotifyURL + "&partner=" + partner + "¬ify_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"); } }
/// <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/>"); } }