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); }
protected void Page_Load(object sender, EventArgs e) { //读取站点配置信息 Model.siteconfig siteConfig = new BLL.siteconfig().loadConfig(); string order_no = AXRequest.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 = AXRequest.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, AXEnums.AmountTypeEnum.BuyGoods.ToString(), order_no, model.payment_id, -1 * order_amount, subject, 1); if (result > 0) { //更改" + Resources.lang.orderStatus+ " 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) { //读取站点配置信息 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"); //备注说明 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", "1"); //交易模式,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 btnSubmit_Click(object sender, EventArgs e) { //检查商品 IList <cart_items> iList = ShopCart.GetList(); //保存订单======================================================================= ax_orders model = new ax_orders(); model.order_no = Utils.GetOrderNumber(); //订单号 model.user_name = user_name.Value.Trim(); model.user_tel = user_tel.Value.Trim(); string province = AXRequest.GetFormString("province"); string city = AXRequest.GetFormString("city"); string area = AXRequest.GetFormString("area"); model.area = province + "," + city + "," + area; model.address = address.Value.Trim(); model.message = message.Value.Trim(); string goods_title = ""; //商品详细列表 List <ax_order_goods> gls = new List <ax_order_goods>(); foreach (cart_items item in iList) { ax_ticket myt = new ax_ticket(); myt.GetModel(item.id); goods_title = new ax_article().GetTitle(Convert.ToInt32(myt.pid)); gls.Add(new ax_order_goods { ticket_id = item.id, goods_id = myt.pid, goods_title = goods_title, ticket_no = item.ticket_no }); } model.order_goods = gls; if (model.Add() == 0) { this.ClientScript.RegisterStartupScript(this.GetType(), "1", "<script> $.alert(\"<div class='message'>订单保存过程中发生错误,请重新提交!</div>\").time(5000);</script>"); return; } #region 发送短信并入库 ax_syssetting mySysSetting = new ax_syssetting(); mySysSetting.GetModel(1); if (mySysSetting.MsgNum > 0 && mySysSetting.MsgOn == 1) { string user = mySysSetting.MsgName; string pass = FormsAuthentication.HashPasswordForStoringInConfigFile(FormsAuthentication.HashPasswordForStoringInConfigFile(mySysSetting.MsgPwd, "MD5").ToLower(), "MD5").ToLower(); string mobile = user_tel.Value.Trim(); string content = "尊敬的" + user_name.Value.Trim() + "客户,您的" + goods_title + "订单号:" + model.order_no + "提交成功!我们会尽快给您安排发货,请注意查收!发货信息将会发送到您的手机上!请您留意!【AH水产】"; string contentEncode = HttpUtility.UrlEncode(content, System.Text.Encoding.GetEncoding("utf-8")); string sms_url = " http://210.5.152.50:7100/submit?userName="******"&body={'content':'" + contentEncode + "','passWord':'******','expId':'','phones':['" + mobile + "'],'productId':'21','sendTime':''}&isEncrypt=0"; SMS mysms = new SMS(); mysms.GetHtmlFromUrl(sms_url); ax_msglist my = new ax_msglist(); my.CardNum = model.order_no; my.MemberName = user_name.Value.Trim(); my.MemberTel = mobile; my.Message = content; my.SendTime = System.DateTime.Now; my.OP = "提货短信"; my.Add(); mySysSetting.MsgNum = mySysSetting.MsgNum - 1; mySysSetting.UpdateMsgNum(); } #endregion //清空购物车 ShopCart.Clear("0"); PanelOrder.Visible = false; this.ClientScript.RegisterStartupScript(this.GetType(), "1", "<script> $.alert(\"<div class='message'>恭喜您!订单提交成功!我们会尽快给您安排发货,请注意查收!发货信息将会发送到您的手机上!请您留意!</div>\").time(5000);</script>"); }