//批量删除 protected void btnDelete_Click(object sender, EventArgs e) { ChkAdminLevel("user_amount_log", DTEnums.ActionEnum.Delete.ToString()); //检查权限 int sucCount = 0; int errorCount = 0; BLL.user_amount_log bll = new BLL.user_amount_log(); for (int i = 0; i < rptList.Items.Count; i++) { int id = Convert.ToInt32(((HiddenField)rptList.Items[i].FindControl("hidId")).Value); CheckBox cb = (CheckBox)rptList.Items[i].FindControl("chkId"); if (cb.Checked) { if (bll.Delete(id)) { sucCount += 1; } else { errorCount += 1; } } } AddAdminLog(DTEnums.ActionEnum.Delete.ToString(), "删除消息记录成功" + sucCount + "条,失败" + errorCount + "条"); //记录日志 JscriptMsg("删除成功" + sucCount + "条,失败" + errorCount + "条!", Utils.CombUrlTxt("amount_log.aspx", "keywords={0}", this.keywords)); }
//批量删除 protected void btnDelete_Click(object sender, EventArgs e) { ChkAdminLevel("user_amount_log", PLEnums.ActionEnum.Delete.ToString()); //检查权限 int sucCount = 0; int errorCount = 0; BLL.user_amount_log bll = new BLL.user_amount_log(); for (int i = 0; i < rptList.Items.Count; i++) { int id = Convert.ToInt32(((HiddenField)rptList.Items[i].FindControl("hidId")).Value); CheckBox cb = (CheckBox)rptList.Items[i].FindControl("chkId"); if (cb.Checked) { if (bll.Delete(id)) { sucCount += 1; } else { errorCount += 1; } } } AddAdminLog(PLEnums.ActionEnum.Delete.ToString(), "删除消息记录成功" + sucCount + "条,失败" + errorCount + "条"); //记录日志 JscriptMsg("删除成功" + sucCount + "条,失败" + errorCount + "条!", Utils.CombUrlTxt("amount_log.aspx", "keywords={0}", this.keywords)); }
private void RptBind(string _strWhere, string _orderby) { this.page = DTRequest.GetQueryInt("page", 1); txtKeywords.Text = this.keywords; BLL.user_amount_log bll = new BLL.user_amount_log(); this.rptList.DataSource = bll.GetList(this.pageSize, this.page, _strWhere, _orderby, out this.totalCount); this.rptList.DataBind(); //绑定页码 txtPageNum.Text = this.pageSize.ToString(); string pageUrl = Utils.CombUrlTxt("amount_log.aspx", "keywords={0}&page={1}", this.keywords, "__id__"); PageContent.InnerHtml = Utils.OutPageList(this.pageSize, this.page, this.totalCount, pageUrl, 8); }
private void RptBind(string _strWhere, string _orderby) { this.page = PLRequest.GetQueryInt("page", 1); txtKeywords.Text = this.keywords; BLL.user_amount_log bll = new BLL.user_amount_log(); this.rptList.DataSource = bll.GetList(this.pageSize, this.page, _strWhere, _orderby, out this.totalCount); this.rptList.DataBind(); //绑定页码 txtPageNum.Text = this.pageSize.ToString(); string pageUrl = Utils.CombUrlTxt("amount_log.aspx", "keywords={0}&page={1}", this.keywords, "__id__"); PageContent.InnerHtml = Utils.OutPageList(this.pageSize, this.page, this.totalCount, pageUrl, 8); }
protected void Page_Load(object sender, EventArgs e) { SortedDictionary<string, string> sPara = GetRequestPost(); if (sPara.Count > 0)//判断是否有带返回参数 { Notify aliNotify = new Notify(); bool verifyResult = aliNotify.Verify(sPara, DTRequest.GetString("notify_id"), DTRequest.GetString("sign")); //写日志 //System.IO.File.AppendAllText(Utils.GetMapPath("alipaylog.txt"), "验证结果:" + verifyResult.ToString() + "\n", System.Text.Encoding.UTF8); if (verifyResult)//验证成功 { string trade_no = DTRequest.GetString("trade_no"); //支付宝交易号 string order_no = DTRequest.GetString("out_trade_no").ToUpper(); //获取订单号 string total_fee = DTRequest.GetString("total_fee"); //获取总金额 string trade_status = DTRequest.GetString("trade_status"); //交易状态 if (trade_status == "TRADE_FINISHED" || trade_status == "TRADE_SUCCESS") { if (order_no.StartsWith("R")) //充值订单 { BLL.user_amount_log bll = new BLL.user_amount_log(); Model.user_amount_log model = bll.GetModel(order_no); if (model == null) { Response.Write("该订单号不存在"); return; } if (model.status == 1) //已成功 { Response.Write("success"); return; } if (model.value != decimal.Parse(total_fee)) { Response.Write("订单金额和支付金额不相符"); return; } model.trade_no = trade_no; model.status = 1; model.complete_time = DateTime.Now; bool result = bll.Update(model); if (!result) { Response.Write("修改订单状态失败"); return; } } else if (order_no.StartsWith("B")) //商品订单 { //写日志 //System.IO.File.AppendAllText(Utils.GetMapPath("alipaylog.txt"), "商品订单\n", System.Text.Encoding.UTF8); BLL.orders bll = new BLL.orders(); Model.orders model = bll.GetModel(order_no); if (model == null) { //写日志 //System.IO.File.AppendAllText(Utils.GetMapPath("alipaylog.txt"), "订单号:" + order_no + "不存在\n", System.Text.Encoding.UTF8); Response.Write("该订单号不存在"); return; } if (model.payment_status == 2) //已付款 { //写日志 //System.IO.File.AppendAllText(Utils.GetMapPath("alipaylog.txt"), "订单号:" + order_no + "已付款\n", System.Text.Encoding.UTF8); Response.Write("success"); return; } if (model.order_amount != decimal.Parse(total_fee)) { //写日志 //System.IO.File.AppendAllText(Utils.GetMapPath("alipaylog.txt"), "订单号:" + order_no + "订单金额" + model.order_amount + "和支付金额" + total_fee + "不相符\n", System.Text.Encoding.UTF8); Response.Write("订单金额和支付金额不相符"); return; } bool result = bll.UpdateField(order_no, "trade_no='" + trade_no + "',status=2,payment_status=2,payment_time='" + DateTime.Now + "'"); if (!result) { Response.Write("修改订单状态失败"); return; } //写日志 //System.IO.File.AppendAllText(Utils.GetMapPath("alipaylog.txt"), "修改订单状态:" + result.ToString() + "\n", System.Text.Encoding.UTF8); //扣除积分 if (model.point < 0) { new BLL.user_point_log().Add(model.user_id, model.user_name, model.point, "换购扣除积分,订单号:" + model.order_no, false); } } } Response.Write("success"); //请不要修改或删除 } else//验证失败 { Response.Write("fail"); } } else { Response.Write("无通知参数"); } }
protected void Page_Load(object sender, EventArgs e) { SortedDictionary<string, string> sPara = GetRequestPost(); if (sPara.Count > 0)//判断是否有带返回参数 { Notify aliNotify = new Notify(); bool verifyResult = aliNotify.Verify(sPara, MXRequest.GetString("notify_id"), MXRequest.GetString("sign")); //写日志 //System.IO.File.AppendAllText(Utils.GetMapPath("alipaylog.txt"), "验证结果:" + verifyResult.ToString() + "\n", System.Text.Encoding.UTF8); if (verifyResult)//验证成功 { string trade_no = MXRequest.GetString("trade_no"); //支付宝交易号 string order_no = MXRequest.GetString("out_trade_no").ToUpper(); //获取订单号 string total_fee = MXRequest.GetString("total_fee"); //获取总金额 string trade_status = MXRequest.GetString("trade_status"); //交易状态 //写日志 //System.IO.File.AppendAllText(Utils.GetMapPath("alipaylog.txt"), "接口类型:" + Config.Type + "\n", System.Text.Encoding.UTF8); if (Config.Type == "1") //即时到帐接口处理方法 { //写日志 //System.IO.File.AppendAllText(Utils.GetMapPath("alipaylog.txt"), "即时到帐返回交易状态:" + trade_status + "\n", System.Text.Encoding.UTF8); if (trade_status == "TRADE_FINISHED" || trade_status == "TRADE_SUCCESS") { if (order_no.StartsWith("R")) //充值订单 { BLL.user_amount_log bll = new BLL.user_amount_log(); Model.user_amount_log model = bll.GetModel(order_no); if (model == null) { Response.Write("该订单号不存在"); return; } if (model.status == 1) //已成功 { Response.Write("success"); return; } if (model.value != decimal.Parse(total_fee)) { Response.Write("订单金额和支付金额不相符"); return; } model.trade_no = trade_no; model.status = 1; model.complete_time = DateTime.Now; bool result = bll.Update(model); if (!result) { Response.Write("修改订单状态失败"); return; } } else if (order_no.StartsWith("B")) //商品订单 { //写日志 //System.IO.File.AppendAllText(Utils.GetMapPath("alipaylog.txt"), "商品订单\n", System.Text.Encoding.UTF8); BLL.orders bll = new BLL.orders(); Model.orders model = bll.GetModel(order_no); if (model == null) { //写日志 //System.IO.File.AppendAllText(Utils.GetMapPath("alipaylog.txt"), "订单号:" + order_no + "不存在\n", System.Text.Encoding.UTF8); Response.Write("该订单号不存在"); return; } if (model.payment_status == 2) //已付款 { //写日志 //System.IO.File.AppendAllText(Utils.GetMapPath("alipaylog.txt"), "订单号:" + order_no + "已付款\n", System.Text.Encoding.UTF8); Response.Write("success"); return; } if (model.order_amount != decimal.Parse(total_fee)) { //写日志 //System.IO.File.AppendAllText(Utils.GetMapPath("alipaylog.txt"), "订单号:" + order_no + "订单金额" + model.order_amount + "和支付金额" + total_fee + "不相符\n", System.Text.Encoding.UTF8); Response.Write("订单金额和支付金额不相符"); return; } bool result = bll.UpdateField(order_no, "trade_no='" + trade_no + "',status=2,payment_status=2,payment_time='" + DateTime.Now + "'"); if (!result) { Response.Write("修改订单状态失败"); return; } //写日志 //System.IO.File.AppendAllText(Utils.GetMapPath("alipaylog.txt"), "修改订单状态:" + result.ToString() + "\n", System.Text.Encoding.UTF8); //扣除积分 if (model.point < 0) { new BLL.user_point_log().Add(model.user_id, model.user_name, model.point, "换购扣除积分,订单号:" + model.order_no, false); } } } } else //担保交易接口处理方法 { if (trade_status == "WAIT_SELLER_SEND_GOODS") //付款成功 { if (order_no.StartsWith("R")) //充值订单 { BLL.user_amount_log bll = new BLL.user_amount_log(); Model.user_amount_log model = bll.GetModel(order_no); if (model == null) { Response.Write("该订单号不存在"); return; } if (model.status == 1) //已成功 { Response.Write("success"); return; } if (model.value != decimal.Parse(total_fee)) { Response.Write("订单金额和支付金额不相符"); return; } model.trade_no = trade_no; model.status = 1; model.complete_time = DateTime.Now; bool result = bll.Update(model); if (!result) { Response.Write("修改订单状态失败"); return; } //自动发货 result = new Service().Send_goods_confirm_by_platform(trade_no, "EXPRESS", "", "DIRECT"); if (!result) { Response.Write("自动发货失败"); return; } } else if (order_no.StartsWith("B")) //商品订单 { BLL.orders bll = new BLL.orders(); Model.orders model = bll.GetModel(order_no); if (model == null) { Response.Write("该订单号不存在"); return; } if (model.payment_status == 2) //已付款 { Response.Write("success"); return; } if (model.order_amount != decimal.Parse(total_fee)) { Response.Write("订单金额和支付金额不相符"); return; } bool result = bll.UpdateField(order_no, "trade_no='" + trade_no + "',status=2,payment_status=2,payment_time='" + DateTime.Now + "'"); if (!result) { Response.Write("修改订单状态失败"); return; } //扣除积分 if (model.point < 0) { new BLL.user_point_log().Add(model.user_id, model.user_name, model.point, "换购扣除积分,订单号:" + model.order_no, false); } } } else if (trade_status == "TRADE_FINISHED") //确认收货交易完成 { if (order_no.StartsWith("B")) //商品订单 { BLL.orders bll = new BLL.orders(); Model.orders model = bll.GetModel(order_no); if (model == null) { Response.Write("该订单号不存在"); return; } if (model.status > 2) //订单状态已经完成结束 { Response.Write("success"); return; } if (model.order_amount != decimal.Parse(total_fee)) { Response.Write("订单金额和支付金额不相符"); return; } bool result = bll.UpdateField(order_no, "status=3,complete_time='" + DateTime.Now + "'"); if (!result) { Response.Write("修改订单状态失败"); return; } //给会员增加积分检查升级 if (model.user_id > 0 && model.point > 0) { new BLL.user_point_log().Add(model.user_id, model.user_name, model.point, "购物获得积分,订单号:" + model.order_no, true); } } } } Response.Write("success"); //请不要修改或删除 } else//验证失败 { Response.Write("fail"); } } else { Response.Write("无通知参数"); } }
protected void Page_Load(object sender, EventArgs e) { //创建ResponseHandler实例 ResponseHandler resHandler = new ResponseHandler(Context); resHandler.setKey(TenpayUtil.key); //判断签名 if (resHandler.isTenpaySign()) { ///通知id string notify_id = resHandler.getParameter("notify_id"); //通过通知ID查询,确保通知来至财付通 //创建查询请求 RequestHandler queryReq = new RequestHandler(Context); queryReq.init(); queryReq.setKey(TenpayUtil.key); queryReq.setGateUrl("https://gw.tenpay.com/gateway/simpleverifynotifyid.xml"); queryReq.setParameter("partner", TenpayUtil.partner); queryReq.setParameter("notify_id", notify_id); //通信对象 TenpayHttpClient httpClient = new TenpayHttpClient(); httpClient.setTimeOut(5); //设置请求内容 httpClient.setReqContent(queryReq.getRequestURL()); //后台调用 if (httpClient.call()) { //设置结果参数 ClientResponseHandler queryRes = new ClientResponseHandler(); queryRes.setContent(httpClient.getResContent()); queryRes.setKey(TenpayUtil.key); //判断签名及结果 //只有签名正确,retcode为0,trade_state为0才是支付成功 if (queryRes.isTenpaySign()) { //取结果参数做业务处理 string order_no = resHandler.getParameter("out_trade_no").ToUpper(); //财付通订单号 string trade_no = resHandler.getParameter("transaction_id"); //金额,以分为单位 string total_fee = resHandler.getParameter("total_fee"); //如果有使用折扣券,discount有值,total_fee+discount=原请求的total_fee string discount = resHandler.getParameter("discount"); //支付结果 string trade_state = resHandler.getParameter("trade_state"); //交易模式,1即时到帐 2中介担保 string trade_mode = resHandler.getParameter("trade_mode"); //判断签名及结果 if ("0".Equals(queryRes.getParameter("retcode"))) { if ("1".Equals(trade_mode)) { #region 即时到账处理方法==================================== if ("0".Equals(trade_state)) { if (order_no.StartsWith("R")) //充值订单 { BLL.user_amount_log bll = new BLL.user_amount_log(); Model.user_amount_log model = bll.GetModel(order_no); if (model == null) { Response.Write("该订单号不存在"); return; } if (model.status == 1) //已成功 { Response.Write("success"); return; } if (model.value != (decimal.Parse(total_fee) / 100)) { Response.Write("订单金额和支付金额不相符"); return; } model.trade_no = trade_no; model.status = 1; model.complete_time = DateTime.Now; bool result = bll.Update(model); if (!result) { Response.Write("修改订单状态失败"); return; } } else if (order_no.StartsWith("B")) //商品订单 { BLL.orders bll = new BLL.orders(); Model.orders model = bll.GetModel(order_no); if (model == null) { Response.Write("该订单号不存在"); return; } if (model.payment_status == 2) //已付款 { Response.Write("success"); return; } if (model.order_amount != (decimal.Parse(total_fee) / 100)) { Response.Write("订单金额和支付金额不相符"); return; } bool result = bll.UpdateField(order_no, "trade_no='" + trade_no + "',status=2,payment_status=2,payment_time='" + DateTime.Now + "'"); if (!result) { Response.Write("修改订单状态失败"); return; } //扣除积分 if (model.point < 0) { new BLL.user_point_log().Add(model.user_id, model.user_name, model.point, "换购扣除积分,订单号:" + model.order_no, false); } } //给财付通系统发送成功信息,财付通系统收到此结果后不再进行后续通知 Response.Write("success"); } else { Response.Write("即时到账支付失败"); } #endregion } else if ("2".Equals(trade_mode)) //担保交易 { #region 担保交易处理方法==================================== if ("0".Equals(trade_state)) //付款成功 { if (order_no.StartsWith("R")) //充值订单 { BLL.user_amount_log bll = new BLL.user_amount_log(); Model.user_amount_log model = bll.GetModel(order_no); if (model == null) { Response.Write("该订单号不存在"); return; } if (model.status == 1) //已成功 { Response.Write("success"); return; } if (model.value != (decimal.Parse(total_fee) / 100)) { Response.Write("订单金额和支付金额不相符"); return; } model.trade_no = trade_no; model.status = 1; model.complete_time = DateTime.Now; bool result = bll.Update(model); if (!result) { Response.Write("修改订单状态失败"); return; } } else if (order_no.StartsWith("B")) //商品订单 { BLL.orders bll = new BLL.orders(); Model.orders model = bll.GetModel(order_no); if (model == null) { Response.Write("该订单号不存在"); return; } if (model.payment_status == 2) //已付款 { Response.Write("success"); return; } if (model.order_amount != (decimal.Parse(total_fee) / 100)) { Response.Write("订单金额和支付金额不相符"); return; } bool result = bll.UpdateField(order_no, "trade_no='" + trade_no + "',status=2,payment_status=2,payment_time='" + DateTime.Now + "'"); if (!result) { Response.Write("修改订单状态失败"); return; } //扣除积分 if (model.point < 0) { new BLL.user_point_log().Add(model.user_id, model.user_name, model.point, "换购扣除积分,订单号:" + model.order_no, false); } } } else if ("5".Equals(trade_state)) //买家收货确认,交易成功 { if (order_no.StartsWith("B")) //商品订单 { BLL.orders bll = new BLL.orders(); Model.orders model = bll.GetModel(order_no); if (model == null) { Response.Write("该订单号不存在"); return; } if (model.status > 2) //订单状态已经完成结束 { Response.Write("success"); return; } if (model.order_amount != decimal.Parse(total_fee)) { Response.Write("订单金额和支付金额不相符"); return; } bool result = bll.UpdateField(order_no, "status=3,complete_time='" + DateTime.Now + "'"); if (!result) { Response.Write("修改订单状态失败"); return; } //给会员增加积分检查升级 if (model.user_id > 0 && model.point > 0) { new BLL.user_point_log().Add(model.user_id, model.user_name, model.point, "购物获得积分,订单号:" + model.order_no, true); } } } //给财付通系统发送成功信息,财付通系统收到此结果后不再进行后续通知 Response.Write("success"); #endregion } } else { Response.Write("查询验证签名失败或id验证失败"); } } else { Response.Write("通知ID查询签名验证失败"); } } else { Response.Write("后台调用通信失败"); } } else { Response.Write("签名验证失败"); } Response.End(); }
protected void Page_Load(object sender, EventArgs e) { //读取站点配置信息 Model.siteconfig siteConfig = new BLL.siteconfig().loadConfig(); //=============================获得订单信息================================ string action = DTRequest.GetQueryString("action"); string order_type = ""; string order_no = ""; decimal order_amount = 0; string user_name = ""; string subject = ""; if (action == "pay") { //获得订单信息 order_type = DTRequest.GetQueryString("pay_order_type"); //订单类型 order_no = DTRequest.GetQueryString("pay_order_no"); order_amount = DTRequest.GetQueryDecimal("pay_order_amount", 0); user_name = DTRequest.GetQueryString("pay_user_name"); subject = DTRequest.GetQueryString("pay_subject"); } else { //获得订单信息 order_type = DTRequest.GetFormString("pay_order_type"); //订单类型 order_no = DTRequest.GetFormString("pay_order_no"); order_amount = DTRequest.GetFormDecimal("pay_order_amount", 0); user_name = DTRequest.GetFormString("pay_user_name"); subject = DTRequest.GetFormString("pay_subject"); } //以下收货人信息 string receive_name = string.Empty; //收货人姓名 string receive_address = string.Empty; //收货人地址 string receive_zip = string.Empty; //收货人邮编 string receive_phone = string.Empty; //收货人电话 string receive_mobile = string.Empty; //收货人手机 //检查参数是否正确 if (order_no == "" || order_amount == 0) { Response.Redirect(new Web.UI.BasePage().linkurl("error", "?msg=" + Utils.UrlEncode("对不起,您提交的参数有误!"))); return; } if (order_no.StartsWith("R")) //R开头为在线充值订单 { Model.user_amount_log model = new BLL.user_amount_log().GetModel(order_no); if (model == null) { Response.Redirect(new Web.UI.BasePage().linkurl("error", "?msg=" + Utils.UrlEncode("对不起,您充值的订单号不存在或已删除!"))); return; } if (model.value != order_amount) { Response.Redirect(new Web.UI.BasePage().linkurl("error", "?msg=" + Utils.UrlEncode("对不起,您充值的订单金额与实际金额不一致!"))); return; } //取得用户信息 Model.users userModel = new BLL.users().GetModel(model.user_id); if (userModel == null) { Response.Redirect(new Web.UI.BasePage().linkurl("error", "?msg=" + Utils.UrlEncode("对不起,用户账户不存在或已删除!"))); return; } receive_name = userModel.nick_name; receive_address = userModel.address; receive_phone = userModel.telphone; receive_mobile = userModel.mobile; } else //B开头为商品订单 { Model.orders model = new BLL.orders().GetModel(order_no); if (model == null) { Response.Redirect(new Web.UI.BasePage().linkurl("error", "?msg=" + Utils.UrlEncode("对不起,您支付的订单号不存在或已删除!"))); return; } if (model.order_amount != order_amount) { Response.Redirect(new Web.UI.BasePage().linkurl("error", "?msg=" + Utils.UrlEncode("对不起,您支付的订单金额与实际金额不一致!"))); return; } receive_name = model.accept_name; receive_address = model.address; receive_zip = model.post_code; receive_phone = model.telphone; receive_mobile = model.mobile; } if (user_name != "") { user_name = "支付会员:" + user_name; } else { user_name = "匿名用户"; } //===============================请求参数================================== //判断担保或是即时到帐接口 if (Config.Type == "1") //即时到帐 { //把请求参数打包成数组 SortedDictionary <string, string> sParaTemp = new SortedDictionary <string, string>(); sParaTemp.Add("payment_type", "1"); //收款类型1商品购买 sParaTemp.Add("show_url", siteConfig.weburl); //商品展示地址 sParaTemp.Add("out_trade_no", order_no); //网站订单号 sParaTemp.Add("subject", siteConfig.webname + "-" + subject); //订单名称 sParaTemp.Add("body", user_name); //订单描述 sParaTemp.Add("total_fee", order_amount.ToString()); //订单总金额 sParaTemp.Add("paymethod", ""); //默认支付方式 sParaTemp.Add("defaultbank", ""); //默认网银代号 sParaTemp.Add("anti_phishing_key", ""); //防钓鱼时间戳 sParaTemp.Add("exter_invoke_ip", DTRequest.GetIP()); ////获取客户端的IP地址 sParaTemp.Add("buyer_email", ""); //默认买家支付宝账号 sParaTemp.Add("royalty_type", ""); sParaTemp.Add("royalty_parameters", ""); //构造即时到帐接口表单提交HTML数据,无需修改 Service ali = new Service(); string sHtmlText = ali.Create_direct_pay_by_user(sParaTemp); Response.Write(sHtmlText); } else //担保交易 { //把请求参数打包成数组 SortedDictionary <string, string> sParaTemp = new SortedDictionary <string, string>(); sParaTemp.Add("payment_type", "1"); //收款类型1商品购买 sParaTemp.Add("out_trade_no", order_no); //网站订单号 sParaTemp.Add("subject", siteConfig.webname + "-" + subject); //订单名称 sParaTemp.Add("price", order_amount.ToString()); //付款金额 sParaTemp.Add("quantity", "1"); //建议默认为1,不改变值,把一次交易看成是一次下订单而非购买一件商品 sParaTemp.Add("logistics_fee", "0.00"); //物流费用 sParaTemp.Add("logistics_type", "EXPRESS"); //物流类型,EXPRESS(快递)、POST(平邮)、EMS(EMS) sParaTemp.Add("logistics_payment", "SELLER_PAY"); //物流支付方式,SELLER_PAY(卖家承担运费)、BUYER_PAY(买家承担运费) sParaTemp.Add("body", user_name); //订单描述 sParaTemp.Add("show_url", siteConfig.weburl); //商品展示地址 sParaTemp.Add("receive_name", receive_name); //收货人姓名 sParaTemp.Add("receive_address", receive_address); //收货人地址 sParaTemp.Add("receive_zip", receive_zip); //收货人邮编 sParaTemp.Add("receive_phone", receive_phone); //收货人电话号码 sParaTemp.Add("receive_mobile", receive_mobile); //收货人手机号码 //构造即时到帐接口表单提交HTML数据,无需修改 Service ali = new Service(); string sHtmlText = ali.Create_partner_trade_by_buyer(sParaTemp); Response.Write(sHtmlText); } }
protected void Page_Load(object sender, EventArgs e) { //读取站点配置信息 Model.siteconfig siteConfig = new BLL.siteconfig().loadConfig(); //=============================获得订单信息================================ string action = DTRequest.GetQueryString("action"); string order_type = ""; string order_no = ""; decimal order_amount = 0; string user_name = ""; string subject = ""; if (action == "pay") { //获得订单信息 order_type = DTRequest.GetQueryString("pay_order_type"); //订单类型 order_no = DTRequest.GetQueryString("pay_order_no"); order_amount = DTRequest.GetQueryDecimal("pay_order_amount", 0); user_name = DTRequest.GetQueryString("pay_user_name"); subject = DTRequest.GetQueryString("pay_subject"); } else { //获得订单信息 order_type = DTRequest.GetFormString("pay_order_type"); //订单类型 order_no = DTRequest.GetFormString("pay_order_no"); order_amount = DTRequest.GetFormDecimal("pay_order_amount", 0); user_name = DTRequest.GetFormString("pay_user_name"); subject = DTRequest.GetFormString("pay_subject"); } string trans_type = string.Empty; //交易类型1实物2虚拟 if (order_no == "" || order_amount == 0) { Response.Redirect(new Web.UI.BasePage().linkurl("error", "?msg=" + Utils.UrlEncode("对不起,您提交的参数有误!"))); return; } if (order_no.StartsWith("R")) //R开头为在线充值订单 { Model.user_amount_log model = new BLL.user_amount_log().GetModel(order_no); if (model == null) { Response.Redirect(new Web.UI.BasePage().linkurl("error", "?msg=" + Utils.UrlEncode("对不起,您充值的订单号不存在或已删除!"))); return; } if (model.value != order_amount) { Response.Redirect(new Web.UI.BasePage().linkurl("error", "?msg=" + Utils.UrlEncode("对不起,您充值的订单金额与实际金额不一致!"))); return; } trans_type = "2"; } else //B开头为商品订单 { Model.orders model = new BLL.orders().GetModel(order_no); if (model == null) { Response.Redirect(new Web.UI.BasePage().linkurl("error", "?msg=" + Utils.UrlEncode("对不起,您支付的订单号不存在或已删除!"))); return; } if (model.order_amount != order_amount) { Response.Redirect(new Web.UI.BasePage().linkurl("error", "?msg=" + Utils.UrlEncode("对不起,您支付的订单金额与实际金额不一致!"))); return; } trans_type = "1"; } //检查会员还是匿名 if (user_name != "") { user_name = "支付会员:" + user_name; } else { user_name = "匿名用户"; } //===============================请求参数================================== //创建RequestHandler实例 RequestHandler reqHandler = new RequestHandler(Context); //初始化 reqHandler.init(); //设置密钥 reqHandler.setKey(TenpayUtil.key); reqHandler.setGateUrl("https://gw.tenpay.com/gateway/pay.htm"); //----------------------------- //设置支付参数 //----------------------------- reqHandler.setParameter("partner", TenpayUtil.partner); //商户号 reqHandler.setParameter("out_trade_no", order_no); //商家订单号 reqHandler.setParameter("total_fee", (Convert.ToDouble(order_amount) * 100).ToString()); //商品金额,以分为单位 reqHandler.setParameter("return_url", TenpayUtil.return_url); //交易完成后跳转的URL reqHandler.setParameter("notify_url", TenpayUtil.notify_url); //接收财付通通知的URL reqHandler.setParameter("body", user_name); //商品描述 reqHandler.setParameter("bank_type", "DEFAULT"); //银行类型(中介担保时此参数无效) reqHandler.setParameter("spbill_create_ip", Page.Request.UserHostAddress); //用户的公网ip,不是商户服务器IP reqHandler.setParameter("fee_type", "1"); //币种,1人民币 reqHandler.setParameter("subject", siteConfig.webname + "-" + subject); //商品名称(中介交易时必填) //系统可选参数 reqHandler.setParameter("sign_type", "MD5"); reqHandler.setParameter("service_version", "1.0"); reqHandler.setParameter("input_charset", "UTF-8"); reqHandler.setParameter("sign_key_index", "1"); //业务可选参数 reqHandler.setParameter("product_fee", "0"); //商品费用,必须保证transport_fee + product_fee=total_fee reqHandler.setParameter("transport_fee", "0"); //物流费用,必须保证transport_fee + product_fee=total_fee reqHandler.setParameter("time_start", DateTime.Now.ToString("yyyyMMddHHmmss")); //订单生成时间,格式为yyyymmddhhmmss reqHandler.setParameter("time_expire", ""); //订单失效时间,格式为yyyymmddhhmmss reqHandler.setParameter("buyer_id", ""); //买方财付通账号 reqHandler.setParameter("goods_tag", ""); //商品标记 reqHandler.setParameter("trade_mode", TenpayUtil.type); //交易模式,1即时到账(默认),2中介担保,3后台选择(买家进支付中心列表选择) reqHandler.setParameter("transport_desc", ""); //物流说明 reqHandler.setParameter("trans_type", "1"); //交易类型,1实物交易,2虚拟交易 reqHandler.setParameter("agentid", ""); //平台ID reqHandler.setParameter("agent_type", ""); //代理模式,0无代理(默认),1表示卡易售模式,2表示网店模式 reqHandler.setParameter("seller_id", ""); //卖家商户号,为空则等同于partner //获取请求带参数的url string requestUrl = reqHandler.getRequestURL(); //实现自动跳转=============================== StringBuilder sbHtml = new StringBuilder(); sbHtml.Append("<form id='tenpaysubmit' name='tenpaysubmit' action='" + reqHandler.getGateUrl() + "' method='get'>"); Hashtable ht = reqHandler.getAllParameters(); foreach (DictionaryEntry de in ht) { sbHtml.Append("<input type=\"hidden\" name=\"" + de.Key + "\" value=\"" + de.Value + "\" >\n"); } //submit按钮控件请不要含有name属性 sbHtml.Append("<input type='submit' value='确认' style='display:none;'></form>"); sbHtml.Append("<script>document.forms['tenpaysubmit'].submit();</script>"); Response.Write(sbHtml.ToString()); }
private void user_point_convert(HttpContext context) { //检查系统是否启用兑换积分功能 if (userConfig.pointcashrate == 0) { context.Response.Write("{\"status\":0, \"msg\":\"对不起,网站未开启兑换积分功能!\"}"); return; } //检查用户是否登录 Model.users model = new BasePage().GetUserInfo(); if (model == null) { context.Response.Write("{\"status\":0, \"msg\":\"对不起,用户尚未登录或已超时!\"}"); return; } int amout = DTRequest.GetFormInt("txtAmount"); string password = DTRequest.GetFormString("txtPassword"); if (model.amount < 1) { context.Response.Write("{\"status\":0, \"msg\":\"对不起,您账户上的余额不足!\"}"); return; } if (amout < 1) { context.Response.Write("{\"status\":0, \"msg\":\"对不起,最小兑换金额为1元!\"}"); return; } if (amout > model.amount) { context.Response.Write("{\"status\":0, \"msg\":\"对不起,您兑换的金额大于账户余额!\"}"); return; } if (password == "") { context.Response.Write("{\"status\":0, \"msg\":\"对不起,请输入您账户的密码!\"}"); return; } //验证密码 if (DESEncrypt.Encrypt(password, model.salt) != model.password) { context.Response.Write("{\"status\":0, \"msg\":\"对不起,您输入的密码不正确!\"}"); return; } //计算兑换后的积分值 int convertPoint = (int)(Convert.ToDecimal(amout) * userConfig.pointcashrate); //扣除金额 int amountNewId = new BLL.user_amount_log().Add(model.id, model.user_name, amout * -1, "用户兑换积分"); //增加积分 if (amountNewId < 1) { context.Response.Write("{\"status\":0, \"msg\":\"转换过程中发生错误,请重新提交!\"}"); return; } int pointNewId = new BLL.user_point_log().Add(model.id, model.user_name, convertPoint, "用户兑换积分", true); if (pointNewId < 1) { //返还金额 new BLL.user_amount_log().Add(model.id, model.user_name, amout, "用户兑换积分失败,返还金额"); context.Response.Write("{\"status\":0, \"msg\":\"转换过程中发生错误,请重新提交!\"}"); return; } context.Response.Write("{\"status\":1, \"msg\":\"恭喜您,积分兑换成功!\"}"); return; }
protected void Page_Load(object sender, EventArgs e) { SortedDictionary <string, string> sPara = GetRequestPost(); if (sPara.Count > 0)//判断是否有带返回参数 { Notify aliNotify = new Notify(); bool verifyResult = aliNotify.Verify(sPara, MXRequest.GetString("notify_id"), MXRequest.GetString("sign")); //写日志 //System.IO.File.AppendAllText(Utils.GetMapPath("alipaylog.txt"), "验证结果:" + verifyResult.ToString() + "\n", System.Text.Encoding.UTF8); if (verifyResult) //验证成功 { string trade_no = MXRequest.GetString("trade_no"); //支付宝交易号 string order_no = MXRequest.GetString("out_trade_no").ToUpper(); //获取订单号 string total_fee = MXRequest.GetString("total_fee"); //获取总金额 string trade_status = MXRequest.GetString("trade_status"); //交易状态 //写日志 //System.IO.File.AppendAllText(Utils.GetMapPath("alipaylog.txt"), "接口类型:" + Config.Type + "\n", System.Text.Encoding.UTF8); if (Config.Type == "1") //即时到帐接口处理方法 { //写日志 //System.IO.File.AppendAllText(Utils.GetMapPath("alipaylog.txt"), "即时到帐返回交易状态:" + trade_status + "\n", System.Text.Encoding.UTF8); if (trade_status == "TRADE_FINISHED" || trade_status == "TRADE_SUCCESS") { if (order_no.StartsWith("R")) //充值订单 { BLL.user_amount_log bll = new BLL.user_amount_log(); Model.user_amount_log model = bll.GetModel(order_no); if (model == null) { Response.Write("该订单号不存在"); return; } if (model.status == 1) //已成功 { Response.Write("success"); return; } if (model.value != decimal.Parse(total_fee)) { Response.Write("订单金额和支付金额不相符"); return; } model.trade_no = trade_no; model.status = 1; model.complete_time = DateTime.Now; bool result = bll.Update(model); if (!result) { Response.Write("修改订单状态失败"); return; } } else if (order_no.StartsWith("B")) //商品订单 { //写日志 //System.IO.File.AppendAllText(Utils.GetMapPath("alipaylog.txt"), "商品订单\n", System.Text.Encoding.UTF8); BLL.orders bll = new BLL.orders(); Model.orders model = bll.GetModel(order_no); if (model == null) { //写日志 //System.IO.File.AppendAllText(Utils.GetMapPath("alipaylog.txt"), "订单号:" + order_no + "不存在\n", System.Text.Encoding.UTF8); Response.Write("该订单号不存在"); return; } if (model.payment_status == 2) //已付款 { //写日志 //System.IO.File.AppendAllText(Utils.GetMapPath("alipaylog.txt"), "订单号:" + order_no + "已付款\n", System.Text.Encoding.UTF8); Response.Write("success"); return; } if (model.order_amount != decimal.Parse(total_fee)) { //写日志 //System.IO.File.AppendAllText(Utils.GetMapPath("alipaylog.txt"), "订单号:" + order_no + "订单金额" + model.order_amount + "和支付金额" + total_fee + "不相符\n", System.Text.Encoding.UTF8); Response.Write("订单金额和支付金额不相符"); return; } bool result = bll.UpdateField(order_no, "trade_no='" + trade_no + "',status=2,payment_status=2,payment_time='" + DateTime.Now + "'"); if (!result) { Response.Write("修改订单状态失败"); return; } //写日志 //System.IO.File.AppendAllText(Utils.GetMapPath("alipaylog.txt"), "修改订单状态:" + result.ToString() + "\n", System.Text.Encoding.UTF8); //扣除积分 if (model.point < 0) { new BLL.user_point_log().Add(model.user_id, model.user_name, model.point, "换购扣除积分,订单号:" + model.order_no, false); } } } } else //担保交易接口处理方法 { if (trade_status == "WAIT_SELLER_SEND_GOODS") //付款成功 { if (order_no.StartsWith("R")) //充值订单 { BLL.user_amount_log bll = new BLL.user_amount_log(); Model.user_amount_log model = bll.GetModel(order_no); if (model == null) { Response.Write("该订单号不存在"); return; } if (model.status == 1) //已成功 { Response.Write("success"); return; } if (model.value != decimal.Parse(total_fee)) { Response.Write("订单金额和支付金额不相符"); return; } model.trade_no = trade_no; model.status = 1; model.complete_time = DateTime.Now; bool result = bll.Update(model); if (!result) { Response.Write("修改订单状态失败"); return; } //自动发货 result = new Service().Send_goods_confirm_by_platform(trade_no, "EXPRESS", "", "DIRECT"); if (!result) { Response.Write("自动发货失败"); return; } } else if (order_no.StartsWith("B")) //商品订单 { BLL.orders bll = new BLL.orders(); Model.orders model = bll.GetModel(order_no); if (model == null) { Response.Write("该订单号不存在"); return; } if (model.payment_status == 2) //已付款 { Response.Write("success"); return; } if (model.order_amount != decimal.Parse(total_fee)) { Response.Write("订单金额和支付金额不相符"); return; } bool result = bll.UpdateField(order_no, "trade_no='" + trade_no + "',status=2,payment_status=2,payment_time='" + DateTime.Now + "'"); if (!result) { Response.Write("修改订单状态失败"); return; } //扣除积分 if (model.point < 0) { new BLL.user_point_log().Add(model.user_id, model.user_name, model.point, "换购扣除积分,订单号:" + model.order_no, false); } } } else if (trade_status == "TRADE_FINISHED") //确认收货交易完成 { if (order_no.StartsWith("B")) //商品订单 { BLL.orders bll = new BLL.orders(); Model.orders model = bll.GetModel(order_no); if (model == null) { Response.Write("该订单号不存在"); return; } if (model.status > 2) //订单状态已经完成结束 { Response.Write("success"); return; } if (model.order_amount != decimal.Parse(total_fee)) { Response.Write("订单金额和支付金额不相符"); return; } bool result = bll.UpdateField(order_no, "status=3,complete_time='" + DateTime.Now + "'"); if (!result) { Response.Write("修改订单状态失败"); return; } //给会员增加积分检查升级 if (model.user_id > 0 && model.point > 0) { new BLL.user_point_log().Add(model.user_id, model.user_name, model.point, "购物获得积分,订单号:" + model.order_no, true); } } } } Response.Write("success"); //请不要修改或删除 } else//验证失败 { Response.Write("fail"); } } else { Response.Write("无通知参数"); } }
protected void Page_Load(object sender, EventArgs e) { //读取站点配置信息 Model.siteconfig siteConfig = new BLL.siteconfig().loadConfig(); //=============================获得订单信息================================ string order_no = MXRequest.GetFormString("pay_order_no").ToUpper(); decimal order_amount = MXRequest.GetFormDecimal("pay_order_amount", 0); string user_name = MXRequest.GetFormString("pay_user_name"); string subject = MXRequest.GetFormString("pay_subject"); //以下收货人信息 string receive_name = string.Empty; //收货人姓名 string receive_address = string.Empty; //收货人地址 string receive_zip = string.Empty; //收货人邮编 string receive_phone = string.Empty; //收货人电话 string receive_mobile = string.Empty; //收货人手机 //检查参数是否正确 if (order_no == "" || order_amount == 0) { Response.Redirect(new Web.UI.BasePage().linkurl("error", "?msg=" + Utils.UrlEncode("对不起,您提交的参数有误!"))); return; } if (order_no.StartsWith("R")) //R开头为在线充值订单 { Model.user_amount_log model = new BLL.user_amount_log().GetModel(order_no); if (model == null) { Response.Redirect(new Web.UI.BasePage().linkurl("error", "?msg=" + Utils.UrlEncode("对不起,您充值的订单号不存在或已删除!"))); return; } if (model.value != order_amount) { Response.Redirect(new Web.UI.BasePage().linkurl("error", "?msg=" + Utils.UrlEncode("对不起,您充值的订单金额与实际金额不一致!"))); return; } //取得用户信息 Model.users userModel = new BLL.users().GetModel(model.user_id); if (userModel == null) { Response.Redirect(new Web.UI.BasePage().linkurl("error", "?msg=" + Utils.UrlEncode("对不起,用户账户不存在或已删除!"))); return; } receive_name = userModel.nick_name; receive_address = userModel.address; receive_phone = userModel.telphone; receive_mobile = userModel.mobile; } else //B开头为商品订单 { Model.orders model = new BLL.orders().GetModel(order_no); if (model == null) { Response.Redirect(new Web.UI.BasePage().linkurl("error", "?msg=" + Utils.UrlEncode("对不起,您支付的订单号不存在或已删除!"))); return; } if (model.order_amount != order_amount) { Response.Redirect(new Web.UI.BasePage().linkurl("error", "?msg=" + Utils.UrlEncode("对不起,您支付的订单金额与实际金额不一致!"))); return; } receive_name = model.accept_name; receive_address = model.address; receive_zip = model.post_code; receive_phone = model.telphone; receive_mobile = model.mobile; } if (user_name != "") { user_name = "支付会员:" + user_name; } else { user_name = "匿名用户"; } //===============================请求参数================================== //判断担保或是即时到帐接口 if (Config.Type == "1") //即时到帐 { //把请求参数打包成数组 SortedDictionary<string, string> sParaTemp = new SortedDictionary<string, string>(); sParaTemp.Add("payment_type", "1"); //收款类型1商品购买 sParaTemp.Add("show_url", siteConfig.weburl); //商品展示地址 sParaTemp.Add("out_trade_no", order_no); //网站订单号 sParaTemp.Add("subject", siteConfig.webname + "-" + subject); //订单名称 sParaTemp.Add("body", user_name); //订单描述 sParaTemp.Add("total_fee", order_amount.ToString()); //订单总金额 sParaTemp.Add("paymethod", ""); //默认支付方式 sParaTemp.Add("defaultbank", ""); //默认网银代号 sParaTemp.Add("anti_phishing_key", ""); //防钓鱼时间戳 sParaTemp.Add("exter_invoke_ip", MXRequest.GetIP()); ////获取客户端的IP地址 sParaTemp.Add("buyer_email", ""); //默认买家支付宝账号 sParaTemp.Add("royalty_type", ""); sParaTemp.Add("royalty_parameters", ""); //构造即时到帐接口表单提交HTML数据,无需修改 Service ali = new Service(); string sHtmlText = ali.Create_direct_pay_by_user(sParaTemp); Response.Write(sHtmlText); } else //担保交易 { //把请求参数打包成数组 SortedDictionary<string, string> sParaTemp = new SortedDictionary<string, string>(); sParaTemp.Add("payment_type", "1"); //收款类型1商品购买 sParaTemp.Add("out_trade_no", order_no); //网站订单号 sParaTemp.Add("subject", siteConfig.webname + "-" + subject); //订单名称 sParaTemp.Add("price", order_amount.ToString()); //付款金额 sParaTemp.Add("quantity", "1"); //建议默认为1,不改变值,把一次交易看成是一次下订单而非购买一件商品 sParaTemp.Add("logistics_fee", "0.00"); //物流费用 sParaTemp.Add("logistics_type", "EXPRESS"); //物流类型,EXPRESS(快递)、POST(平邮)、EMS(EMS) sParaTemp.Add("logistics_payment", "SELLER_PAY"); //物流支付方式,SELLER_PAY(卖家承担运费)、BUYER_PAY(买家承担运费) sParaTemp.Add("body", user_name); //订单描述 sParaTemp.Add("show_url", siteConfig.weburl); //商品展示地址 sParaTemp.Add("receive_name", receive_name); //收货人姓名 sParaTemp.Add("receive_address", receive_address); //收货人地址 sParaTemp.Add("receive_zip", receive_zip); //收货人邮编 sParaTemp.Add("receive_phone", receive_phone); //收货人电话号码 sParaTemp.Add("receive_mobile", receive_mobile); //收货人手机号码 //构造即时到帐接口表单提交HTML数据,无需修改 Service ali = new Service(); string sHtmlText = ali.Create_partner_trade_by_buyer(sParaTemp); Response.Write(sHtmlText); } }
protected void Page_Load(object sender, EventArgs e) { //读取站点配置信息 Model.siteconfig siteConfig = new BLL.siteconfig().loadConfig(); //=============================获得订单信息================================ string order_no = DTRequest.GetFormString("pay_order_no").ToUpper(); decimal order_amount = DTRequest.GetFormDecimal("pay_order_amount", 0); string user_name = DTRequest.GetFormString("pay_user_name"); string subject = DTRequest.GetFormString("pay_subject"); //以下收货人信息 string receive_name = string.Empty; //收货人姓名 string receive_address = string.Empty; //收货人地址 string receive_zip = string.Empty; //收货人邮编 string receive_phone = string.Empty; //收货人电话 string receive_mobile = string.Empty; //收货人手机 //检查参数是否正确 if (order_no == "" || order_amount == 0) { Response.Redirect(new Web.UI.BasePage().linkurl("error", "?msg=" + Utils.UrlEncode("对不起,您提交的参数有误!"))); return; } if (order_no.StartsWith("R")) //R开头为在线充值订单 { Model.user_amount_log model = new BLL.user_amount_log().GetModel(order_no); if (model == null) { Response.Redirect(new Web.UI.BasePage().linkurl("error", "?msg=" + Utils.UrlEncode("对不起,您充值的订单号不存在或已删除!"))); return; } if (model.value != order_amount) { Response.Redirect(new Web.UI.BasePage().linkurl("error", "?msg=" + Utils.UrlEncode("对不起,您充值的订单金额与实际金额不一致!"))); return; } //取得用户信息 Model.users userModel = new BLL.users().GetModel(model.user_id); if (userModel == null) { Response.Redirect(new Web.UI.BasePage().linkurl("error", "?msg=" + Utils.UrlEncode("对不起,用户账户不存在或已删除!"))); return; } receive_name = userModel.nick_name; receive_address = userModel.address; receive_phone = userModel.telphone; receive_mobile = userModel.mobile; } else //B开头为商品订单 { Model.orders model = new BLL.orders().GetModel(order_no); if (model == null) { Response.Redirect(new Web.UI.BasePage().linkurl("error", "?msg=" + Utils.UrlEncode("对不起,您支付的订单号不存在或已删除!"))); return; } if (model.order_amount != order_amount) { Response.Redirect(new Web.UI.BasePage().linkurl("error", "?msg=" + Utils.UrlEncode("对不起,您支付的订单金额与实际金额不一致!"))); return; } receive_name = model.accept_name; receive_address = model.address; receive_zip = model.post_code; receive_phone = model.telphone; receive_mobile = model.mobile; } if (user_name != "") { user_name = "支付会员:" + user_name; } else { user_name = "匿名用户"; } //===============================加密签名================================== string moneytype = "CNY"; // 拼凑加密串=订单金额+币种+订单号+商户号+返回地址+商户MD5密钥 string signtext = order_amount + moneytype + order_no + Config.Partner + Config.Return_url + Config.Key; string md5info = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(signtext, "md5").ToUpper(); //===============================请求参数================================== //把请求参数打包成数组 SortedDictionary <string, string> sParaTemp = new SortedDictionary <string, string>(); sParaTemp.Add("v_mid", Config.Partner); //商户编号 sParaTemp.Add("v_oid", order_no); //网站订单号 sParaTemp.Add("v_amount", order_amount.ToString()); //订单总金额 sParaTemp.Add("v_moneytype", moneytype); //币种 sParaTemp.Add("v_url", Config.Return_url); //返回地址 sParaTemp.Add("remark2", "[url:=" + Config.Notify_url + "]"); //回调地址 sParaTemp.Add("v_md5info", md5info); //MD5校验码 sParaTemp.Add("remark1", siteConfig.webname + "-" + subject + user_name); //订单描述 sParaTemp.Add("v_rcvname", receive_name); //收货人姓名 sParaTemp.Add("v_rcvaddr", receive_address); //收货人地址 sParaTemp.Add("v_rcvtel", receive_phone); //收货人电话 sParaTemp.Add("v_rcvpost", receive_zip); //收货人邮编 sParaTemp.Add("v_rcvmobile", receive_mobile); //收货人手机号 //构造即时到帐接口表单提交HTML数据,无需修改 Service chinabank = new Service(); string sHtmlText = chinabank.BuildFormHtml(sParaTemp, "post", "确认"); Response.Write(sHtmlText); }
protected string remark2; //备注1 protected void Page_Load(object sender, EventArgs e) { //读取站点配置信息 Model.siteconfig siteConfig = new BLL.siteconfig().loadConfig(); v_oid = DTRequest.GetString("v_oid").ToUpper(); v_pstatus = DTRequest.GetString("v_pstatus"); v_pstring = DTRequest.GetString("v_pstring"); v_pmode = DTRequest.GetString("v_pmode"); v_md5str = DTRequest.GetString("v_md5str"); v_amount = DTRequest.GetString("v_amount"); v_moneytype = DTRequest.GetString("v_moneytype"); remark1 = DTRequest.GetString("remark1"); remark2 = DTRequest.GetString("remark2"); // 拼凑加密串 string signtext = v_oid + v_pstatus + v_amount + v_moneytype + Config.Key; signtext = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(signtext, "md5").ToUpper(); //写日志 //System.IO.File.AppendAllText(Utils.GetMapPath("chinabanklog.txt"), "现签名:" + signtext + ",原签名:" + v_md5str + "验证结果:" + v_pstatus + "\n", System.Text.Encoding.UTF8); if (signtext == v_md5str && v_pstatus.Equals("20")) { //成功状态 if (v_oid.StartsWith("R")) //充值订单 { //写日志 //System.IO.File.AppendAllText(Utils.GetMapPath("chinabanklog.txt"), "充值订单号:" + v_oid + "\n", System.Text.Encoding.UTF8); BLL.user_amount_log bll = new BLL.user_amount_log(); Model.user_amount_log model = bll.GetModel(v_oid); if (model == null) { //写日志 System.IO.File.AppendAllText(Utils.GetMapPath("chinabanklog.txt"), "充值记录不存在\n", System.Text.Encoding.UTF8); Response.Write("error"); return; } if (model.status == 1) //已成功 { Response.Write("ok"); return; } if (model.value != decimal.Parse(v_amount)) { //写日志 //System.IO.File.AppendAllText(Utils.GetMapPath("chinabanklog.txt"), "金额不相同,记录值:" + model.value + ",返回值:" + v_amount + "\n", System.Text.Encoding.UTF8); Response.Write("error"); return; } model.status = 1; model.complete_time = DateTime.Now; bool result = bll.Update(model); if (!result) { //写日志 //System.IO.File.AppendAllText(Utils.GetMapPath("chinabanklog.txt"), "更新记录失败\n", System.Text.Encoding.UTF8); Response.Write("error"); return; } } else if (v_oid.StartsWith("B")) //商品订单 { //写日志 //System.IO.File.AppendAllText(Utils.GetMapPath("chinabanklog.txt"), "商品订单号:" + v_oid + "\n", System.Text.Encoding.UTF8); BLL.orders bll = new BLL.orders(); Model.orders model = bll.GetModel(v_oid); if (model == null) { //写日志 //System.IO.File.AppendAllText(Utils.GetMapPath("chinabanklog.txt"), "充值记录不存在\n", System.Text.Encoding.UTF8); Response.Write("error"); return; } if (model.payment_status == 2) //已付款 { Response.Write("ok"); return; } if (model.order_amount != decimal.Parse(v_amount)) { //写日志 //System.IO.File.AppendAllText(Utils.GetMapPath("chinabanklog.txt"), "金额不相同,记录值:" + model.order_amount + ",返回值:" + v_amount + "\n", System.Text.Encoding.UTF8); Response.Write("error"); return; } bool result = bll.UpdateField(v_oid, "status=2,payment_status=2,payment_time='" + DateTime.Now + "'"); if (!result) { //写日志 //System.IO.File.AppendAllText(Utils.GetMapPath("chinabanklog.txt"), "更新记录失败\n", System.Text.Encoding.UTF8); Response.Write("error"); return; } //扣除积分 if (model.point < 0) { new BLL.user_point_log().Add(model.user_id, model.user_name, model.point, "换购扣除积分,订单号:" + model.order_no, false); } } //成功状态 Response.Write("ok"); return; } //失败状态 Response.Write("error"); return; }
protected void Page_Load(object sender, EventArgs e) { //读取站点配置信息 Model.siteconfig siteConfig = new BLL.siteconfig().loadConfig(); string order_no = DTRequest.GetFormString("pay_order_no").ToUpper(); BLL.orders objorders = new BLL.orders(); Model.orders modelorders = objorders.GetModel(order_no); if (modelorders == null) { Response.Redirect(new Web.UI.BasePage().linkurl("error", "?msg=" + Utils.UrlEncode("对不起,订单详情获取出错,请重试!"))); return; } decimal order_amount = modelorders.order_amount; string subject = DTRequest.GetFormString("pay_subject"); if (order_no == "" || order_amount == 0 ) { Response.Redirect(new Web.UI.BasePage().linkurl("error", "?msg=" + Utils.UrlEncode("对不起,您提交的参数有误!"))); return; } //检查是否已登录 Model.users userModel = new Web.UI.BasePage().GetUserInfo(); if (userModel == null) { Response.Redirect(new Web.UI.BasePage().linkurl("payment", "?action=login")); //尚未登录 return; } if (userModel.amount < order_amount) { Response.Redirect(new Web.UI.BasePage().linkurl("payment", "?action=recharge")); //账户的余额不足 return; } if (order_no.StartsWith("B")) //B开头为商品订单 { BLL.orders bll = new BLL.orders(); Model.orders model = bll.GetModel(order_no); if (model == null) { Response.Redirect(new Web.UI.BasePage().linkurl("error", "?msg=" + Utils.UrlEncode("对不起,商品订单号不存在!"))); return; } if (model.payment_status == 1) { //执行扣取账户金额 int result = new BLL.user_amount_log().Add(userModel.id, userModel.user_name, -1 * order_amount, subject); if (result > 0) { //更改订单状态 bool result1 = bll.UpdateField(order_no, "status=2,payment_status=2,payment_time='" + DateTime.Now + "'"); if (!result1) { Response.Redirect(new Web.UI.BasePage().linkurl("payment", "?action=error")); return; } //扣除积分 if (model.point < 0) { new BLL.user_point_log().Add(model.user_id, model.user_name, model.point, "换购扣除积分,订单号:" + model.order_no, false); } } else { Response.Redirect(new Web.UI.BasePage().linkurl("payment", "?action=error")); return; } } //支付成功 Response.Redirect(new Web.UI.BasePage().linkurl("payment", "?action=succeed&order_no=" + order_no)); return; } Response.Redirect(new Web.UI.BasePage().linkurl("error", "?msg=" + Utils.UrlEncode("对不起,找不到需要支付的订单类型!"))); return; }
protected void Page_Load(object sender, EventArgs e) { //读取站点配置信息 Model.siteconfig siteConfig = new BLL.siteconfig().loadConfig(); string order_no = MXRequest.GetFormString("pay_order_no").ToUpper(); BLL.orders objorders = new BLL.orders(); Model.orders modelorders = objorders.GetModel(order_no); if (modelorders == null) { Response.Redirect(new Web.UI.BasePage().linkurl("error", "?msg=" + Utils.UrlEncode("对不起,订单详情获取出错,请重试!"))); return; } decimal order_amount = modelorders.payable_amount; string subject = MXRequest.GetFormString("pay_subject"); if (order_no == "" || order_amount == 0) { Response.Redirect(new Web.UI.BasePage().linkurl("error", "?msg=" + Utils.UrlEncode("对不起,您提交的参数有误!"))); return; } //检查是否已登录 Model.users userModel = new Web.UI.BasePage().GetUserInfo(); if (userModel == null) { Response.Redirect(new Web.UI.BasePage().linkurl("payment", "login")); //尚未登录 return; } if (userModel.amount < order_amount) { Response.Redirect(new Web.UI.BasePage().linkurl("payment", "recharge")); //账户的余额不足 return; } if (order_no.StartsWith("B")) //B开头为商品订单 { BLL.orders bll = new BLL.orders(); Model.orders model = bll.GetModel(order_no); if (model == null) { Response.Redirect(new Web.UI.BasePage().linkurl("error", "?msg=" + Utils.UrlEncode("对不起,商品订单号不存在!"))); return; } if (model.payment_status == 1) { //执行扣取账户金额 int result = new BLL.user_amount_log().Add(userModel.id, userModel.user_name, MXEnums.AmountTypeEnum.BuyGoods.ToString(), order_no, model.payment_id, -1 * order_amount, subject, 1); if (result > 0) { //更改订单状态 bool result1 = bll.UpdateField(order_no, "status=2,payment_status=2,payment_time='" + DateTime.Now + "'"); if (!result1) { Response.Redirect(new Web.UI.BasePage().linkurl("payment", "error")); return; } //扣除积分 if (model.point < 0) { new BLL.user_point_log().Add(model.user_id, model.user_name, model.point, "换购扣除积分,订单号:" + model.order_no, false); } } else { Response.Redirect(new Web.UI.BasePage().linkurl("payment", "error")); return; } } //支付成功 Response.Redirect(new Web.UI.BasePage().linkurl("payment", "succeed", order_no)); return; } Response.Redirect(new Web.UI.BasePage().linkurl("error", "?msg=" + Utils.UrlEncode("对不起,找不到需要支付的订单类型!"))); return; }
protected void Page_Load(object sender, EventArgs e) { SortedDictionary <string, string> sPara = GetRequestPost(); if (sPara.Count > 0)//判断是否有带返回参数 { Notify aliNotify = new Notify(); bool verifyResult = aliNotify.Verify(sPara, AXRequest.GetString("notify_id"), AXRequest.GetString("sign")); //写日志 //System.IO.File.AppendAllText(Utils.GetMapPath("alipaylog.txt"), "验证结果:" + verifyResult.ToString() + "\n", System.Text.Encoding.UTF8); if (verifyResult) //验证成功 { string trade_no = AXRequest.GetString("trade_no"); //支付宝交易号 string order_no = AXRequest.GetString("out_trade_no").ToUpper(); //获取订单号 string total_fee = AXRequest.GetString("total_fee"); //获取总金额 string trade_status = AXRequest.GetString("trade_status"); //交易状态 if (trade_status == "TRADE_FINISHED" || trade_status == "TRADE_SUCCESS") { if (order_no.StartsWith("R")) //充值订单 { BLL.user_amount_log bll = new BLL.user_amount_log(); Model.user_amount_log model = bll.GetModel(order_no); if (model == null) { Response.Write("该订单号不存在"); return; } if (model.status == 1) //已成功 { Response.Write("success"); return; } if (model.value != decimal.Parse(total_fee)) { Response.Write("订单金额和支付金额不相符"); return; } model.trade_no = trade_no; model.status = 1; model.complete_time = DateTime.Now; bool result = bll.Update(model); if (!result) { Response.Write("修改订单状态失败"); return; } } else if (order_no.StartsWith("B")) //商品订单 { //写日志 //System.IO.File.AppendAllText(Utils.GetMapPath("alipaylog.txt"), "商品订单\n", System.Text.Encoding.UTF8); BLL.orders bll = new BLL.orders(); Model.orders model = bll.GetModel(order_no); if (model == null) { //写日志 //System.IO.File.AppendAllText(Utils.GetMapPath("alipaylog.txt"), "订单号:" + order_no + "不存在\n", System.Text.Encoding.UTF8); Response.Write("该订单号不存在"); return; } if (model.payment_status == 2) //已付款 { //写日志 //System.IO.File.AppendAllText(Utils.GetMapPath("alipaylog.txt"), "订单号:" + order_no + "已付款\n", System.Text.Encoding.UTF8); Response.Write("success"); return; } if (model.order_amount != decimal.Parse(total_fee)) { //写日志 //System.IO.File.AppendAllText(Utils.GetMapPath("alipaylog.txt"), "订单号:" + order_no + "订单金额" + model.order_amount + "和支付金额" + total_fee + "不相符\n", System.Text.Encoding.UTF8); Response.Write("订单金额和支付金额不相符"); return; } bool result = bll.UpdateField(order_no, "trade_no='" + trade_no + "',status=2,payment_status=2,payment_time='" + DateTime.Now + "'"); if (!result) { Response.Write("修改订单状态失败"); return; } //写日志 //System.IO.File.AppendAllText(Utils.GetMapPath("alipaylog.txt"), "修改订单状态:" + result.ToString() + "\n", System.Text.Encoding.UTF8); //扣除积分 if (model.point < 0) { new BLL.user_point_log().Add(model.user_id, model.user_name, model.point, "换购扣除积分,订单号:" + model.order_no, false); } } } Response.Write("success"); //请不要修改或删除 } else//验证失败 { Response.Write("fail"); } } else { Response.Write("无通知参数"); } }
protected void Page_Load(object sender, EventArgs e) { //读取站点配置信息 Model.siteconfig siteConfig = new BLL.siteconfig().loadConfig(); //=============================获得订单信息================================ string order_no = MXRequest.GetFormString("pay_order_no").ToUpper(); //订单号 decimal order_amount = MXRequest.GetFormDecimal("pay_order_amount", 0); //订单金额 string user_name = MXRequest.GetFormString("pay_user_name"); //支付用户名 string subject = MXRequest.GetFormString("pay_subject"); //备注说明 string trans_type = string.Empty; //交易类型1实物2虚拟 if (order_no == "" || order_amount == 0) { Response.Redirect(new Web.UI.BasePage().linkurl("error", "?msg=" + Utils.UrlEncode("对不起,您提交的参数有误!"))); return; } if (order_no.StartsWith("R")) //R开头为在线充值订单 { Model.user_amount_log model = new BLL.user_amount_log().GetModel(order_no); if (model == null) { Response.Redirect(new Web.UI.BasePage().linkurl("error", "?msg=" + Utils.UrlEncode("对不起,您充值的订单号不存在或已删除!"))); return; } if (model.value != order_amount) { Response.Redirect(new Web.UI.BasePage().linkurl("error", "?msg=" + Utils.UrlEncode("对不起,您充值的订单金额与实际金额不一致!"))); return; } trans_type = "2"; } else //B开头为商品订单 { Model.orders model = new BLL.orders().GetModel(order_no); if (model == null) { Response.Redirect(new Web.UI.BasePage().linkurl("error", "?msg=" + Utils.UrlEncode("对不起,您支付的订单号不存在或已删除!"))); return; } if (model.order_amount != order_amount) { Response.Redirect(new Web.UI.BasePage().linkurl("error", "?msg=" + Utils.UrlEncode("对不起,您支付的订单金额与实际金额不一致!"))); return; } trans_type = "1"; } //检查会员还是匿名 if (user_name != "") { user_name = "支付会员:" + user_name; } else { user_name = "匿名用户"; } //===============================请求参数================================== //创建RequestHandler实例 RequestHandler reqHandler = new RequestHandler(Context); //初始化 reqHandler.init(); //设置密钥 reqHandler.setKey(TenpayUtil.key); reqHandler.setGateUrl("https://gw.tenpay.com/gateway/pay.htm"); //----------------------------- //设置支付参数 //----------------------------- reqHandler.setParameter("partner", TenpayUtil.partner); //商户号 reqHandler.setParameter("out_trade_no", order_no); //商家订单号 reqHandler.setParameter("total_fee", (Convert.ToDouble(order_amount) * 100).ToString()); //商品金额,以分为单位 reqHandler.setParameter("return_url", TenpayUtil.return_url); //交易完成后跳转的URL reqHandler.setParameter("notify_url", TenpayUtil.notify_url); //接收财付通通知的URL reqHandler.setParameter("body", user_name); //商品描述 reqHandler.setParameter("bank_type", "DEFAULT"); //银行类型(中介担保时此参数无效) reqHandler.setParameter("spbill_create_ip", Page.Request.UserHostAddress); //用户的公网ip,不是商户服务器IP reqHandler.setParameter("fee_type", "1"); //币种,1人民币 reqHandler.setParameter("subject", siteConfig.webname + "-" + subject); //商品名称(中介交易时必填) //系统可选参数 reqHandler.setParameter("sign_type", "MD5"); reqHandler.setParameter("service_version", "1.0"); reqHandler.setParameter("input_charset", "UTF-8"); reqHandler.setParameter("sign_key_index", "1"); //业务可选参数 reqHandler.setParameter("product_fee", "0"); //商品费用,必须保证transport_fee + product_fee=total_fee reqHandler.setParameter("transport_fee", "0"); //物流费用,必须保证transport_fee + product_fee=total_fee reqHandler.setParameter("time_start", DateTime.Now.ToString("yyyyMMddHHmmss")); //订单生成时间,格式为yyyymmddhhmmss reqHandler.setParameter("time_expire", ""); //订单失效时间,格式为yyyymmddhhmmss reqHandler.setParameter("buyer_id", ""); //买方财付通账号 reqHandler.setParameter("goods_tag", ""); //商品标记 reqHandler.setParameter("trade_mode", TenpayUtil.type); //交易模式,1即时到账(默认),2中介担保,3后台选择(买家进支付中心列表选择) reqHandler.setParameter("transport_desc", ""); //物流说明 reqHandler.setParameter("trans_type", "1"); //交易类型,1实物交易,2虚拟交易 reqHandler.setParameter("agentid", ""); //平台ID reqHandler.setParameter("agent_type", ""); //代理模式,0无代理(默认),1表示卡易售模式,2表示网店模式 reqHandler.setParameter("seller_id", ""); //卖家商户号,为空则等同于partner //获取请求带参数的url string requestUrl = reqHandler.getRequestURL(); //实现自动跳转=============================== StringBuilder sbHtml = new StringBuilder(); sbHtml.Append("<form id='tenpaysubmit' name='tenpaysubmit' action='" + reqHandler.getGateUrl() + "' method='get'>"); Hashtable ht = reqHandler.getAllParameters(); foreach (DictionaryEntry de in ht) { sbHtml.Append("<input type=\"hidden\" name=\"" + de.Key + "\" value=\"" + de.Value + "\" >\n"); } //submit按钮控件请不要含有name属性 sbHtml.Append("<input type='submit' value='确认' style='display:none;'></form>"); sbHtml.Append("<script>document.forms['tenpaysubmit'].submit();</script>"); Response.Write(sbHtml.ToString()); }
protected void Page_Load(object sender, EventArgs e) { //读取站点配置信息 Model.siteconfig siteConfig = new BLL.siteconfig().loadConfig(); //=============================获得订单信息================================ string order_no = AXRequest.GetFormString("pay_order_no").ToUpper(); decimal order_amount = AXRequest.GetFormDecimal("pay_order_amount", 0); string user_name = AXRequest.GetFormString("pay_user_name"); string subject = AXRequest.GetFormString("pay_subject"); //以下" + Resources.lang.Receiver+ "信息 string receive_name = string.Empty; //" + Resources.lang.Receiver+ "姓名 string receive_address = string.Empty; //" + Resources.lang.Receiver+ "地址 string receive_zip = string.Empty; //" + Resources.lang.Receiver+ "邮编 string receive_phone = string.Empty; //" + Resources.lang.Receiver+ "电话 string receive_mobile = string.Empty; //" + Resources.lang.Receiver+ "手机 //检查参数是否正确 if (order_no == "" || order_amount == 0) { Response.Redirect(new Web.UI.BasePage().linkurl("error", "?msg=" + Utils.UrlEncode("对不起,您提交的参数有误!"))); return; } if (order_no.StartsWith("R")) //R开头为在线充值订单 { Model.user_amount_log model = new BLL.user_amount_log().GetModel(order_no); if (model == null) { Response.Redirect(new Web.UI.BasePage().linkurl("error", "?msg=" + Utils.UrlEncode("对不起,您充值的订单号不存在或已删除!"))); return; } if (model.value != order_amount) { Response.Redirect(new Web.UI.BasePage().linkurl("error", "?msg=" + Utils.UrlEncode("对不起,您充值的" + Resources.lang.amount + "与实际金额不一致!"))); return; } //取得用户信息 Model.users userModel = new BLL.users().GetModel(model.user_id); if (userModel == null) { Response.Redirect(new Web.UI.BasePage().linkurl("error", "?msg=" + Utils.UrlEncode("对不起,用户账户不存在或已删除!"))); return; } receive_name = userModel.nick_name; receive_address = userModel.address; receive_phone = userModel.telphone; receive_mobile = userModel.mobile; } else //B开头为商品订单 { Model.orders model = new BLL.orders().GetModel(order_no); if (model == null) { Response.Redirect(new Web.UI.BasePage().linkurl("error", "?msg=" + Utils.UrlEncode("对不起,您支付的订单号不存在或已删除!"))); return; } if (model.order_amount != order_amount) { Response.Redirect(new Web.UI.BasePage().linkurl("error", "?msg=" + Utils.UrlEncode("对不起,您支付的" + Resources.lang.amount + "与实际金额不一致!"))); return; } receive_name = model.accept_name; receive_address = model.address; receive_zip = model.post_code; receive_phone = model.telphone; receive_mobile = model.mobile; } if (user_name != "") { user_name = "支付会员:" + user_name; } else { user_name = "匿名用户"; } //===============================请求参数================================== //把请求参数打包成数组 SortedDictionary <string, string> sParaTemp = new SortedDictionary <string, string>(); sParaTemp.Add("payment_type", "1"); //收款类型1商品购买 sParaTemp.Add("show_url", siteConfig.weburl); //商品展示地址 sParaTemp.Add("out_trade_no", order_no); //网站订单号 sParaTemp.Add("subject", siteConfig.webname + "-" + subject); //订单名称 sParaTemp.Add("body", user_name); //订单描述 sParaTemp.Add("total_fee", order_amount.ToString()); //订单总金额 sParaTemp.Add("paymethod", ""); //默认支付方式 sParaTemp.Add("defaultbank", ""); //默认网银代号 sParaTemp.Add("anti_phishing_key", ""); //防钓鱼时间戳 sParaTemp.Add("exter_invoke_ip", AXRequest.GetIP()); ////获取客户端的IP地址 sParaTemp.Add("buyer_email", ""); //默认买家支付宝账号 sParaTemp.Add("royalty_type", ""); sParaTemp.Add("royalty_parameters", ""); //构造即时到帐接口表单提交HTML数据,无需修改 Service ali = new Service(); string sHtmlText = ali.Create_direct_pay_by_user(sParaTemp); Response.Write(sHtmlText); }