protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (Request["KeyId"] != null) { int payid = Convert.ToInt32(Common.DesDecrypt(Request["KeyId"].ToString(), Common.EncryptKey)); Hi.Model.PAY_Payment payment = payservice.GetModel(payid); if (payment != null) { //订单编号 Hi.Model.DIS_Order order = new Hi.BLL.DIS_Order().GetModel(payment.OrderID); if (payment.vdef4 != null) { lblNo.Text = payment.guid.Trim(); } lblPayDate.Text = Convert.ToDateTime(payment.PayDate).ToString("yyyy-MM-dd HH:mm"); //付款方 Hi.Model.BD_Distributor dis = new Hi.BLL.BD_Distributor().GetModel(payment.DisID); lblDisName.Text = payment.PayUser; //收款方 Hi.Model.BD_Company comp = new Hi.BLL.BD_Company().GetModel(order.CompID); lblCompName.Text = comp.CompName; List <Hi.Model.PAY_PaymentBank> LBank = new Hi.BLL.PAY_PaymentBank().GetList(" top 1 accountName,bankCode ", " CompID=" + dis.CompID + " and dr=0 ", " Isno desc "); if (LBank.Count > 0) { Hi.Model.PAY_PaymentBank bank = LBank[0]; lblBank2.Text = "(" + bank.AccountName + " " + bank.bankcode + ")"; } //资金 lblPayPrice.Text = Convert.ToDecimal(payment.PayPrice).ToString("N"); lblPayPriceDX.Text = CmycurD(payment.PayPrice); if (!string.IsNullOrEmpty(payment.vdef5)) { lblSXFPrice.Text = Convert.ToDecimal(payment.vdef5).ToString("N"); } lblOrderNo.Text = order.ReceiptNo; } } } }
/// <summary> /// 返回成功信息 /// </summary> /// <param name="type">1,订单支付 2 ,账单支付 3,充值</param> /// <returns></returns> public string GetMessage(int type) { switch (type) { case 1: str = "付款成功,已支付"; url = " 您可以<a href='../newOrder/orderdetail.aspx?KeyID=" + Common.DesEncrypt(KeyID.ToString(), Common.EncryptKey) + "'>查看订单详情</a><a href='../OrderList.aspx'>返回订单管理</a>"; lastmesage = "<a href='../newOrder/orderdetail.aspx?KeyID=" + Common.DesEncrypt(KeyID.ToString(), Common.EncryptKey) + "' id='lblmessage'>5</a>"; break; case 2: str = "付款成功,已支付"; url = " 您可以<a href='../OrderZDInfo.aspx?KeyID=" + Common.DesEncrypt(KeyID.ToString(), Common.EncryptKey) + "'>查看账单详情</a><a href='orderZDList.aspx'>返回我的账单</a>"; lastmesage = " <a href='../OrderZDInfo.aspx?KeyID=" + Common.DesEncrypt(KeyID.ToString(), Common.EncryptKey) + "' id='lblmessage'>5</a>"; break; case 3: str = "交易成功,已支付"; Hi.Model.PAY_Payment payM = new Hi.Model.PAY_Payment(); List <Hi.Model.PAY_Payment> payMList = new Hi.BLL.PAY_Payment().GetList("", "orderid=" + KeyID, ""); if (payMList.Count > 0) { payM = payMList[0]; } this.PayedAmount.InnerHtml = payM.PayPrice.ToString("0.00"); url = "可以点击回到<a href='PrePayList.aspx'>企业钱包查询</a>"; lastmesage = "<a href='PrePayList.aspx' id='lblmessage'>5</a>"; break; default: str = "付款失败!"; url = ""; break; } return(str); }
///<summary> ///获取钱包充值流水号 ///</summary> public List <string> Getpayidyfk(int UserID, int CompID, int DisID, string price) { int prepayid = 0; int payid = 0; int regid = 0; List <string> list = new List <string>(); Hi.Model.PAY_PrePayment Prepay = new Hi.Model.PAY_PrePayment(); Hi.BLL.PAY_PrePayment bll_prepay = new Hi.BLL.PAY_PrePayment(); Hi.BLL.PAY_Payment bll_pay = new Hi.BLL.PAY_Payment(); Hi.BLL.PAY_RegisterLog bll_reg = new Hi.BLL.PAY_RegisterLog(); Hi.Model.BD_Distributor dis = new Hi.BLL.BD_Distributor().GetModel(DisID); try { //在表PAY_PrePayment中生成一条数据 Prepay.CompID = CompID; Prepay.DisID = DisID; Prepay.OrderID = 0; Prepay.Start = 2; Prepay.PreType = 1; Prepay.price = Convert.ToDecimal(price); Prepay.Paytime = DateTime.Now; Prepay.CreatDate = DateTime.Now; Prepay.OldId = 0; Prepay.CrateUser = UserID; Prepay.AuditState = 2; Prepay.AuditUser = 0; Prepay.IsEnabled = 1; Prepay.ts = DateTime.Now; Prepay.modifyuser = UserID; prepayid = bll_prepay.Add(Prepay); if (prepayid > 0) { //如果pay_prepayment表中插入数据成功的话,在pay_payment表中插入一条数据 int keyID = prepayid; Hi.Model.PAY_PrePayment Prepay_M = bll_prepay.GetModel(prepayid); string guid = Guid.NewGuid().ToString().Replace("-", ""); Hi.Model.PAY_Payment pay = new Hi.Model.PAY_Payment(); pay.OrderID = keyID; pay.DisID = DisID; pay.PayUser = dis.DisName; pay.PayPrice = Convert.ToDecimal(price); pay.guid = Common.Number_repeat(guid); pay.IsAudit = 2; pay.vdef3 = "2"; pay.CreateDate = DateTime.Now; pay.CreateUserID = UserID; pay.ts = DateTime.Now; pay.modifyuser = UserID; pay.Channel = "6"; payid = bll_pay.Add(pay); //如果pay_prepayment表中插入数据成功的话,在PAY_RegisterLog表中插入一条数据 Hi.Model.PAY_RegisterLog reg = new Hi.Model.PAY_RegisterLog(); reg.OrderId = keyID; reg.Ordercode = WebConfigurationManager.AppSettings["OrgCode"] + Convert.ToString(keyID); reg.number = pay.guid; reg.Price = Convert.ToDecimal(price); reg.Payuse = "企业钱包充值"; reg.PayName = dis.DisName; reg.DisID = DisID; reg.PayTime = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"); reg.BankID = "支付宝"; reg.CreateUser = UserID; reg.CreateDate = DateTime.Now; reg.LogType = 1375; regid = bll_reg.Add(reg); if (payid > 0 && regid > 0) { //返回的list第一行放支付流水号,第二行放企业订单号(支付时生成) list.Add(ClsSystem.gnvl(pay.guid, "")); list.Add(ClsSystem.gnvl(reg.Ordercode, "")); return(list); } } } catch { } return(null); }
/// <summary> /// 企业钱包充值 /// </summary> /// <param name="rechengID">充值记录Id</param> public Wxpay_Url PayRechang(int rechengID) { //企业钱包充值记录 Hi.Model.PAY_PrePayment prepayM = new Hi.BLL.PAY_PrePayment().GetModel(rechengID); decimal price = prepayM.price; #region 界面上显示 txtPayOrder = price; this.lblOrderNO.InnerText = prepayM.guid.ToString(); this.fee.InnerText = this.CompName;//收款方 // this.lblOrderNO.HRef = "../neworder/orderdetail.aspx?KeyID=" + Common.DesEncrypt(orderid.ToString(), Common.EncryptKey); #endregion 界面上显示 #region 支付记录 int payid = 0; int regid = 0; string guid = Guid.NewGuid().ToString().Replace("-", ""); Hi.Model.PAY_Payment payModel = new Hi.Model.PAY_Payment(); payModel.OrderID = rechengID; payModel.DisID = this.DisID; payModel.PayUser = new Hi.BLL.BD_Distributor().GetModel(this.DisID).DisName; payModel.PayPrice = price; payModel.guid = Common.Number_repeat(guid); payModel.IsAudit = 2; payModel.vdef3 = "2"; payModel.CreateDate = DateTime.Now; payModel.CreateUserID = this.UserID; payModel.ts = DateTime.Now; payModel.modifyuser = this.UserID; payModel.PrintNum = 1; payModel.Channel = "7"; //1,快捷支付,2,银联支付 ,3,网银支付,4,B2B网银支付,5,线下支付,6,支付宝支付 7,微信支付 payModel.State = 0; //手续费收取方 payModel.vdef5 = "0.00"; //支付手续费 payid = new Hi.BLL.PAY_Payment().Add(payModel); Hi.Model.PAY_RegisterLog regModel = new Hi.Model.PAY_RegisterLog(); regModel.OrderId = rechengID; regModel.Ordercode = WebConfigurationManager.AppSettings["OrgCode"] + Convert.ToString(rechengID); regModel.number = payModel.guid; regModel.Price = price; regModel.Payuse = prepayM.PreType == 6 ? "转账汇款" : prepayM.PreType == 1 ? "企业钱包充值" : ""; regModel.PayName = new Hi.BLL.BD_Distributor().GetModel(this.DisID).DisName; regModel.DisID = this.DisID; regModel.PayTime = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"); regModel.Remark = prepayM.vdef1; regModel.DisName = new Hi.BLL.BD_Company().GetModel(this.CompID).CompName; regModel.BankID = "支付宝"; regModel.CreateUser = this.UserID; regModel.CreateDate = DateTime.Now; regModel.LogType = 1375; regid = new Hi.BLL.PAY_RegisterLog().Add(regModel); if (payid <= 0 || regid <= 0) { //JScript.AlertMsg(this, "数据异常!"); ErrMessage("数据异常", rechengID.ToString()); } GoodsName = "钱包充值"; #endregion int amount = Convert.ToInt32(price * 100);//支付金额(单位:分) //隐藏域赋值 this.hidguid.Value = payModel.guid; this.hidprice.Value = price.ToString(); this.hidordid.Value = payModel.OrderID.ToString(); this.hidpid.Value = payid.ToString(); this.hidppid.Value = "recharge";// prepayid.ToString(); Wxpay_Url wxpaymodel = new Wxpay_Url(); wxpaymodel.Guid = payModel.guid; wxpaymodel.OrderID = orderid.ToString(); wxpaymodel.Amount = amount; wxpaymodel.Hidguid = payModel.guid; wxpaymodel.Hidprice = price.ToString(); wxpaymodel.Hidordid = payModel.OrderID.ToString(); wxpaymodel.Hidpid = payid.ToString(); wxpaymodel.Hidppid = "recharge"; return(wxpaymodel); //btnWxPay_Click(payModel.guid, orderid.ToString(), amount); }
/// <summary> /// 订单支付 /// </summary> /// <param name="orderid">订单ID</param> /// <param name="txtPayOrder">支付金额</param> /// <param name="price">企业钱包金额</param> /// <param name="yfk">预付款</param> /// <param name="payPas"></param> public Wxpay_Url PayOrder(int orderid, decimal txtPayOrder, decimal price, int yfk, string payPas) { //使用企业钱包 OrderModel = new Hi.BLL.DIS_Order().GetModel(orderid); disModel = new Hi.BLL.BD_Distributor().GetModel(OrderModel.DisID); #region 界面上显示 this.lblOrderNO.InnerText = OrderModel.ReceiptNo.Trim().ToString(); this.fee.InnerText = this.CompName;//收款方 // this.lblOrderNO.HRef = "../neworder/orderdetail.aspx?KeyID=" + Common.DesEncrypt(orderid.ToString(), Common.EncryptKey); #endregion 界面上显示 #region 企业钱包支付 begin if (disModel == null) { ErrMessage("数据异常,代理商有误", orderid.ToString()); } decimal sumPrice = new Hi.BLL.PAY_PrePayment().sums(disModel.ID, disModel.CompID); //剩余企业钱包 int disid = OrderModel.DisID; //代理商ID string password = disModel.Paypwd; if (yfk == 1) { if (payPas == null || payPas.Trim().ToString() == "") { ErrMessage("企业钱包密码不能为空", orderid.ToString()); } payPas = payPas.Trim().ToString(); if (password == Util.md5("123456")) { ErrMessage("请先修改企业钱包支付密码", orderid.ToString()); } else { if (payPas == "") { ErrMessage("密码不能为空", orderid.ToString()); } } } decimal payPrice = 0;//支付金额 if (txtPayOrder == 0) { ErrMessage("支付金额不能为0", orderid.ToString()); } if (yfk == 1 && txtPayOrder < price) { ErrMessage("使用企业钱包大于支付金额!", orderid.ToString()); } if (yfk == 1) { payPrice = txtPayOrder - price; } else { payPrice = txtPayOrder; } if (txtPayOrder > OrderModel.AuditAmount + OrderModel.OtherAmount - OrderModel.PayedAmount) { ErrMessage("支付金额大于未支付金额,不能支付!", orderid.ToString()); } if (!(( (OrderModel.Otype == (int)Enums.OType.赊销订单 && (OrderModel.OState != (int)Enums.OrderState.退回 && OrderModel.OState != (int)Enums.OrderState.未提交 && OrderModel.OState != (int)Enums.OrderState.待审核) && (OrderModel.PayState == (int)Enums.PayState.未支付 || OrderModel.PayState == (int)Enums.PayState.部分支付)) || (OrderModel.Otype != (int)Enums.OType.赊销订单 && OrderModel.Otype != (int)Enums.OType.推送账单 && (OrderModel.OState == (int)Enums.OrderState.已审 || OrderModel.OState == (int)Enums.OrderState.已发货 || OrderModel.OState == (int)Enums.OrderState.已到货) && (OrderModel.PayState == (int)Enums.PayState.未支付 || OrderModel.PayState == (int)Enums.PayState.部分支付)) || (OrderModel.Otype == (int)Enums.OType.推送账单 && OrderModel.OState == (int)Enums.OrderState.已审 && (OrderModel.PayState == (int)Enums.PayState.部分支付 || OrderModel.PayState == (int)Enums.PayState.未支付)) ) && OrderModel.OState != (int)Enums.OrderState.已作废)) { if (OrderModel.Otype == (int)Enums.OType.推送账单) { ErrMessage("账单异常,不能支付", orderid.ToString()); } else { ErrMessage("订单异常,不能支付", orderid.ToString()); } } if (yfk == 1 && price > 0) { //企业钱包处理 if (sumPrice < price) { ErrMessage("企业钱包余额不足", orderid.ToString()); } if (disModel.Paypwd != Util.md5(payPas)) { ErrMessage("支付密码不正确", orderid.ToString()); } Hi.Model.PAY_PrePayment prepayModel = new Hi.Model.PAY_PrePayment(); prepayModel.CompID = disModel.CompID; prepayModel.DisID = disModel.ID; prepayModel.OrderID = OrderModel.ID; prepayModel.Start = 2; prepayModel.PreType = 5; prepayModel.price = price * -1; prepayModel.Paytime = DateTime.Now; prepayModel.CreatDate = DateTime.Now; prepayModel.CrateUser = this.UserID; prepayModel.AuditState = 2; prepayModel.IsEnabled = 1; prepayModel.ts = DateTime.Now; prepayModel.modifyuser = this.UserID; prepayModel.guid = Common.Number_repeat(Guid.NewGuid().ToString().Replace("-", "")); // prepayModel.vdef1 = "订单支付"; prepayid = new Hi.BLL.PAY_PrePayment().Add(prepayModel); int prepay = 0; int order = 0; if (prepayid > 0 && payPrice == 0)//payPrice(网银支付金额)= 0 ,只用企业钱包支付,修改状态 { SqlConnection con = new SqlConnection(LocalSqlServer); con.Open(); SqlTransaction sqlTrans = con.BeginTransaction(); try { prepay = new Hi.BLL.PAY_PrePayment().updatePrepayState(con, prepayid, sqlTrans); //修改企业钱包状态 order = new Hi.BLL.DIS_Order().UpdateOrderPstate(con, OrderModel.ID, price, sqlTrans); //修改订单状态 if (prepay > 0 && order > 0) { sqlTrans.Commit(); } else { sqlTrans.Rollback(); } } catch { prepay = 0; order = 0; sqlTrans.Rollback(); } finally { con.Close(); } if (prepay > 0 && order > 0) { try { if (OrderModel.Otype == (int)Enums.OType.推送账单) { Utils.AddSysBusinessLog(disModel.CompID, "Order", OrderModel.ID.ToString(), "账单支付", "支付:" + price.ToString("0.00") + "元(企业钱包支付)", this.UserID.ToString()); } else { Utils.AddSysBusinessLog(disModel.CompID, "Order", OrderModel.ID.ToString(), "订单支付", "支付:" + price + "元(企业钱包支付)", this.UserID.ToString()); } if (OrderModel.Otype != 9) { OrderInfoType.AddIntegral(this.CompID, this.DisID, "1", 1, OrderModel.ID, price, "订单支付", "", this.UserID); } new Common().GetWxService("2", OrderModel.ID.ToString(), "1", price); } catch (Exception ex) { ErrMessage("支付失败", orderid.ToString()); } if (OrderModel.Otype == (int)Enums.OType.推送账单) { Response.Redirect("PaySuccess.aspx?type=" + Common.DesEncrypt("2", Common.EncryptKey) + "&KeyID=" + Common.DesEncrypt(OrderModel.ID.ToString(), Common.EncryptKey) + "&Pid=" + Common.DesEncrypt("0".ToString(), Common.EncryptKey) + "&PPid=" + Common.DesEncrypt(prepayid.ToString(), Common.EncryptKey) + "&IsRef=Y", false); } else { Response.Redirect("PaySuccess.aspx?type=" + Common.DesEncrypt("1", Common.EncryptKey) + "&KeyID=" + Common.DesEncrypt(OrderModel.ID.ToString(), Common.EncryptKey) + "&Pid=" + Common.DesEncrypt("0".ToString(), Common.EncryptKey) + "&PPid=" + Common.DesEncrypt(prepayid.ToString(), Common.EncryptKey) + "&IsRef=Y", false); } } } } #endregion #region 插入支付表记录 Hi.Model.PAY_Payment payModel = new Hi.Model.PAY_Payment(); string orderNo = WebConfigurationManager.AppSettings["OrgCode"] + DateTime.Now.ToString("yyyyMMdd");//支付订单号前半部分 string guid = Guid.NewGuid().ToString().Replace("-", ""); payModel.OrderID = OrderModel.ID; // orderid; payModel.DisID = this.DisID; payModel.Type = 0; // isDBPay; payModel.PayUser = disModel.DisName; payModel.PayPrice = payPrice; payModel.IsAudit = 2; payModel.guid = Common.Number_repeat(guid); payModel.vdef3 = "1"; //1,订单支付,2,预付款充值、汇款 payModel.vdef4 = orderNo; payModel.CreateDate = DateTime.Now; payModel.CreateUserID = this.UserID; payModel.ts = DateTime.Now; payModel.modifyuser = this.UserID; payModel.PrintNum = 1; //支付宝支付无需结算 //判断账户类型,判断支付渠道 payModel.Channel = "7"; //1,快捷支付,2,银联支付 ,3,网银支付,4,B2B网银支付,5,线下支付,6,支付宝支付 7,微信支付 payModel.State = 0; //手续费收取方 payModel.vdef5 = "0.00"; //支付手续费 payid = new Hi.BLL.PAY_Payment().Add(payModel); if (prepayid > 0) { Hi.Model.PAY_PrePayment prepayMent = new Hi.BLL.PAY_PrePayment().GetModel(prepayid); prepayMent.vdef4 = payid.ToString();//与企业钱包关联 new Hi.BLL.PAY_PrePayment().Update(prepayMent); } Hi.Model.PAY_RegisterLog regModel = new Hi.Model.PAY_RegisterLog(); regModel.OrderId = OrderModel.ID;// orderid; regModel.Ordercode = orderNo + payid.ToString(); regModel.number = payModel.guid; regModel.Price = payPrice; regModel.Payuse = "订单支付"; regModel.PayName = disModel.DisName; regModel.DisID = OrderModel.DisID; regModel.PayTime = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"); regModel.Remark = OrderModel.Remark;// orderModel.Remark; regModel.DisName = new Hi.BLL.BD_Company().GetModel(disModel.CompID).CompName; regModel.BankID = "支付宝支付"; regModel.CreateUser = this.UserID; regModel.CreateDate = DateTime.Now; regModel.LogType = 1311; int regid = new Hi.BLL.PAY_RegisterLog().Add(regModel); if (payid <= 0 || regid <= 0) { Response.Redirect("Error.aspx?type=" + Common.DesEncrypt("3", Common.EncryptKey) + "&KeyID=" + Common.DesEncrypt(Convert.ToString(KeyID), Common.EncryptKey) + "&msg=" + Common.DesEncrypt("支付失败!", Common.EncryptKey), false); } //订单所有商品明细 DataTable l = new Hi.BLL.DIS_OrderDetail().GetOrderDe("", " IsNUll(o.dr,0)=0 and o.OrderId=" + orderid); foreach (DataRow dr in l.Rows) { GoodsName += dr["GoodsName"] + ","; } GoodsName = GoodsName.Substring(0, GoodsName.Length - 1);//去掉最后一个逗号 if (GoodsName.Length > 15) { GoodsName = GoodsName.Substring(0, 10) + "..."; } #endregion int amount = Convert.ToInt32(payPrice * 100);//支付金额(单位:分) //隐藏域赋值 this.hidguid.Value = payModel.guid; this.hidprice.Value = payPrice.ToString(); this.hidordid.Value = payModel.OrderID.ToString(); this.hidpid.Value = payid.ToString(); this.hidppid.Value = prepayid.ToString(); // btnWxPay_Click(payModel.guid, orderid.ToString(), amount); Wxpay_Url wxpaymodel = new Wxpay_Url(); wxpaymodel.Guid = payModel.guid; wxpaymodel.OrderID = orderid.ToString(); wxpaymodel.Amount = amount; wxpaymodel.Hidguid = payModel.guid; wxpaymodel.Hidprice = payModel.PayPrice.ToString(); wxpaymodel.Hidordid = payModel.OrderID.ToString(); wxpaymodel.Hidpid = payid.ToString(); wxpaymodel.Hidppid = prepayid.ToString(); return(wxpaymodel); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(Hi.Model.PAY_Payment model) { return(dal.Update(model)); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Hi.Model.PAY_Payment model) { return(dal.Add(model)); }
/// <summary> /// 支付宝支付 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnApliay() { //企业钱包充值记录 Hi.Model.PAY_PrePayment prepayM = new Hi.BLL.PAY_PrePayment().GetModel(KeyID); decimal price = prepayM.price; #region 支付记录 int payid = 0; int regid = 0; string guid = Guid.NewGuid().ToString().Replace("-", ""); Hi.Model.PAY_Payment payModel = new Hi.Model.PAY_Payment(); payModel.OrderID = KeyID; payModel.DisID = this.DisID; payModel.PayUser = new Hi.BLL.BD_Distributor().GetModel(this.DisID).DisName; payModel.PayPrice = price; payModel.guid = Common.Number_repeat(guid); payModel.IsAudit = 2; payModel.vdef3 = "2"; payModel.CreateDate = DateTime.Now; payModel.CreateUserID = this.UserID; payModel.ts = DateTime.Now; payModel.modifyuser = this.UserID; payModel.Channel = "6"; //1,快捷支付,2,银联支付 ,3,网银支付,4,B2B网银支付,5,线下支付,6,支付宝支付 7,微信支付 payModel.State = 0; //手续费收取方 payModel.vdef5 = "0.00"; //支付手续费 payModel.PrintNum = 1; //结算标示 payid = new Hi.BLL.PAY_Payment().Add(payModel); Hi.Model.PAY_RegisterLog regModel = new Hi.Model.PAY_RegisterLog(); regModel.OrderId = KeyID; regModel.Ordercode = WebConfigurationManager.AppSettings["OrgCode"] + Convert.ToString(KeyID); regModel.number = payModel.guid; regModel.Price = price; regModel.Payuse = prepayM.PreType == 6 ? "转账汇款" : prepayM.PreType == 1 ? "企业钱包充值" : ""; regModel.PayName = new Hi.BLL.BD_Distributor().GetModel(this.DisID).DisName; regModel.DisID = this.DisID; regModel.PayTime = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"); regModel.Remark = prepayM.vdef1; regModel.DisName = new Hi.BLL.BD_Company().GetModel(this.CompID).CompName; regModel.BankID = "支付宝"; regModel.CreateUser = this.UserID; regModel.CreateDate = DateTime.Now; regModel.LogType = 1375; regid = new Hi.BLL.PAY_RegisterLog().Add(regModel); if (payid <= 0 || regid <= 0) { //JScript.AlertMsg(this, "数据异常!"); ClientScript.RegisterStartupScript(this.GetType(), "payTx1375", "<script>$('#lblErr').html('数据异常!');</script>"); return; } #endregion #region 支付宝支付 //支付类型 string payment_type = "1"; //必填,不能修改 //服务器异步通知页面路径 string notify_url = HttpContext.Current.Request.Url.Scheme + "://" + HttpContext.Current.Request.Url.Host + ":" + HttpContext.Current.Request.Url.Port + "/Distributor/Pay/ReceiveNoticeAlipay.aspx"; //需http://格式的完整路径,不能加?id=123这类自定义参数 //页面跳转同步通知页面路径 string return_url = HttpContext.Current.Request.Url.Scheme + "://" + HttpContext.Current.Request.Url.Host + ":" + HttpContext.Current.Request.Url.Port + "/Distributor/pay/PrePayList.aspx"; //需http://格式的完整路径,不能加?id=123这类自定义参数,不能写成http://localhost/ //卖家支付宝帐户 //string seller_email = "*****@*****.**"; string seller_email = Common.GetPayWxandAli(this.CompID).ali_seller_email;// ConfigurationManager.AppSettings["seller_email"] == null ? "*****@*****.**" : ConfigurationManager.AppSettings["seller_email"].ToString().Trim(); //必填 //商户订单号 string out_trade_no = payModel.guid;// OrderModel.GUID; //商户网站订单系统中唯一订单号,必填 //订单名称 string subject = "钱包充值";//OrderModel.GUID; //必填 //付款金额 string total_fee = price.ToString("0.00"); string paymethod = string.Empty; //默认支付方式 string defaultbank = string.Empty; //默认网银 //if (OrderInfoModel.BankId != "0" && OrderInfoModel.BankId != "") //{ // //默认支付方式 // paymethod = "bankPay"; // //必填 // //默认网银 // defaultbank = OrderInfoModel.BankId; //} //必填 //订单描述 string body = prepayM.vdef1; //商品展示地址 string show_url = "http://www.my1818.com"; //需以http://开头的完整路径, //防钓鱼时间戳 string anti_phishing_key = Submit.Query_timestamp();//""; //若要使用请调用类文件submit中的query_timestamp函数 //客户端的IP地址 string exter_invoke_ip = Page.Request.UserHostAddress; //非局域网的外网IP地址,如:221.0.0.1 //把请求参数打包成数组 SortedDictionary <string, string> sParaTemp = new SortedDictionary <string, string>(); sParaTemp.Add("partner", Config.Partner); sParaTemp.Add("_input_charset", Config.Input_charset.ToLower()); sParaTemp.Add("service", "create_direct_pay_by_user"); sParaTemp.Add("payment_type", payment_type); sParaTemp.Add("notify_url", notify_url); sParaTemp.Add("return_url", return_url); sParaTemp.Add("seller_email", seller_email); sParaTemp.Add("out_trade_no", out_trade_no); sParaTemp.Add("subject", subject); sParaTemp.Add("total_fee", total_fee); sParaTemp.Add("body", body); //if (OrderInfoModel.BankId != "0" && OrderInfoModel.BankId != "") //{ // sParaTemp.Add("paymethod", paymethod); // sParaTemp.Add("defaultbank", defaultbank); //} sParaTemp.Add("show_url", show_url); sParaTemp.Add("anti_phishing_key", anti_phishing_key); sParaTemp.Add("exter_invoke_ip", exter_invoke_ip); //建立请求 string sHtmlText = Submit.BuildRequest(sParaTemp, "get", "确认"); Response.Write(sHtmlText); #endregion }
protected void Page_Load(object sender, EventArgs e) { int orderid = 0; if (!IsPostBack) { try { // 1.取得参数 if (Request.Form["hidOid"] == "") { orderid = 0; } else { orderid = Common.DesDecrypt(Request.Form["hidOid"], Common.EncryptKey).ToInt(0); KeyID = orderid; } if (!Common.PageDisOperable("Order", orderid, this.DisID)) { Response.Redirect("../../NoOperable.aspx", true); return; } decimal txtPayOrder = Convert.ToDecimal(Request.Form["hidPayOrder"]); //本次支付总金额 decimal price = Convert.ToDecimal(Request.Form["hidPrice"]); //使用企业钱包金额 int yfk = Convert.ToInt32(Request.Form["hidIsPre"]); //是否使用企业钱包 1:是 0:否 int isDBPay = Convert.ToInt32(Request.Form["hidIsDBPay"]); //是否是担保支付 1:是 0:否 string bankid = Convert.ToString(Request.Form["hidBankNo"]); //银行编号 string AccountType = Request.Form["hidAccountType"]; //账户类型 string payPas = Convert.ToString(Request.Form["hidPayPas"]); //预付款密码 Hi.Model.BD_Distributor disModel = new Hi.BLL.BD_Distributor().GetModel(this.DisID); Hi.Model.DIS_Order disOrderMOdel = new Hi.BLL.DIS_Order().GetModel(orderid); if (disModel == null) { err = true; ErrMessage("数据异常"); return; } decimal sumPrice = new Hi.BLL.PAY_PrePayment().sums(disModel.ID, disOrderMOdel.CompID); //剩余企业钱包 int disid = this.DisID; //代理商ID string password = disModel.Paypwd; if (yfk == 1) { if (payPas == null || payPas.Trim().ToString() == "") { err = true; ErrMessage("企业钱包密码不能为空"); return; } payPas = payPas.Trim().ToString(); if (password == Util.md5("123456")) { err = true; ErrMessage("请先修改企业钱包支付密码"); return; } else { if (payPas == "") { //string Josn = "{\"error\":\"1\",\"msg\":\"密码不能为空!\"}"; err = true; ErrMessage("密码不能为空"); return; } } } decimal payPrice = 0; if (txtPayOrder == 0) { err = true; ErrMessage("支付金额不能为0"); return; } if (yfk == 1 && txtPayOrder < price) { err = true; ErrMessage("使用企业钱包大于支付金额!"); return; } if (yfk == 1) { payPrice = txtPayOrder - price; } else { payPrice = txtPayOrder; } if (orderid <= 0) { //string Josn = "{\"error\":\"1\",\"msg\":\"操作有误!\"}"; err = true; ErrMessage("数据有误"); return; } Hi.Model.DIS_Order orderModel = new Hi.BLL.DIS_Order().GetModel(orderid); if (orderModel == null) { err = true; ErrMessage("数据有误"); return; } if (txtPayOrder > orderModel.AuditAmount + orderModel.OtherAmount - orderModel.PayedAmount) { err = true; ErrMessage("支付金额大于未支付金额,不能支付!"); return; } if (!(( (orderModel.Otype == (int)Enums.OType.赊销订单 && (orderModel.OState != (int)Enums.OrderState.退回 && orderModel.OState != (int)Enums.OrderState.未提交 && orderModel.OState != (int)Enums.OrderState.待审核) && (orderModel.PayState == (int)Enums.PayState.未支付 || orderModel.PayState == (int)Enums.PayState.部分支付)) || (orderModel.Otype != (int)Enums.OType.赊销订单 && orderModel.Otype != (int)Enums.OType.推送账单 && (orderModel.OState == (int)Enums.OrderState.已审 || orderModel.OState == (int)Enums.OrderState.已发货 || orderModel.OState == (int)Enums.OrderState.已到货) && (orderModel.PayState == (int)Enums.PayState.未支付 || orderModel.PayState == (int)Enums.PayState.部分支付)) || (orderModel.Otype == (int)Enums.OType.推送账单 && orderModel.OState == (int)Enums.OrderState.已审 && (orderModel.PayState == (int)Enums.PayState.部分支付 || orderModel.PayState == (int)Enums.PayState.未支付)) ) && orderModel.OState != (int)Enums.OrderState.已作废)) { if (orderModel.Otype == (int)Enums.OType.推送账单) { err = true; ErrMessage("账单异常,不能支付"); } else { err = true; ErrMessage("订单异常,不能支付"); } return; } int prepayid = 0; if (yfk == 1 && price > 0) { //企业钱包处理 if (sumPrice < price) { err = true; ErrMessage("企业钱包余额不足"); return; } if (disModel.Paypwd != Util.md5(payPas)) { err = true; ErrMessage("支付密码不正确"); return; } Hi.Model.PAY_PrePayment prepayModel = new Hi.Model.PAY_PrePayment(); prepayModel.CompID = disOrderMOdel.CompID; prepayModel.DisID = disModel.ID; prepayModel.OrderID = orderid; prepayModel.Start = 2; prepayModel.PreType = 5; prepayModel.price = price * -1; prepayModel.Paytime = DateTime.Now; prepayModel.CreatDate = DateTime.Now; prepayModel.CrateUser = this.UserID; prepayModel.AuditState = 2; prepayModel.IsEnabled = 1; prepayModel.ts = DateTime.Now; prepayModel.modifyuser = this.UserID; prepayModel.guid = Common.Number_repeat(Guid.NewGuid().ToString().Replace("-", "")); // prepayModel.vdef1 = "订单支付"; prepayid = new Hi.BLL.PAY_PrePayment().Add(prepayModel); int prepay = 0; int order = 0; if (prepayid > 0 && payPrice == 0)//payPrice(网银支付金额)= 0 ,只用企业钱包支付,修改状态 { SqlConnection con = new SqlConnection(LocalSqlServer); con.Open(); SqlTransaction sqlTrans = con.BeginTransaction(); try { prepay = new Hi.BLL.PAY_PrePayment().updatePrepayState(con, prepayid, sqlTrans); //修改企业钱包状态 order = new Hi.BLL.DIS_Order().UpdateOrderPstate(con, orderid, price, sqlTrans); //修改订单状态 if (prepay > 0 && order > 0) { sqlTrans.Commit(); } else { sqlTrans.Rollback(); } } catch { prepay = 0; order = 0; sqlTrans.Rollback(); } finally { con.Close(); } if (prepay > 0 && order > 0) { try { if (orderModel.Otype == (int)Enums.OType.推送账单) { Utils.AddSysBusinessLog(disOrderMOdel.CompID, "Order", orderid.ToString(), "账单支付", "支付:" + price.ToString("0.00") + "元(企业钱包支付)", this.UserID.ToString()); } else { Utils.AddSysBusinessLog(disOrderMOdel.CompID, "Order", orderid.ToString(), "订单支付", "支付:" + price + "元(企业钱包支付)", this.UserID.ToString()); } if (orderModel.Otype != 9) { OrderInfoType.AddIntegral(disOrderMOdel.CompID, disOrderMOdel.DisID, "1", 1, orderid, price, "订单支付", "", this.UserID); } new Common().GetWxService("2", orderid.ToString(), "1", price); } catch (Exception ex) { throw ex; } if (orderModel.Otype == (int)Enums.OType.推送账单) { err = true;//阻止进入网银支付 Response.Redirect("PaySuccess.aspx?type=" + Common.DesEncrypt("2", Common.EncryptKey) + "&KeyID=" + Common.DesEncrypt(orderid.ToString(), Common.EncryptKey) + "&Pid=" + Common.DesEncrypt("0".ToString(), Common.EncryptKey) + "&PPid=" + Common.DesEncrypt(prepayid.ToString(), Common.EncryptKey) + "&IsRef=Y", false); } else { err = true;//阻止进入网银支付 Response.Redirect("PaySuccess.aspx?type=" + Common.DesEncrypt("1", Common.EncryptKey) + "&KeyID=" + Common.DesEncrypt(orderid.ToString(), Common.EncryptKey) + "&Pid=" + Common.DesEncrypt("0".ToString(), Common.EncryptKey) + "&PPid=" + Common.DesEncrypt(prepayid.ToString(), Common.EncryptKey) + "&IsRef=Y", false); } return; } else { err = true; ErrMessage("支付失败"); return; } } } if (payPrice <= 0) { err = true; ErrMessage("数据有误"); return; } #region 计算支付手续费 start string sxfsq = "-1"; decimal sxf = 0; decimal comp_sxf = 0;//收费方是厂商是,为了不改变支付金额,故声明此变量来记录,厂商手续费。 // 获取手续费 begin string[] Json = Common.GetSxf(disOrderMOdel.CompID, AccountType, bankid, payPrice); string strMsg = Json[2].ToString(); if (!string.IsNullOrEmpty(strMsg)) { ErrMessage(strMsg); return; } else { sxfsq = Json[1].ToString(); sxf = Convert.ToDecimal(Json[0]); comp_sxf = Convert.ToDecimal(Json[3]); } // 获取手续费 end //支付总金额(含手续费) decimal UNIT = 0.01M; payPrice = payPrice + Common.Round(sxf, UNIT); #endregion 计算支付手续费 end int payid = 0; int regid = 0; Hi.Model.PAY_Payment payModel = new Hi.Model.PAY_Payment(); string orderNo = WebConfigurationManager.AppSettings["OrgCode"] + DateTime.Now.ToString("yyyyMMdd");//支付订单号前半部分 string guid = Guid.NewGuid().ToString().Replace("-", ""); payModel.OrderID = orderid; payModel.DisID = this.DisID; payModel.Type = isDBPay; payModel.PayUser = disModel.DisName; payModel.PayPrice = payPrice; payModel.IsAudit = 2; payModel.guid = Common.Number_repeat(guid); payModel.vdef3 = "1"; payModel.vdef4 = orderNo; payModel.CreateDate = DateTime.Now; payModel.CreateUserID = this.UserID; payModel.ts = DateTime.Now; payModel.modifyuser = this.UserID; //判断账户类型,判断支付渠道,然后赋值 if (AccountType == "11") { if (bankid == "888") { payModel.Channel = "2"; } else { payModel.Channel = "3"; } }//信用卡支付 else if (AccountType == "13") { payModel.Channel = "8"; } else//网银支付 { payModel.Channel = "4"; } payModel.State = Convert.ToInt32(sxfsq);//手续费收取方 if (sxfsq.Equals("2")) { payModel.vdef5 = comp_sxf.ToString("0.00"); } else { payModel.vdef5 = sxf.ToString("0.00");//支付手续费 } payid = new Hi.BLL.PAY_Payment().Add(payModel); if (prepayid > 0) { Hi.Model.PAY_PrePayment prepayMent = new Hi.BLL.PAY_PrePayment().GetModel(prepayid); prepayMent.vdef4 = payid.ToString();//与企业钱包关联 new Hi.BLL.PAY_PrePayment().Update(prepayMent); } Hi.Model.PAY_RegisterLog regModel = new Hi.Model.PAY_RegisterLog(); regModel.OrderId = orderid; regModel.Ordercode = orderNo;// orderNo + payid.ToString(); regModel.number = payModel.guid; regModel.Price = payPrice; regModel.Payuse = "订单支付"; regModel.PayName = disModel.DisName; regModel.DisID = disid; regModel.PayTime = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"); regModel.Remark = orderModel.Remark; regModel.DisName = new Hi.BLL.BD_Company().GetModel(disOrderMOdel.CompID).CompName; regModel.BankID = bankid; regModel.CreateUser = this.UserID; regModel.CreateDate = DateTime.Now; regModel.LogType = 1311; regid = new Hi.BLL.PAY_RegisterLog().Add(regModel); if (payid <= 0 || regid <= 0) { err = true; ErrMessage("数据有误"); return; } string configPath = WebConfigurationManager.AppSettings["payment.config.path"]; try { PaymentEnvironment.Initialize(configPath); } catch (Exception ex) { //string Josn = "{\"error\":\"1\",\"msg\":\"支付配置有误,请联系系统管理员!\"}"; err = true; ErrMessage("支付配置有误,请联系系统管理员"); return; } String institutionID = WebConfigurationManager.AppSettings["PayOrgCode"]; //机构代码 long amount = Convert.ToInt64(payPrice * 100); //支付金额(单位:分) long fee = 0; String usage = "支付订单"; String remark = "订单支付"; String notificationURL = ""; //"http://www.my1818.com/Handler/ReceiveNoticePage.ashx";//Request.Url.Scheme + "://" + Request.Url.Host + ":" + Request.Url.Port + if (WebConfigurationManager.AppSettings["PayType"] == "0") { notificationURL = Request.Url.Scheme + "://" + Request.Url.Host + ":" + Request.Url.Port + "/Handler/ReceiveNoticePage.ashx"; } // notificationURL = "https://www.yibanmed.com/Handler/ReceiveNoticePage.ashx"; else { notificationURL = "https://www.yibanmed.com/Handler/ReceiveNoticePage.ashx";//回调页面地址 } String payees = new Hi.BLL.BD_Company().GetModel(disOrderMOdel.CompID).CompName; //判断支付接口 string Pay_type = WebConfigurationManager.AppSettings["PayType"]; String bankID = string.Empty; if (Pay_type == "0") //测试接口 { bankID = "700"; //bankid;// } else { bankID = bankid;//正式接口 } int accountType = Convert.ToInt32(AccountType); // 2.创建交易请求对象 Tx1311Request tx1311Request = new Tx1311Request(); tx1311Request.setInstitutionID(institutionID); //机构号码 tx1311Request.setOrderNo(orderNo); //订单号orderNo + payid.ToString() tx1311Request.setPaymentNo(payModel.guid); //支付交易流水号 tx1311Request.setAmount(amount); //支付金额 单位分 tx1311Request.setFee(fee); //支付服务手续费 单位分 tx1311Request.setPayerID(""); //付款人注册ID tx1311Request.setPayerName(""); //付款方名称 tx1311Request.setUsage(usage); //资金用途 tx1311Request.setRemark(remark); //备注 tx1311Request.setNotificationURL(notificationURL); //机构接收支付通知的URL tx1311Request.addPayee(""); //收款方名称 if (accountType == 13) { tx1311Request.setAccountType(11); //付款方帐号类型 tx1311Request.setCardType("02"); //银行卡类型(01=借记卡、02=贷记卡) } else if (accountType == 11) { tx1311Request.setAccountType(accountType); //付款方帐号类型 tx1311Request.setCardType("01"); //银行卡类型(01=借记卡、02=贷记卡) } else if (accountType == 12) { tx1311Request.setAccountType(accountType); //付款方帐号类型 } tx1311Request.setBankID(bankID); //付款银行标识 // 3.执行报文处理 tx1311Request.process(); try { Hi.Model.PAY_RegisterLog regM = new Hi.BLL.PAY_RegisterLog().GetModel(regid); regM.PlanMessage = tx1311Request.getRequestPlainText(); new Hi.BLL.PAY_RegisterLog().Update(regM); } catch (Exception ex) { throw ex; } //跳转的url地址 HttpContext.Current.Items["action"] = PaymentEnvironment.PaymentURL; //中金返回信息 HttpContext.Current.Items["message"] = tx1311Request.getRequestMessage(); //中金签名信息 HttpContext.Current.Items["signature"] = tx1311Request.getRequestSignature(); } catch (Exception ex) { err = true; ErrMessage(ex.Message); return; } finally { if (!err) { Context.Server.Transfer("DoSubmit.aspx", false); } } } }
protected void btnTx1376_Click(object sender, EventArgs e) { try { Hi.Model.PAY_PrePayment prepayM = new Hi.Model.PAY_PrePayment(); Hi.Model.PAY_Payment payM = new Hi.Model.PAY_Payment(); if (Request.QueryString["KeyID"] == "") { KeyID = 0; } else { KeyID = Convert.ToInt32(Common.DesDecrypt(Request.QueryString["KeyID"].ToString(), Common.EncryptKey)); } string phoneCode = this.txtPhoneNum.Value; //检验码 decimal price = 0; //使用企业钱包金额 int hidPay = 0; //支付表ID if (ViewState["payid"] == null || ViewState["payid"] == "") { //JScript.ShowAlert(this, "数据异常!", "$('#txtPhoneNum').val('');$('.tip').fadeOut(100);$('.opacity').fadeOut(100);"); Tx1376ErrResult("数据异常!"); return; } hidPay = Convert.ToInt32(ViewState["payid"]); ViewState["payid"] = null; payM = new Hi.BLL.PAY_Payment().GetModel(hidPay); int hidPrepay = KeyID;//企业钱包表ID if (hidPrepay <= 0) { //JScript.ShowAlert(this, "数据异常!", "$('#txtPhoneNum').val('');$('.tip').fadeOut(100);$('.opacity').fadeOut(100);"); Tx1376ErrResult("数据异常!"); return; } prepayM = new Hi.BLL.PAY_PrePayment().GetModel(Convert.ToInt32(hidPrepay)); price = prepayM.price; int hidFastPay = Convert.ToInt32(this.hidFastPay.Value); int regid = 0; Hi.Model.PAY_RegisterLog regModel = new Hi.Model.PAY_RegisterLog(); regModel.OrderId = hidPrepay; regModel.Ordercode = payM.vdef4;// WebConfigurationManager.AppSettings["OrgCode"] + Convert.ToString(hidPrepay); regModel.number = payM.guid; regModel.Price = price; regModel.Payuse = prepayM.PreType == 6 ? "转账汇款" : prepayM.PreType == 1 ? "企业钱包充值" : ""; regModel.PayName = new Hi.BLL.BD_Distributor().GetModel(this.DisID).DisName; regModel.DisID = this.DisID; regModel.PayTime = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"); regModel.Remark = prepayM.vdef1; regModel.DisName = new Hi.BLL.BD_Company().GetModel(this.CompID).CompName; regModel.BankID = new Hi.BLL.PAY_FastPayMent().GetModel(hidFastPay).BankID.ToString(); regModel.CreateUser = this.UserID; regModel.CreateDate = DateTime.Now; regModel.LogType = 1376; regid = new Hi.BLL.PAY_RegisterLog().Add(regModel); if (regid <= 0) { Tx1376ErrResult("数据异常!"); return; } if (WebConfigurationManager.AppSettings["Paytest_zj"] != "1") { string configPath = WebConfigurationManager.AppSettings["payment.config.path"]; try { PaymentEnvironment.Initialize(configPath); } catch { throw new Exception("支付配置不正确,请联系管理员!"); } string institutionID = WebConfigurationManager.AppSettings["PayOrgCode"];//机构号码 Tx1376Request tx1376Request = new Tx1376Request(); tx1376Request.setInstitutionID(institutionID); tx1376Request.setOrderNo(payM.vdef4);//WebConfigurationManager.AppSettings["OrgCode"] + Convert.ToString(hidPrepay) tx1376Request.setPaymentNo(new Hi.BLL.PAY_Payment().GetModel(Convert.ToInt32(hidPay)).guid); tx1376Request.setSmsValidationCode(phoneCode); tx1376Request.process(); TxMessenger txMessenger = new TxMessenger(); String[] respMsg = txMessenger.send(tx1376Request.getRequestMessage(), tx1376Request.getRequestSignature()); Tx1376Response tx1376Response = new Tx1376Response(respMsg[0], respMsg[1]); try { Hi.Model.PAY_RegisterLog regM = new Hi.BLL.PAY_RegisterLog().GetModel(regid); regM.PlanMessage = tx1376Request.getRequestPlainText(); regM.Start = tx1376Response.getCode(); regM.ResultMessage = tx1376Response.getMessage(); new Hi.BLL.PAY_RegisterLog().Update(regM); Hi.Model.PAY_Payment payModel = new Hi.BLL.PAY_Payment().GetModel(hidPay); payM.PayDate = DateTime.Now; payModel.ts = DateTime.Now; payModel.verifystatus = tx1376Response.getVerifyStatus(); payModel.status = tx1376Response.getStatus(); new Hi.BLL.PAY_Payment().Update(payModel); } catch { } if (!"2000".Equals(tx1376Response.getCode())) { Tx1376ErrResult(tx1376Response.getMessage()); return; } int VerifyStatus = tx1376Response.getVerifyStatus(); int Status = tx1376Response.getStatus(); if (VerifyStatus != 40 || Status != 20)//VerifyStatus = 40 验证码验证成功,Status = 20 支付成功 { if (Status == 10) { //中金:支付处理中,钱会从账户中扣除,第二天会退回到账户中。 Tx1376ErrResult("代扣失败"); return; } Tx1376ErrResult(tx1376Response.getResponseMessage()); return; } } else { try { Hi.Model.PAY_RegisterLog regM = new Hi.BLL.PAY_RegisterLog().GetModel(regid); regM.PlanMessage = ""; regM.Start = "2000"; regM.ResultMessage = "OK."; new Hi.BLL.PAY_RegisterLog().Update(regM); Hi.Model.PAY_Payment payModel = new Hi.BLL.PAY_Payment().GetModel(hidPay); payM.PayDate = DateTime.Now; payModel.ts = DateTime.Now; payModel.verifystatus = 40; payModel.status = 20; new Hi.BLL.PAY_Payment().Update(payModel); } catch { } } int prepay = 0; int pay = 0; SqlConnection con = new SqlConnection(LocalSqlServer); con.Open(); SqlTransaction sqlTrans = con.BeginTransaction(); try { pay = new Hi.BLL.PAY_Payment().updatePayState(con, hidPay, sqlTrans); prepay = new Hi.BLL.PAY_PrePayment().updatePrepayState(con, hidPrepay, sqlTrans); if (pay > 0 && prepay > 0) { sqlTrans.Commit(); } else { sqlTrans.Rollback(); } } catch { pay = 0; prepay = 0; sqlTrans.Rollback(); } finally { con.Close(); } if (pay <= 0 || prepay <= 0) { Tx1376ErrResult("支付成功,但修改支付状态失败,请联系系统管理员,勿重复操作!"); return; } Response.Redirect("PaySuccess.aspx?type=" + Common.DesEncrypt("3", Common.EncryptKey) + "&KeyID=" + Common.DesEncrypt(KeyID.ToString(), Common.EncryptKey), false); return; } catch (Exception ex) { JScript.AlertMethod(this, ex.Message, JScript.IconOption.错误, "function (){ $('#txtPhoneNum').val('');$('.tip').fadeOut(100);$('.opacity').fadeOut(100); }"); return; } }
public void tx1375() { try { int hidFastPay = Convert.ToInt32(this.hidFastPay.Value); if (hidFastPay > 0) { string phone = new Hi.BLL.PAY_FastPayMent().GetModel(hidFastPay).phone; this.phone.InnerHtml = "(已发送至" + phone.Substring(0, 3) + " **** " + phone.Substring(phone.Length - 4, 4) + ")"; } Hi.Model.PAY_PrePayment prepayM = new Hi.BLL.PAY_PrePayment().GetModel(KeyID); decimal price = prepayM.price; #region 计算支付手续费 start string AccountType = hid_PayType.Value; string bankid = hidBank.Value; string sxfsq = "-1"; decimal sxf = 0; // 获取手续费 begin string[] Json = Common.GetFastPay_sxf(this.CompID, price); string strMsg = Json[2].ToString(); if (!string.IsNullOrEmpty(strMsg)) { Tx1376ErrResult(strMsg); return; } else { sxfsq = Json[1].ToString(); sxf = Convert.ToDecimal(Json[0]); } //支付总金额(含手续费) decimal UNIT = 0.01M; price = price + Common.Round(sxf, UNIT); #endregion 计算支付手续费 end String orderNo = WebConfigurationManager.AppSettings["OrgCode"] + DateTime.Now.ToString("yyyyMMdd");//支付订单号前半部分 int payid = 0; int regid = 0; string guid = Guid.NewGuid().ToString().Replace("-", ""); Hi.Model.PAY_Payment payModel = new Hi.Model.PAY_Payment(); payModel.OrderID = KeyID; payModel.DisID = this.DisID; payModel.PayUser = new Hi.BLL.BD_Distributor().GetModel(this.DisID).DisName; payModel.PayPrice = price; payModel.guid = Common.Number_repeat(guid); payModel.IsAudit = 2; payModel.vdef3 = "2"; payModel.vdef4 = orderNo; payModel.CreateDate = DateTime.Now; payModel.CreateUserID = this.UserID; payModel.ts = DateTime.Now; payModel.modifyuser = this.UserID; payModel.Channel = "1"; //支付渠道 payModel.State = Convert.ToInt32(sxfsq); //手续费收取方 payModel.vdef5 = sxf.ToString("0.00"); //支付手续费 payModel.vdef9 = "1"; //默认支付 payid = new Hi.BLL.PAY_Payment().Add(payModel); ViewState["payid"] = payid; Hi.Model.PAY_RegisterLog regModel = new Hi.Model.PAY_RegisterLog(); regModel.OrderId = KeyID; regModel.Ordercode = WebConfigurationManager.AppSettings["OrgCode"] + Convert.ToString(KeyID); regModel.number = payModel.guid; regModel.Price = price; regModel.Payuse = prepayM.PreType == 6 ? "转账汇款" : prepayM.PreType == 1 ? "企业钱包充值" : ""; regModel.PayName = new Hi.BLL.BD_Distributor().GetModel(this.DisID).DisName; regModel.DisID = this.DisID; regModel.PayTime = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"); regModel.Remark = prepayM.vdef1; regModel.DisName = new Hi.BLL.BD_Company().GetModel(this.CompID).CompName; regModel.BankID = new Hi.BLL.PAY_FastPayMent().GetModel(hidFastPay).BankID.ToString(); regModel.CreateUser = this.UserID; regModel.CreateDate = DateTime.Now; regModel.LogType = 1375; regid = new Hi.BLL.PAY_RegisterLog().Add(regModel); if (payid <= 0 || regid <= 0) { //JScript.AlertMsg(this, "数据异常!"); ClientScript.RegisterStartupScript(this.GetType(), "payTx1375", "<script>$('#lblErr').html('数据异常!');</script>"); return; } if (WebConfigurationManager.AppSettings["Paytest_zj"] != "1") { string configPath = WebConfigurationManager.AppSettings["payment.config.path"]; try { PaymentEnvironment.Initialize(configPath); } catch { throw new Exception("支付配置不正确,请联系管理员!"); } String institutionID = WebConfigurationManager.AppSettings["PayOrgCode"]; // String orderNo = WebConfigurationManager.AppSettings["OrgCode"] + Convert.ToString(KeyID); 为了统一清算,作废次方法 long amount = Convert.ToInt64(price * 100); // 2.创建交易请求对象 Tx1375Request tx1375Request = new Tx1375Request(); tx1375Request.setInstitutionID(institutionID); tx1375Request.setOrderNo(orderNo); tx1375Request.setPaymentNo(new Hi.BLL.PAY_Payment().GetModel(payid).guid); tx1375Request.setTxSNBinding(WebConfigurationManager.AppSettings["OrgCode"] + Convert.ToString(hidFastPay)); tx1375Request.setAmount(amount); tx1375Request.setRemark("快捷支付发送短信".ToString()); // 3.执行报文处理 tx1375Request.process(); TxMessenger txMessenger = new TxMessenger(); String[] respMsg = txMessenger.send(tx1375Request.getRequestMessage(), tx1375Request.getRequestSignature()); Tx1375Response tx1375Response = new Tx1375Response(respMsg[0], respMsg[1]); try { Hi.Model.PAY_RegisterLog regM = new Hi.BLL.PAY_RegisterLog().GetModel(regid); regM.PlanMessage = tx1375Request.getRequestPlainText(); regM.Start = tx1375Response.getCode(); regM.ResultMessage = tx1375Response.getMessage(); new Hi.BLL.PAY_RegisterLog().Update(regM); } catch { } if (!"2000".Equals(tx1375Response.getCode())) { //JScript.AlertMsg(this, tx1375Response.getMessage()); ClientScript.RegisterStartupScript(this.GetType(), "payTx1375", "<script>$('#lblErr').html('" + tx1375Response.getMessage() + "!');</script>"); return; } } else { try { Hi.Model.PAY_RegisterLog regM = new Hi.BLL.PAY_RegisterLog().GetModel(regid); regM.PlanMessage = ""; regM.Start = "2000"; regM.ResultMessage = "OK."; new Hi.BLL.PAY_RegisterLog().Update(regM); } catch { } } ClientScript.RegisterStartupScript(this.GetType(), "pay", "<script>$('.opacity').fadeIn(200);$('.tip').fadeIn(200);$('#paying').hide();$('#txtPhoneNum').show();$('#txtPhoneNum').select();$('#msgtwo').hide();$('#msgone').show();msgTime(120);</script>"); return; } catch (Exception ex) { //JScript.AlertMsg(this, ex.Message); ClientScript.RegisterStartupScript(this.GetType(), "payTx1375", "<script>$('#lblErr').html('" + ex.Message + "!');</script>"); return; } }
/// <summary> /// 中金聚合支付(微信支付宝支付) /// </summary> /// <param name="paytype">类型(10=微信扫码支付 20=支付宝扫码支付)</param> /// <param name="KeyID">支付订单id</param> /// <param name="payPrice">本次支付金额</param> /// <returns></returns> public static string[] tx1401(string paytype, string KeyID, decimal payPrice) { string imageUrl = string.Empty; bool fal = false; Hi.Model.DIS_Order OrderModel = new Hi.BLL.DIS_Order().GetModel(Convert.ToInt32(KeyID)); Hi.Model.BD_Distributor disModel = new Hi.BLL.BD_Distributor().GetModel(OrderModel.DisID); #region 计算支付手续费 start string sxfsq = "-1"; decimal sxf = 0; decimal comp_sxf = 0; //收费方是厂商是,为了不改变支付金额,故声明此变量来记录,厂商手续费。 // 获取手续费 begin string[] Json = Common.GetAli_Sxf(disModel.CompID, payPrice); string strMsg = Json[2].ToString(); if (!string.IsNullOrEmpty(strMsg)) { return(new string[] { "false", strMsg }); //"{\"sxf\":\"" + sxf + "\",\"sxfsq\":\"" + sxfsq + "\",\"strMsg\":\"" + str + "\"}"; } else { sxfsq = Json[1].ToString(); sxf = Convert.ToDecimal(Json[0]); comp_sxf = Convert.ToDecimal(Json[3]); } // 获取手续费 end //支付总金额(含手续费) decimal UNIT = 0.01M; payPrice = payPrice + Common.Round(sxf, UNIT); #endregion 计算支付手续费 end int payid = 0; int regid = 0; Hi.Model.PAY_Payment payModel = new Hi.Model.PAY_Payment(); string orderNo = WebConfigurationManager.AppSettings["OrgCode"] + DateTime.Now.ToString("yyyyMMdd");//支付订单号前半部分 string guid = Guid.NewGuid().ToString().Replace("-", ""); payModel.OrderID = OrderModel.ID; payModel.DisID = OrderModel.DisID; payModel.Type = Convert.ToInt32(WebConfigurationManager.AppSettings["IsDBPay"]); payModel.PayUser = disModel.DisName; payModel.PayPrice = payPrice; payModel.IsAudit = 2; payModel.guid = Common.Number_repeat(guid); payModel.vdef3 = "1";//1,订单支付,2,预付款充值、汇款 payModel.vdef4 = orderNo; payModel.CreateDate = DateTime.Now; payModel.CreateUserID = OrderModel.CreateUserID; payModel.ts = DateTime.Now; payModel.modifyuser = OrderModel.CreateUserID; payModel.Channel = paytype.Equals("10") ? "7" : "6"; //(微信支付6,支付宝7) payModel.State = Convert.ToInt32(sxfsq); //手续费收取方 if (sxfsq.Equals("2")) { payModel.vdef5 = comp_sxf.ToString("0.00"); } else { payModel.vdef5 = sxf.ToString("0.00");//支付手续费 } payid = new Hi.BLL.PAY_Payment().Add(payModel); //插入日志表 Hi.Model.PAY_RegisterLog regModel = new Hi.Model.PAY_RegisterLog(); regModel.OrderId = OrderModel.ID; regModel.Ordercode = orderNo;// orderNo + payid.ToString(); regModel.number = payModel.guid; regModel.Price = payPrice; regModel.Payuse = "订单支付"; regModel.PayName = disModel.DisName; regModel.DisID = OrderModel.DisID; regModel.PayTime = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"); regModel.Remark = OrderModel.Remark; regModel.DisName = new Hi.BLL.BD_Company().GetModel(OrderModel.CompID).CompName; regModel.BankID = paytype; regModel.CreateUser = OrderModel.CreateUserID; regModel.CreateDate = DateTime.Now; regModel.LogType = 1401; regid = new Hi.BLL.PAY_RegisterLog().Add(regModel); if (payid <= 0 || regid <= 0) { return(new string[] { "false", "数据有误" }); } string configPath = WebConfigurationManager.AppSettings["payment.config.path"]; try { PaymentEnvironment.Initialize(configPath); } catch (Exception ex) { return(new string[] { "false", "支付配置有误,请联系系统管理员" }); } String institutionID = WebConfigurationManager.AppSettings["PayOrgCode"];//机构代码 string GoodsName = string.Empty; DataTable l = new Hi.BLL.DIS_OrderDetail().GetOrderDe("", " IsNUll(o.dr,0)=0 and o.OrderId=" + KeyID); foreach (DataRow dr in l.Rows) { GoodsName += dr["GoodsName"] + ","; } if (GoodsName.Length > 15) { GoodsName = GoodsName.Substring(0, 10) + "..."; } // 1.取得参数 int paymentWay = Convert.ToInt32(paytype); String expirePeriod = "5";//默认是五分钟 String subject = GoodsName; String productID = KeyID.ToString(); String goodsTag = ""; String remark = ""; String notificationURL = HttpContext.Current.Request.Url.Scheme + "://" + HttpContext.Current.Request.Url.Host + ":" + HttpContext.Current.Request.Url.Port + "/Distributor/Pay/ReceiveNoticeAlipay.aspx"; int limitPay = 10; long amount = Convert.ToInt64(payPrice * 100);//支付金额(单位:分) long discountAmount = 0; // 2.创建交易请求对象 Tx1401Request tx1401Request = new Tx1401Request(); tx1401Request.setInstitutionID(institutionID); tx1401Request.setOrderNo(orderNo); tx1401Request.setPaymentNo(payModel.guid); tx1401Request.setPaymentWay(paymentWay); tx1401Request.setAmount(amount); tx1401Request.setExpirePeriod(expirePeriod); tx1401Request.setSubject(subject); tx1401Request.setDiscountAmount(discountAmount); tx1401Request.setProductID(productID); tx1401Request.setGoodsTag(goodsTag); tx1401Request.setRemark(remark); tx1401Request.setNotificationURL(notificationURL); tx1401Request.setLimitPay(limitPay); // 3.执行报文处理 tx1401Request.process(); //2个信息参数 HttpContext.Current.Items["txCode"] = "1401"; HttpContext.Current.Items["txName"] = "市场订单聚合支付"; // 与支付平台进行通讯 TxMessenger txMessenger = new TxMessenger(); String[] respMsg = txMessenger.send(tx1401Request.getRequestMessage(), tx1401Request.getRequestSignature());// 0:message; 1:signature String plaintext = XmlUtil.formatXmlString(Encoding.UTF8.GetString(Convert.FromBase64String(respMsg[0]))); //Console.WriteLine("[message] = [" + respMsg[0] + "]"); //Console.WriteLine("[signature] = [" + respMsg[1] + "]"); //Console.WriteLine("[plaintext] = [" + plaintext + "]"); Tx1401Response tx1401Response = new Tx1401Response(respMsg[0], respMsg[1]); HttpContext.Current.Items["plainText"] = tx1401Response.getResponsePlainText(); if ("2000".Equals(tx1401Response.getCode())) { //图片URL imageUrl = tx1401Response.getImageUrl(); //二维码代码 string codeUrl = tx1401Response.getCodeUrl(); //处理业务 fal = true; } return(new string[] { fal.ToString(), imageUrl, payModel.guid }); }
protected void Page_Load(object sender, EventArgs e) { SortedDictionary <string, string> sPara = GetRequestPost(); Common.CatchInfo("调用成功", sPara.ToString()); if (sPara.Count > 0)//判断是否有带返回参数 { //Notify aliNotify = new Notify(); Notify aliNotify = new Notify(); bool verifyResult = aliNotify.Verify(sPara, Request.Form["notify_id"], Request.Form["sign"]); if (verifyResult)//验证成功 { ///////////////////////////////////////////////////////////////////////////////////////////////////////////// //请在这里加上商户的业务逻辑程序代码 //——请根据您的业务逻辑来编写程序(以下代码仅作参考)—— //获取支付宝的通知返回参数,可参考技术文档中服务器异步通知参数列表 //商户订单号 string out_trade_no = Request.Form["out_trade_no"]; //支付宝交易号 string trade_no = Request.Form["trade_no"]; //交易状态 string trade_status = Request.Form["trade_status"]; //买家账号 string buyer_email = Request.Form["buyer_email"]; //支付金额 string price = Request.Form["total_fee"]; if (Request.Form["trade_status"] == "TRADE_FINISHED" || Request.Form["trade_status"] == "TRADE_SUCCESS") { //判断该笔订单是否在商户网站中已经做过处理 //如果没有做过处理,根据订单号(out_trade_no)在商户网站的订单系统中查到该笔订单的详细,并执行商户的业务程序 //如果有做过处理,不执行商户的业务程序 string strWhere2 = string.Empty; if (out_trade_no != "") { strWhere2 += " number = '" + out_trade_no + "'"; } Hi.Model.PAY_RegisterLog regM = new Hi.Model.PAY_RegisterLog(); List <Hi.Model.PAY_RegisterLog> regL = new Hi.BLL.PAY_RegisterLog().GetList("", strWhere2, ""); if (regL == null || regL.Count <= 0) { //response.Redirect("../Distributor/Pay/Error.aspx?msg=未找到对应的支付记录!", false); //return; Console.WriteLine("未找到对应的支付记录!"); } regM = regL[0]; string strWhere = string.Empty; if (out_trade_no != "") { strWhere += " guid = '" + out_trade_no + "'"; } strWhere += " and isnull(dr,0)=0"; Hi.Model.PAY_Payment payM = new Hi.Model.PAY_Payment(); List <Hi.Model.PAY_Payment> payL = new Hi.BLL.PAY_Payment().GetList("", strWhere, ""); if (payL == null || payL.Count <= 0) { //response.Redirect("../Distributor/Pay/Error.aspx?msg=未找到对应的支付记录!", false); // return; Console.WriteLine("未找到对应的支付记录!"); } payM = payL[0]; payM.PayDate = DateTime.Now; payM.ts = DateTime.Now; payM.status = trade_status == "TRADE_FINISHED" ? 80 : 90; new Hi.BLL.PAY_Payment().Update(payM); regM.Start = trade_status; new Hi.BLL.PAY_RegisterLog().Update(regM); if (payM.IsAudit == 1) { Console.WriteLine("该支付记录状态已经修改成功,请不要重复操作!"); } //!!!支付成功 !!! decimal prepayPrice = 0; //企业钱包充值 Hi.Model.PAY_PrePayment prepayMnew = new Hi.Model.PAY_PrePayment(); string strWhere3 = string.Empty; if (out_trade_no != "") { strWhere3 += " ID = " + payM.OrderID; } strWhere3 += " and isnull(dr,0)=0"; List <Hi.Model.PAY_PrePayment> plist = new Hi.BLL.PAY_PrePayment().GetList("", strWhere3, ""); if (plist.Count > 0) { prepayMnew = plist[0]; } //订单 Hi.Model.DIS_Order orderModel = new Hi.BLL.DIS_Order().GetModel(payM.OrderID); if (orderModel != null) { string strWhere1 = string.Empty; strWhere1 += " vdef4 = '" + payM.ID + "'"; strWhere1 += " and isnull(dr,0)=0"; Hi.Model.PAY_PrePayment prepayM = new Hi.Model.PAY_PrePayment(); List <Hi.Model.PAY_PrePayment> prepayL = new Hi.BLL.PAY_PrePayment().GetList("", strWhere1, ""); if (prepayL != null && prepayL.Count > 0) { prepayM = prepayL[0]; prepayPrice = prepayM.price * -1; } int order = 0; int prepay = 0; int pay = 0; decimal prices = Convert.ToDecimal(price); SqlConnection con = new SqlConnection(LocalSqlServer); con.Open(); SqlTransaction sqlTrans = con.BeginTransaction(); try { order = new Hi.BLL.DIS_Order().UpdateOrderPstate(con, orderModel.ID, payM.PayPrice + prepayPrice - Convert.ToDecimal(payM.vdef5), sqlTrans); pay = new Hi.BLL.PAY_Payment().updatePayState(con, payM.ID, sqlTrans); if (prepayPrice > 0) { prepay = new Hi.BLL.PAY_PrePayment().updatePrepayState(con, prepayM.ID, sqlTrans); } else { prepay = 1; } sqlTrans.Commit(); } catch { order = 0; prepay = 0; pay = 0; sqlTrans.Rollback(); } finally { con.Close(); } if (order <= 0 || prepay <= 0 || pay <= 0) { Console.WriteLine("支付成功,但修改支付状态失败,请联系系统管理员,勿重复操作!"); } try { //new Common().GetWxService("2", orderModel.ID.ToString(), "1"); if (orderModel.Otype != 9) { Common.AddIntegral(orderModel.CompID, orderModel.DisID, "1", 1, orderModel.ID, (prepayPrice + prices), "订单支付", "", orderModel.CreateUserID); } } catch { } if (orderModel.Otype == (int)Enums.OType.推送账单) { Common.AddSysBusinessLog(orderModel.CompID, "Order", orderModel.ID.ToString(), "账单支付", "支付:" + (prepayPrice + prices).ToString("0.00") + "元(支付宝支付" + prices.ToString("0.00") + (prepayM.ID > 0 ? "+企业钱包支付" + prepayPrice.ToString("0.00") : "") + "【含手续费" + Convert.ToDecimal(payM.vdef5).ToString("0.00") + "元】)", payM.CreateUserID.ToString()); } else { Common.AddSysBusinessLog(orderModel.CompID, "Order", orderModel.ID.ToString(), "订单支付", "支付:" + (prepayPrice + prices).ToString("0.00") + "元(支付宝支付" + prices.ToString("0.00") + (prepayM.ID > 0 ? "+企业钱包支付" + prepayPrice.ToString("0.00") : "") + "【含手续费" + Convert.ToDecimal(payM.vdef5).ToString("0.00") + "元】)", payM.CreateUserID.ToString()); } //微信和安卓消息推送 try { MsgSend.Jpushdega jpushdega = new MsgSend.Jpushdega(new MsgSend().GetWxService); jpushdega.BeginInvoke("2", orderModel.ID.ToString(), "1", prepayPrice + prices, null, null); //new MsgSend().GetWxService("2", orderModel.ID.ToString(), "1", prepayPrice + prices); } catch { } //Response.Write("success"); //请不要修改或删除 //打印页面 //Response.Write("支付成功<br />"); Response.Write("success"); //请不要修改或删除 }//钱包充值 else if (prepayMnew != null) { int prepay = 0; int pay = 0; SqlConnection con = new SqlConnection(LocalSqlServer); con.Open(); SqlTransaction sqlTrans = con.BeginTransaction(); try { pay = new Hi.BLL.PAY_Payment().updatePayState(con, payM.ID, sqlTrans); prepay = new Hi.BLL.PAY_PrePayment().updatePrepayState(con, prepayMnew.ID, sqlTrans); sqlTrans.Commit(); } catch { pay = 0; prepay = 0; sqlTrans.Rollback(); } finally { con.Close(); } } else { //response.Redirect("../Distributor/Pay/Error.aspx?msg=未找到该支付订单!", false); //return; Console.WriteLine("未找到该支付记录!"); } } ///////////////////////////////////////////////////////////////////////////////////////////////////////////// } else//验证失败 { Response.Write("fail"); } } //else //{ // Response.Write("无通知参数"); // Response.Redirect("ErrorPay.aspx?type=2&OrderCode=" + Request.QueryString["out_trade_no"]); //} }
/// <summary> /// 订单支付 /// </summary> /// <param name="orderid">订单ID</param> /// <param name="txtPayOrder">支付金额</param> /// <param name="price">企业钱包金额</param> /// <param name="yfk">预付款</param> /// <param name="payPas"></param> public Wxpay_Url PayOrder(int orderid, decimal txtPayOrder, decimal price, int yfk, string payPas) { //使用企业钱包 serviceOrder = new Hi.BLL.Pay_Service().GetModel(orderid); #region 界面上显示 this.lblOrderNO.InnerText = serviceOrder.ID.ToString();; this.fee.InnerText = "医伴金服";//收款方 #endregion 界面上显示 decimal payPrice = serviceOrder.Price;//支付金额 #region 插入支付表记录 Hi.Model.PAY_Payment payModel = new Hi.Model.PAY_Payment(); string orderNo = WebConfigurationManager.AppSettings["OrgCode"] + DateTime.Now.ToString("yyyyMMdd");//支付订单号前半部分 string guid = Guid.NewGuid().ToString().Replace("-", ""); payModel.OrderID = serviceOrder.ID; // orderid; payModel.DisID = 0; payModel.Type = 0; // isDBPay; payModel.PayUser = this.CompName; payModel.PayPrice = payPrice; payModel.IsAudit = 2; payModel.guid = Common.Number_repeat(guid); payModel.vdef3 = "3"; //1,订单支付,2,预付款充值、汇款 3购买服务 payModel.vdef4 = orderNo; payModel.CreateDate = DateTime.Now; payModel.CreateUserID = this.UserID; payModel.ts = DateTime.Now; payModel.modifyuser = this.UserID; payModel.PrintNum = 1; //支付宝支付无需结算 //判断账户类型,判断支付渠道 payModel.Channel = "7"; //1,快捷支付,2,银联支付 ,3,网银支付,4,B2B网银支付,5,线下支付,6,支付宝支付 7,微信支付 payModel.State = 0; //手续费收取方 payModel.vdef5 = "0.00"; //支付手续费 payid = new Hi.BLL.PAY_Payment().Add(payModel); //if (prepayid > 0) //{ // Hi.Model.PAY_PrePayment prepayMent = new Hi.BLL.PAY_PrePayment().GetModel(prepayid); // prepayMent.vdef4 = payid.ToString();//与企业钱包关联 // new Hi.BLL.PAY_PrePayment().Update(prepayMent); //} Hi.Model.PAY_RegisterLog regModel = new Hi.Model.PAY_RegisterLog(); regModel.OrderId = serviceOrder.ID;// orderid; regModel.Ordercode = orderNo + payid.ToString(); regModel.number = payModel.guid; regModel.Price = payPrice; regModel.Payuse = "订单支付"; regModel.PayName = this.CompName; regModel.DisID = 0; regModel.PayTime = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"); regModel.Remark = "厂商购买服务";// orderModel.Remark; regModel.DisName = this.CompName; regModel.BankID = "微信支付"; regModel.CreateUser = this.UserID; regModel.CreateDate = DateTime.Now; regModel.LogType = 1311; int regid = new Hi.BLL.PAY_RegisterLog().Add(regModel); serviceOrder.IsAudit = 1; serviceOrder.PayedPrice = payPrice; bool serid = new Hi.BLL.Pay_Service().Update(serviceOrder); if (payid <= 0 || regid <= 0 || !serid) { Response.Redirect("Error.aspx", false); } ; #endregion int amount = Convert.ToInt32(payPrice * 100);//支付金额(单位:分) //隐藏域赋值 this.hidguid.Value = payModel.guid; this.hidprice.Value = payPrice.ToString(); this.hidordid.Value = payModel.OrderID.ToString(); this.hidpid.Value = payid.ToString(); this.hidppid.Value = prepayid.ToString(); // btnWxPay_Click(payModel.guid, orderid.ToString(), amount); Wxpay_Url wxpaymodel = new Wxpay_Url(); wxpaymodel.Guid = payModel.guid; wxpaymodel.OrderID = orderid.ToString(); wxpaymodel.Amount = amount; wxpaymodel.Hidguid = payModel.guid; wxpaymodel.Hidprice = payModel.PayPrice.ToString(); wxpaymodel.Hidordid = payModel.OrderID.ToString(); wxpaymodel.Hidpid = payid.ToString(); wxpaymodel.Hidppid = prepayid.ToString(); return(wxpaymodel); }
protected void Page_Load(object sender, EventArgs e) { //ResultNotify resultNotify = new ResultNotify(this); //resultNotify.ProcessNotify(); string resultFromWx = getPostStr(); //设置支付参数 var res = XDocument.Parse(resultFromWx); string return_code = res.Element("xml").Element("return_code").Value; string out_trade_no = res.Element("xml").Element("out_trade_no").Value; string result_code = res.Element("xml").Element("result_code").Value; string price = res.Element("xml").Element("total_fee").Value; ///////////////////////////////////////////////////////////////////////////////////////////////////////////// //请在这里加上商户的业务逻辑程序代码 //——请根据您的业务逻辑来编写程序(以下代码仅作参考)—— //获取支付宝的通知返回参数,可参考技术文档中服务器异步通知参数列表 if (return_code == "SUCCESS" || result_code == "SUCCESS") { //判断该笔订单是否在商户网站中已经做过处理 //如果没有做过处理,根据订单号(out_trade_no)在商户网站的订单系统中查到该笔订单的详细,并执行商户的业务程序 //如果有做过处理,不执行商户的业务程序 string strWhere2 = string.Empty; if (out_trade_no != "") { strWhere2 += " number = '" + out_trade_no + "'"; } Hi.Model.PAY_RegisterLog regM = new Hi.Model.PAY_RegisterLog(); List <Hi.Model.PAY_RegisterLog> regL = new Hi.BLL.PAY_RegisterLog().GetList("", strWhere2, ""); if (regL == null || regL.Count <= 0) { //response.Redirect("../Distributor/Pay/Error.aspx?msg=未找到对应的支付记录!", false); //return; Console.WriteLine("未找到对应的支付记录!"); } regM = regL[0]; string strWhere = string.Empty; if (out_trade_no != "") { strWhere += " guid = '" + out_trade_no + "'"; } strWhere += " and isnull(dr,0)=0"; Hi.Model.PAY_Payment payM = new Hi.Model.PAY_Payment(); List <Hi.Model.PAY_Payment> payL = new Hi.BLL.PAY_Payment().GetList("", strWhere, ""); if (payL == null || payL.Count <= 0) { //response.Redirect("../Distributor/Pay/Error.aspx?msg=未找到对应的支付记录!", false); // return; Console.WriteLine("未找到对应的支付记录!"); } payM = payL[0]; payM.PayDate = DateTime.Now; payM.ts = DateTime.Now; payM.status = 0; //trade_status == "TRADE_FINISHED" ? 80 : 90; new Hi.BLL.PAY_Payment().Update(payM); regM.Start = ""; // trade_status; new Hi.BLL.PAY_RegisterLog().Update(regM); if (payM.IsAudit == 2) //该支付记录未修改成功进入,修改成功就不进入,请不要重复操作 { //!!!支付成功 !!! decimal prepayPrice = 0; //企业钱包充值 Hi.Model.PAY_PrePayment prepayMnew = new Hi.Model.PAY_PrePayment(); string strWhere3 = string.Empty; if (out_trade_no != "") { strWhere3 += " ID = " + payM.OrderID; } strWhere3 += " and isnull(dr,0)=0"; List <Hi.Model.PAY_PrePayment> plist = new Hi.BLL.PAY_PrePayment().GetList("", strWhere3, ""); if (plist.Count > 0) { prepayMnew = plist[0]; } //订单 Hi.Model.DIS_Order orderModel = new Hi.BLL.DIS_Order().GetModel(payM.OrderID); if (orderModel != null) { string strWhere1 = string.Empty; strWhere1 += " vdef4 = '" + payM.ID + "'"; strWhere1 += " and isnull(dr,0)=0"; Hi.Model.PAY_PrePayment prepayM = new Hi.Model.PAY_PrePayment(); List <Hi.Model.PAY_PrePayment> prepayL = new Hi.BLL.PAY_PrePayment().GetList("", strWhere1, ""); if (prepayL != null && prepayL.Count > 0) { prepayM = prepayL[0]; prepayPrice = prepayM.price * -1; } int order = 0; int prepay = 0; int pay = 0; decimal prices = Convert.ToDecimal(price); SqlConnection con = new SqlConnection(LocalSqlServer); con.Open(); SqlTransaction sqlTrans = con.BeginTransaction(); try { order = new Hi.BLL.DIS_Order().UpdateOrderPstate(con, orderModel.ID, payM.PayPrice + prepayPrice - Convert.ToDecimal(payM.vdef5), sqlTrans); pay = new Hi.BLL.PAY_Payment().updatePayState(con, payM.ID, sqlTrans); if (prepayPrice > 0) { prepay = new Hi.BLL.PAY_PrePayment().updatePrepayState(con, prepayM.ID, sqlTrans); } else { prepay = 1; } sqlTrans.Commit(); } catch { order = 0; prepay = 0; pay = 0; sqlTrans.Rollback(); } finally { con.Close(); } if (order <= 0 || prepay <= 0 || pay <= 0) { Console.WriteLine("支付成功,但修改支付状态失败,请联系系统管理员,勿重复操作!"); } try { //new Common().GetWxService("2", orderModel.ID.ToString(), "1"); if (orderModel.Otype != 9) { OrderInfoType.AddIntegral(orderModel.CompID, orderModel.DisID, "1", 1, orderModel.ID, (prepayPrice + prices), "订单支付", "", orderModel.CreateUserID); } } catch { } if (orderModel.Otype == (int)Enums.OType.推送账单) { Utils.AddSysBusinessLog(orderModel.CompID, "Order", orderModel.ID.ToString(), "账单支付", "支付:" + (prepayPrice + prices).ToString("0.00") + "元(微信支付" + prices.ToString("0.00") + (prepayM.ID > 0 ? "+企业钱包支付" + prepayPrice.ToString("0.00") : "") + "【含手续费" + Convert.ToDecimal(payM.vdef5).ToString("0.00") + "元】)", payM.CreateUserID.ToString()); } else { Utils.AddSysBusinessLog(orderModel.CompID, "Order", orderModel.ID.ToString(), "订单支付", "支付:" + (prepayPrice + prices).ToString("0.00") + "元(微信支付" + prices.ToString("0.00") + (prepayM.ID > 0 ? "+企业钱包支付" + prepayPrice.ToString("0.00") : "") + "【含手续费" + Convert.ToDecimal(payM.vdef5).ToString("0.00") + "元】)", payM.CreateUserID.ToString()); } //微信和安卓消息推送 try { new Common().GetWxService("2", orderModel.ID.ToString(), "1", prepayPrice + prices); } catch { } Response.Write("success"); //请不要修改或删除 }//钱包充值 else if (prepayMnew != null) { int prepay = 0; int pay = 0; SqlConnection con = new SqlConnection(LocalSqlServer); con.Open(); SqlTransaction sqlTrans = con.BeginTransaction(); try { pay = new Hi.BLL.PAY_Payment().updatePayState(con, payM.ID, sqlTrans); prepay = new Hi.BLL.PAY_PrePayment().updatePrepayState(con, prepayMnew.ID, sqlTrans); sqlTrans.Commit(); } catch { pay = 0; prepay = 0; sqlTrans.Rollback(); } finally { con.Close(); } } else { //response.Redirect("../Distributor/Pay/Error.aspx?msg=未找到该支付订单!", false); //return; Console.WriteLine("未找到该支付记录!"); } } else { Console.WriteLine("success"); } Response.Write("success"); } else//验证失败 { Response.Write("fail"); } }
protected void Page_Load(object sender, EventArgs e) { //this.lblMsg.InnerText = Request["msg"]; LogManager.LogFielPrefix = "jsnx"; LogManager.LogPath = "C:/requestpag/"; LogManager.WriteLog(LogFile.Trace.ToString(), "时间:" + DateTime.Now.ToString("yyyy-MMdd HH:mm:ss") + "\r\n" + "进入回调页面"); SortedDictionary <string, string> sPara = GetRequestPost(); try { if (sPara == null || sPara.Count <= 0) { Response.Write("无通知参数"); LogManager.WriteLog(LogFile.Trace.ToString(), "时间:" + DateTime.Now.ToString("yyyy-MMdd HH:mm:ss") + "\r\n" + "退出回调页面\r\nError:无通知参数"); return; } Notify aliNotify = new Notify(); bool verifyResult = aliNotify.Verify(sPara, Request.Form["notify_id"], Request.Form["sign"]); if (!verifyResult)//验证失败 { Response.Write("fail"); LogManager.WriteLog(LogFile.Trace.ToString(), "时间:" + DateTime.Now.ToString("yyyy-MMdd HH:mm:ss") + "\r\n" + "退出回调页面\r\nError:验证失败"); return; } //企业订单号 string out_trade_no = Common.NoHTML(Request.Form["out_trade_no"]); //支付宝交易号 string trade_no = Common.NoHTML(Request.Form["trade_no"]); //交易状态 string trade_status = Common.NoHTML(Request.Form["trade_status"]); decimal prepayPrice = 0; string guid = ""; int orderid = 0; Hi.Model.PAY_RegisterLog regM = new Hi.Model.PAY_RegisterLog(); List <Hi.Model.PAY_RegisterLog> regL = new Hi.BLL.PAY_RegisterLog().GetList("", " Ordercode = '" + out_trade_no + "'", ""); if (regL == null || regL.Count <= 0) { Response.Write("找不到" + out_trade_no); LogManager.WriteLog(LogFile.Trace.ToString(), "时间:" + DateTime.Now.ToString("yyyy-MMdd HH:mm:ss") + "\r\n" + "退出回调页面\r\nError:找不到" + out_trade_no); return; } regM = regL[0]; try { regM.Start = trade_status; regM.ResultMessage = trade_no; new Hi.BLL.PAY_RegisterLog().Update(regM); } catch { } guid = regM.number; orderid = regM.OrderId; Hi.Model.DIS_Order orderModel = new Hi.BLL.DIS_Order().GetModel(orderid); Hi.Model.PAY_Payment payM = new Hi.Model.PAY_Payment(); List <Hi.Model.PAY_Payment> payL = new Hi.BLL.PAY_Payment().GetList("", " guid = '" + guid + "' ", ""); if (payL == null || payL.Count <= 0) { Response.Write("找不到" + out_trade_no); LogManager.WriteLog(LogFile.Trace.ToString(), "时间:" + DateTime.Now.ToString("yyyy-MMdd HH:mm:ss") + "\r\n" + "退出回调页面\r\nError:找不到" + out_trade_no); return; } payM = payL[0]; if (payM.IsAudit == 1) { Response.Write("success");//请不要修改或删除,输出success后,支付宝将不再发送通知 LogManager.WriteLog(LogFile.Trace.ToString(), "时间:" + DateTime.Now.ToString("yyyy-MMdd HH:mm:ss") + "\r\n" + "退出回调页面\r\n支付成功\r\n支付订单号:" + out_trade_no); return; } if (trade_status != "TRADE_SUCCESS") { Response.Write(GetTradeStatusByName(trade_status)); LogManager.WriteLog(LogFile.Trace.ToString(), "时间:" + DateTime.Now.ToString("yyyy-MMdd HH:mm:ss") + "\r\n" + "退出回调页面\r\nError:" + GetTradeStatusByName(trade_status) + "\r\n支付订单号:" + out_trade_no); return; } Hi.Model.PAY_PrePayment prepayM = new Hi.Model.PAY_PrePayment(); List <Hi.Model.PAY_PrePayment> prepayL = new Hi.BLL.PAY_PrePayment().GetList("", " vdef4 = '" + payM.ID + "' ", ""); if (prepayL != null && prepayL.Count > 0) { prepayM = prepayL[0]; prepayPrice = prepayM.price * -1; } int order = 0; int prepay = 0; int pay = 0; SqlConnection con = new SqlConnection(LocalSqlServer); con.Open(); SqlTransaction sqlTrans = con.BeginTransaction(); try { order = new Hi.BLL.DIS_Order().UpdateOrderPstate(con, orderid, payM.PayPrice + prepayPrice, sqlTrans); pay = new Hi.BLL.PAY_Payment().updatePayState(con, payM.ID, sqlTrans); if (prepayPrice > 0) { prepay = new Hi.BLL.PAY_PrePayment().updatePrepayState(con, prepayM.ID, sqlTrans); } else { prepay = 1; } sqlTrans.Commit(); } catch (Exception ex) { Response.Write("Error"); LogManager.WriteLog(LogFile.Trace.ToString(), "时间:" + DateTime.Now.ToString("yyyy-MMdd HH:mm:ss") + "\r\n" + "退出回调页面\r\nError:" + ex.Message + "\r\n支付订单号:" + out_trade_no); order = 0; prepay = 0; pay = 0; sqlTrans.Rollback(); } finally { con.Close(); } if (order <= 0 || prepay <= 0 || pay <= 0) { Response.Write("Error"); LogManager.WriteLog(LogFile.Trace.ToString(), "时间:" + DateTime.Now.ToString("yyyy-MMdd HH:mm:ss") + "\r\n" + "退出回调页面\r\nError:支付成功,修改状态失败,等待下次页面通知\r\n支付订单号:" + out_trade_no); return; } try { new Common().GetWxService("2", orderModel.ID.ToString(), "1"); if (orderModel.Otype != 9) { OrderInfoType.AddIntegral(orderModel.CompID, orderModel.DisID, "1", 1, orderModel.ID, (prepayPrice + payM.PayPrice), "订单支付", "", orderModel.CreateUserID); } } catch { } if (orderModel.Otype == (int)Enums.OType.推送账单) { Utils.AddSysBusinessLog(orderModel.CompID, "Order", orderModel.ID.ToString(), "账单支付", "支付:" + (prepayPrice + payM.PayPrice).ToString("0.00") + "元(支付宝支付)", payM.CreateUserID.ToString()); } else { Utils.AddSysBusinessLog(orderModel.CompID, "Order", orderModel.ID.ToString(), "订单支付", "支付:" + (prepayPrice + payM.PayPrice).ToString("0.00") + "元(支付宝支付)", payM.CreateUserID.ToString()); } Response.Write("success"); //请不要修改或删除,输出success后,支付宝将不再发送通知 LogManager.WriteLog(LogFile.Trace.ToString(), "时间:" + DateTime.Now.ToString("yyyy-MMdd HH:mm:ss") + "\r\n" + "退出回调页面\r\n支付成功\r\n支付订单号:" + out_trade_no); return; } catch (Exception ex) { LogManager.LogFielPrefix = "requestpag"; LogManager.LogPath = "C:/requestpag/"; LogManager.WriteLog(LogFile.Error.ToString(), "Error:" + ex.Message + "\r\n"); Response.Write(ex.Message); return; } finally { Response.End(); } }
public void tx1311() { Hi.Model.PAY_Payment payModel = new Hi.Model.PAY_Payment(); Hi.Model.PAY_RegisterLog regModel = new Hi.Model.PAY_RegisterLog(); try { //账户类型 string AccountType = Request["AccountType"]; int accountType = Convert.ToInt32(AccountType); //银行编码 string bankid = this.hidBank.Value; Hi.Model.PAY_PrePayment prepayM = new Hi.BLL.PAY_PrePayment().GetModel(KeyID); decimal price = prepayM.price; #region 计算支付手续费 start string sxfsq = "-1"; decimal sxf = 0; decimal comp_sxf = 0;//收费方是厂商是,为了不改变支付金额,故声明此变量来记录,厂商手续费。 // 获取手续费 begin string[] Json = Common.GetSxf(this.CompID, AccountType, bankid, price); string strMsg = Json[2].ToString(); if (!string.IsNullOrEmpty(strMsg)) { ClientScript.RegisterStartupScript(this.GetType(), "payTx1375", "<script>$('#lblErr').html(' 充值金额小于支付手续费,不允许支付 !');</script>"); return; } else { sxfsq = Json[1].ToString(); sxf = Convert.ToDecimal(Json[0]); comp_sxf = Convert.ToDecimal(Json[3]); } //支付总金额(含手续费) decimal UNIT = 0.01M; price = price + Common.Round(sxf, UNIT); #endregion 计算支付手续费 end int payid = 0; int regid = 0; string orderNo = WebConfigurationManager.AppSettings["OrgCode"] + DateTime.Now.ToString("yyyyMMdd");//支付订单号前半部分 string guid = Guid.NewGuid().ToString().Replace("-", ""); payModel.OrderID = KeyID; payModel.DisID = this.DisID; payModel.PayUser = new Hi.BLL.BD_Distributor().GetModel(this.DisID).DisName; payModel.PayPrice = price; payModel.IsAudit = 2; payModel.guid = Common.Number_repeat(guid); payModel.vdef3 = "2"; payModel.vdef4 = orderNo; payModel.CreateDate = DateTime.Now; payModel.CreateUserID = this.UserID; payModel.ts = DateTime.Now; payModel.modifyuser = this.UserID; //判断账户类型,判断支付渠道,然后赋值 if (AccountType == "11") { if (bankid == "888") { payModel.Channel = "2"; } else { payModel.Channel = "3"; } }//个人贷记卡支付 else if (AccountType == "13") { payModel.Channel = "8"; } else { payModel.Channel = "4"; } payModel.State = Convert.ToInt32(sxfsq);//手续费收取方 if (sxfsq.Equals("2")) { payModel.vdef5 = comp_sxf.ToString("0.00"); } else { payModel.vdef5 = sxf.ToString("0.00");//支付手续费 } payid = new Hi.BLL.PAY_Payment().Add(payModel); regModel.OrderId = KeyID; regModel.Ordercode = WebConfigurationManager.AppSettings["OrgCode"] + Convert.ToString(KeyID); regModel.number = payModel.guid; regModel.Price = price; regModel.Payuse = prepayM.PreType == 6 ? "转账汇款" : prepayM.PreType == 1 ? "企业钱包充值" : ""; regModel.PayName = new Hi.BLL.BD_Distributor().GetModel(this.DisID).DisName; regModel.DisID = this.DisID; regModel.PayTime = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"); regModel.Remark = prepayM.vdef1; regModel.DisName = new Hi.BLL.BD_Company().GetModel(this.CompID).CompName; regModel.BankID = bankid; regModel.CreateUser = this.UserID; regModel.CreateDate = DateTime.Now; regModel.LogType = 1311; regid = new Hi.BLL.PAY_RegisterLog().Add(regModel); if (payid <= 0 || regid <= 0) { //JScript.AlertMsg(this, "数据异常!"); ClientScript.RegisterStartupScript(this.GetType(), "payTx1375", "<script>$('#lblErr').html('数据异常!');</script>"); return; } string configPath = WebConfigurationManager.AppSettings["payment.config.path"]; try { PaymentEnvironment.Initialize(configPath); } catch { //JScript.AlertMsg(this, "支付配置有误,请联系系统管理员!"); //return; throw new Exception("支付配置有误,请联系系统管理员!"); } String institutionID = WebConfigurationManager.AppSettings["PayOrgCode"]; //原来传递的支付订单号----目前订单号运行重复 //String orderNo = WebConfigurationManager.AppSettings["OrgCode"] + Convert.ToString(KeyID); long amount = Convert.ToInt64(price * 100); long fee = 0; String payerID = this.DisID.ToString(); String payerName = new Hi.BLL.BD_Distributor().GetModel(this.DisID).DisName; String usage = prepayM.PreType == 6 ? "转账汇款" : prepayM.PreType == 1 ? "企业钱包充值" : ""; String remark = prepayM.PreType == 6 ? "转账汇款" : prepayM.PreType == 1 ? "企业钱包充值" : ""; String notificationURL = string.Empty; if (WebConfigurationManager.AppSettings["PayType"] == "0") { notificationURL = Request.Url.Scheme + "://" + Request.Url.Host + ":" + Request.Url.Port + "/Handler/ReceiveNoticePage.ashx"; } else { notificationURL = "http://www.my1818.com/Handler/ReceiveNoticePage.ashx";//回调页面地址 } String payees = new Hi.BLL.BD_Company().GetModel(this.CompID).CompName; //判断支付接口 string Pay_type = WebConfigurationManager.AppSettings["PayType"]; String bankID = string.Empty; if (Pay_type == "0") { bankID = "700";//bankid;// } else { bankID = bankid; } // 2.创建交易请求对象 Tx1311Request tx1311Request = new Tx1311Request(); tx1311Request.setInstitutionID(institutionID); //机构号码 tx1311Request.setOrderNo(orderNo); //转账流水号 tx1311Request.setPaymentNo(payModel.guid); //支付交易流水号 tx1311Request.setAmount(amount); //支付金额 单位分 tx1311Request.setFee(fee); //支付服务手续费 单位分 tx1311Request.setPayerID(""); //付款人注册ID tx1311Request.setPayerName(""); //付款方名称 tx1311Request.setUsage(usage); //资金用途 tx1311Request.setRemark(remark); //备注 tx1311Request.setNotificationURL(notificationURL); //机构接收支付通知的URL tx1311Request.addPayee(""); //收款方名称 tx1311Request.setBankID(bankID); //付款银行标识 if (accountType == 13) { tx1311Request.setAccountType(11); //付款方帐号类型 tx1311Request.setCardType("02"); //银行卡类型(01=借记卡、02=贷记卡) } else if (accountType == 11) { tx1311Request.setAccountType(accountType); //付款方帐号类型 tx1311Request.setCardType("01"); //银行卡类型(01=借记卡、02=贷记卡) } else if (accountType == 12) { tx1311Request.setAccountType(accountType);//付款方帐号类型 } // 3.执行报文处理 tx1311Request.process(); try { Hi.Model.PAY_RegisterLog regM = new Hi.BLL.PAY_RegisterLog().GetModel(regid); regM.PlanMessage = tx1311Request.getRequestPlainText(); new Hi.BLL.PAY_RegisterLog().Update(regM); } catch { } // 4.将参数放置到request对象 // //3个交易参数 HttpContext.Current.Items["plainText"] = tx1311Request.getRequestPlainText(); HttpContext.Current.Items["message"] = tx1311Request.getRequestMessage(); HttpContext.Current.Items["signature"] = tx1311Request.getRequestSignature(); // //2个信息参数 HttpContext.Current.Items["txCode"] = "1311"; HttpContext.Current.Items["txName"] = "市场订单支付直通车"; // 1个action(支付平台地址)参数 HttpContext.Current.Items["action"] = PaymentEnvironment.PaymentURL; // 5.转向Request.jsp页面 Context.Server.Transfer("ReRequest.aspx", true); } catch (Exception ex) { ClientScript.RegisterStartupScript(this.GetType(), "payTx1375", "<script>$('#lblErr').html('" + ex.Message + "!');</script>"); return; } }