protected void Page_Load(object sender, EventArgs e) { //获得订单信息 string order_no = DTRequest.GetFormString("pay_order_no").ToUpper(); decimal order_amount = DTRequest.GetFormDecimal("pay_order_amount", 0); //检查参数是否正确 if (string.IsNullOrEmpty(order_no) || order_amount == 0) { Response.Redirect(new Web.UI.BasePage().linkurl("error", "?msg=" + Utils.UrlEncode("对不起,您提交的参数有误!"))); return; } //调用【网页授权获取用户信息】接口获取用户的openid和access_token JsApiConfig jsApiConfig = new JsApiConfig(); WxPayData data = new WxPayData(); data.SetValue("appid", jsApiConfig.AppId); data.SetValue("redirect_uri", HttpUtility.UrlEncode(jsApiConfig.Redirect_url)); data.SetValue("response_type", "code"); data.SetValue("scope", "snsapi_base"); data.SetValue("state", order_no + "#wechat_redirect"); //传入订单号 string url = "https://open.weixin.qq.com/connect/oauth2/authorize?" + data.ToUrl(); try { //触发微信返回code码 Response.Redirect(url);//Redirect函数会抛出ThreadAbortException异常,不用处理这个异常 } catch (System.Threading.ThreadAbortException ex) { } }
private void change_OrderStatus(HttpContext context) { int tag = DTRequest.GetFormInt("tag", 0); string oID = DTRequest.GetFormString("oID"); int status = DTRequest.GetFormInt("status", 0); int flag = DTRequest.GetFormInt("flag", 0); byte? lockstatus = Utils.ObjToByte(DTRequest.GetFormString("lockstatus")); decimal cost = DTRequest.GetFormDecimal("cost", 0); string finRemark = DTRequest.GetFormString("finRemark"); if (tag == 0) { context.Response.Write("{ \"msg\":\"参数错误\", \"status\":\"1\" }"); return; } BLL.Order bll = new BLL.Order(); Model.manager manager = new ManagePage().GetAdminInfo(); string result = string.Empty; if (tag == 1) { result = bll.updateDstatus(oID, (byte)status, manager); } else if (tag == 2) { result = bll.updateFlag(oID, (byte)flag, manager); } else if (tag == 3) { result = bll.updateLockStatus(oID, lockstatus, manager); } else if (tag == 4) { result = bll.updateCost(oID, cost, manager); } else { result = bll.updateFinRemark(oID, finRemark, manager); } if (string.IsNullOrEmpty(result)) { context.Response.Write("{ \"msg\":\"" + oID + "\", \"status\":\"0\" }"); return; } context.Response.Write("{ \"msg\":\"" + result + "\", \"status\":\"1\" }"); return; }
protected void Page_Load(object sender, EventArgs e) { //读取站点配置信息 Model.siteconfig siteConfig = new BLL.siteconfig().loadConfig(DTKeys.FILE_SITE_XML_CONFING); //获得订单信息 string order_type = DTRequest.GetFormString("pay_order_type"); //订单类型 string order_no = DTRequest.GetFormString("pay_order_no"); decimal order_amount = DTRequest.GetFormDecimal("pay_order_amount", 0); string user_name = DTRequest.GetFormString("pay_user_name"); string subject = DTRequest.GetFormString("pay_subject"); if (order_type == "" || order_no == "" || order_amount == 0 || user_name == "") { Response.Redirect(siteConfig.webpath + "error.aspx?msg=" + Utils.UrlEncode("对不起,您提交的参数有误!")); return; } ////////////////////////////////////////////请求参数//////////////////////////////////////////// //必填参数// //请与贵网站订单系统中的唯一订单号匹配 string out_trade_no = order_no; //订单名称,显示在支付宝收银台里的“商品名称”里,显示在支付宝的交易管理的“商品名称”的列表里。 string _subject = siteConfig.webname + "-" + subject; //订单描述、订单详细、订单备注,显示在支付宝收银台里的“商品描述”里 string body = "支付会员:" + user_name; //订单总金额,显示在支付宝收银台里的“应付总额”里 string total_fee = order_amount.ToString(); //扩展功能参数——默认支付方式// //默认支付方式,代码见“即时到帐接口”技术文档 string paymethod = ""; //默认网银代号,代号列表见“即时到帐接口”技术文档“附录”→“银行列表” string defaultbank = ""; //扩展功能参数——防钓鱼// //防钓鱼时间戳 string anti_phishing_key = ""; //获取客户端的IP地址,建议:编写获取客户端IP地址的程序 string exter_invoke_ip = ""; //扩展功能参数——其他// //商品展示地址,要用http:// 格式的完整路径,不允许加?id=123这类自定义参数 string show_url = siteConfig.weburl; //自定义参数,可存放任何内容(除=、&等特殊字符外),不会显示在页面上 string extra_common_param = order_type; //默认买家支付宝账号 string buyer_email = ""; string royalty_type = ""; string royalty_parameters = ""; //////////////////////////////////////////////////////////////////////////////////////////////// //把请求参数打包成数组 SortedDictionary <string, string> sParaTemp = new SortedDictionary <string, string>(); sParaTemp.Add("payment_type", "1"); sParaTemp.Add("show_url", show_url); sParaTemp.Add("out_trade_no", out_trade_no); sParaTemp.Add("subject", _subject); sParaTemp.Add("body", body); sParaTemp.Add("total_fee", total_fee); sParaTemp.Add("paymethod", paymethod); sParaTemp.Add("defaultbank", defaultbank); sParaTemp.Add("anti_phishing_key", anti_phishing_key); sParaTemp.Add("exter_invoke_ip", exter_invoke_ip); sParaTemp.Add("extra_common_param", extra_common_param); sParaTemp.Add("buyer_email", buyer_email); sParaTemp.Add("royalty_type", royalty_type); sParaTemp.Add("royalty_parameters", 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 = 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 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 = 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"); //检查参数是否正确 if (string.IsNullOrEmpty(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_recharge model = new BLL.user_recharge().GetModel(order_no); if (model == null) { Response.Redirect(new Web.UI.BasePage().linkurl("error", "?msg=" + Utils.UrlEncode("对不起,您充值的订单号不存在或已删除!"))); return; } if (model.amount != order_amount) { Response.Redirect(new Web.UI.BasePage().linkurl("error", "?msg=" + Utils.UrlEncode("对不起,您充值的订单金额与实际金额不一致!"))); return; } } 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; } } if (user_name != "") { user_name = "支付会员:" + user_name; } else { user_name = "匿名用户"; } //===============================建立请求================================== string GATEWAY_NEW = "http://wappaygw.alipay.com/service/rest.htm?"; //支付宝网关地址 string format = "xml"; //返回格式,必填,不需要修改 string v = "2.0"; //必填,不需要修改 string req_id = DateTime.Now.ToString("yyyyMMddHHmmss"); //必填,须保证每次请求都是唯一 //请求业务参数详细,必填 string req_dataToken = "<direct_trade_create_req><notify_url>" + Config.Notify_url + "</notify_url><call_back_url>" + Config.Return_url + "</call_back_url><seller_account_name>" + Config.Seller_email + "</seller_account_name><out_trade_no>" + order_no + "</out_trade_no><subject>" + siteConfig.webname + "-" + subject + "</subject><total_fee>" + order_amount.ToString() + "</total_fee><merchant_url></merchant_url></direct_trade_create_req>"; //把请求参数打包成数组 Dictionary <string, string> sParaTempToken = new Dictionary <string, string>(); sParaTempToken.Add("partner", Config.Partner); sParaTempToken.Add("_input_charset", Config.Input_charset.ToLower()); sParaTempToken.Add("sec_id", Config.Sign_type.ToUpper()); sParaTempToken.Add("service", "alipay.wap.trade.create.direct"); sParaTempToken.Add("format", format); sParaTempToken.Add("v", v); sParaTempToken.Add("req_id", req_id); sParaTempToken.Add("req_data", req_dataToken); //建立请求 string sHtmlTextToken = Submit.BuildRequest(GATEWAY_NEW, sParaTempToken); //URLDECODE返回的信息 System.Text.Encoding code = System.Text.Encoding.GetEncoding(Config.Input_charset); sHtmlTextToken = HttpUtility.UrlDecode(sHtmlTextToken, code); //解析远程模拟提交后返回的信息 Dictionary <string, string> dicHtmlTextToken = Submit.ParseResponse(sHtmlTextToken); //获取token string request_token = dicHtmlTextToken["request_token"]; //业务详细,必填 string req_data = "<auth_and_execute_req><request_token>" + request_token + "</request_token></auth_and_execute_req>"; //把请求参数打包成数组 Dictionary <string, string> sParaTemp = new Dictionary <string, string>(); sParaTemp.Add("partner", Config.Partner); sParaTemp.Add("_input_charset", Config.Input_charset.ToLower()); sParaTemp.Add("sec_id", Config.Sign_type.ToUpper()); sParaTemp.Add("service", "alipay.wap.auth.authAndExecute"); sParaTemp.Add("format", format); sParaTemp.Add("v", v); sParaTemp.Add("req_data", req_data); //建立请求 string sHtmlText = Submit.BuildRequest(GATEWAY_NEW, sParaTemp, "get", "确认"); Response.Write(sHtmlText); }
protected void Page_Load(object sender, EventArgs e) { //讀取網站配置資料 Model.siteconfig siteConfig = new BLL.siteconfig().loadConfig(DTKeys.FILE_SITE_XML_CONFING); //獲得訂單資料 string order_type = DTRequest.GetFormString("pay_order_type"); //訂單類型 string order_no = DTRequest.GetFormString("pay_order_no"); decimal order_amount = DTRequest.GetFormDecimal("pay_order_amount", 0); string user_name = DTRequest.GetFormString("pay_user_name"); string subject = DTRequest.GetFormString("pay_subject"); if (order_type == "" || order_no == "" || order_amount == 0 || user_name == "") { Response.Redirect(siteConfig.webpath + "error.aspx?msg=" + Utils.UrlEncode("對不起,您送出的參數有誤!")); return; } ////////////////////////////////////////////請求參數//////////////////////////////////////////// //必填參數// //請與貴網站訂單系統中的唯一訂單號匹配 string out_trade_no = order_no; //訂單名稱,顯示在支付寶收銀台裡的“商品名稱”裡,顯示在支付寶的交易管理的“商品名稱”的列表裡。 string _subject = siteConfig.webname + "-" + subject; //訂單描述、訂單詳細、訂單備註,顯示在支付寶收銀台裡的“商品描述”裡 string body = "支付會員:" + user_name; //訂單總金額,顯示在支付寶收銀台裡的“應付總額”裡 string total_fee = order_amount.ToString(); //擴展功能參數——預設支付方式// //預設支付方式,代碼見“即時到帳介面”技術文檔 string paymethod = ""; //默認網銀代號,代號列表見“即時到帳介面”技術文檔“附錄”→“銀行列表” string defaultbank = ""; //擴展功能參數——防釣魚// //防釣魚時間戳記 string anti_phishing_key = ""; //獲取用戶端的IP地址,建議:編寫獲取用戶端IP位址的程式 string exter_invoke_ip = ""; //擴展功能參數——其他// //商品展示地址,要用http:// 格式的完整路徑,不允許加?id=123這類自訂參數 string show_url = siteConfig.weburl; //自訂參數,可存放任何內容(除=、&等特殊字元外),不會顯示在頁面上 string extra_common_param = order_type; //默認買家支付寶帳號 string buyer_email = ""; string royalty_type = ""; string royalty_parameters = ""; //////////////////////////////////////////////////////////////////////////////////////////////// //把請求參數打包成陣列 SortedDictionary <string, string> sParaTemp = new SortedDictionary <string, string>(); sParaTemp.Add("payment_type", "1"); sParaTemp.Add("show_url", show_url); sParaTemp.Add("out_trade_no", out_trade_no); sParaTemp.Add("subject", _subject); sParaTemp.Add("body", body); sParaTemp.Add("total_fee", total_fee); sParaTemp.Add("paymethod", paymethod); sParaTemp.Add("defaultbank", defaultbank); sParaTemp.Add("anti_phishing_key", anti_phishing_key); sParaTemp.Add("exter_invoke_ip", exter_invoke_ip); sParaTemp.Add("extra_common_param", extra_common_param); sParaTemp.Add("buyer_email", buyer_email); sParaTemp.Add("royalty_type", royalty_type); sParaTemp.Add("royalty_parameters", 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) { //获得订单信息 int site_payment_id = 0; //订单支付方式 string order_no = DTRequest.GetFormString("pay_order_no").ToUpper(); decimal order_amount = DTRequest.GetFormDecimal("pay_order_amount", 0); //检查参数是否正确 if (string.IsNullOrEmpty(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_recharge model = new BLL.user_recharge().GetModel(order_no); if (model == null) { Response.Redirect(new Web.UI.BasePage().linkurl("error", "?msg=" + Utils.UrlEncode("对不起,您充值的订单号不存在或已删除!"))); return; } if (model.amount != order_amount) { Response.Redirect(new Web.UI.BasePage().linkurl("error", "?msg=" + Utils.UrlEncode("对不起,您充值的订单金额与实际金额不一致!"))); return; } site_payment_id = model.payment_id; //站点支付方式ID } 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; } site_payment_id = model.payment_id; //站点支付方式ID } //调用【网页授权获取用户信息】接口获取用户的openid和access_token JsApiConfig jsApiConfig = new JsApiConfig(site_payment_id); WxPayData data = new WxPayData(); data.SetValue("appid", jsApiConfig.AppId); data.SetValue("redirect_uri", HttpUtility.UrlEncode(jsApiConfig.Redirect_url)); data.SetValue("response_type", "code"); data.SetValue("scope", "snsapi_base"); data.SetValue("state", order_no + "#wechat_redirect"); //传入订单号 string url = "https://open.weixin.qq.com/connect/oauth2/authorize?" + data.ToUrl(); try { //触发微信返回code码 Response.Redirect(url);//Redirect函数会抛出ThreadAbortException异常,不用处理这个异常 } catch (System.Threading.ThreadAbortException ex) { } }
protected void Page_Load(object sender, EventArgs e) { //读取站点配置信息 Model.siteconfig siteConfig = new BLL.siteconfig().loadConfig(); //系统配置 Config xmlConfig = new Config(); //读取配置 //=============================获得订单信息================================ 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_recharge model = new BLL.user_recharge().GetModel(order_no); if (model == null) { Response.Redirect(new Web.UI.BasePage().linkurl("error", "?msg=" + Utils.UrlEncode("对不起,您充值的订单号不存在或已删除!"))); return; } if (model.amount != 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 (!string.IsNullOrEmpty(user_name)) { user_name = "支付会员:" + user_name; } else { user_name = "匿名用户"; } //===============================加密签名================================== string moneytype = "CNY"; // 拼凑加密串=订单金额+币种+订单号+商户号+返回地址+商户MD5密钥 string signtext = order_amount + moneytype + order_no + xmlConfig.Partner + xmlConfig.Return_url + xmlConfig.Key; string md5info = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(signtext, "md5").ToUpper(); //===============================请求参数================================== //把请求参数打包成数组 SortedDictionary <string, string> sParaTemp = new SortedDictionary <string, string>(); sParaTemp.Add("v_mid", xmlConfig.Partner); //商户编号 sParaTemp.Add("v_oid", order_no); //网站订单号 sParaTemp.Add("v_amount", order_amount.ToString()); //订单总金额 sParaTemp.Add("v_moneytype", moneytype); //币种 sParaTemp.Add("v_url", xmlConfig.Return_url); //返回地址 sParaTemp.Add("remark2", "[url:=" + xmlConfig.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 void Page_Load(object sender, EventArgs e) { Rain.Model.siteconfig siteconfig = new Rain.BLL.siteconfig().loadConfig(); TenpayUtil tenpayUtil = new TenpayUtil(); string upper = DTRequest.GetFormString("pay_order_no").ToUpper(); Decimal formDecimal = DTRequest.GetFormDecimal("pay_order_amount", new Decimal(0)); string formString1 = DTRequest.GetFormString("pay_user_name"); string formString2 = DTRequest.GetFormString("pay_subject"); string str = string.Empty; if (upper == "" || formDecimal == new Decimal(0)) { this.Response.Redirect(new BasePage().linkurl("error", (object)("?msg=" + Utils.UrlEncode("对不起,您提交的参数有误!")))); } else { if (upper.StartsWith("R")) { Rain.Model.user_recharge model = new Rain.BLL.user_recharge().GetModel(upper); if (model == null) { this.Response.Redirect(new BasePage().linkurl("error", (object)("?msg=" + Utils.UrlEncode("对不起,您充值的订单号不存在或已删除!")))); return; } if (model.amount != formDecimal) { this.Response.Redirect(new BasePage().linkurl("error", (object)("?msg=" + Utils.UrlEncode("对不起,您充值的订单金额与实际金额不一致!")))); return; } str = "2"; } else { Rain.Model.orders model = new Rain.BLL.orders().GetModel(upper); if (model == null) { this.Response.Redirect(new BasePage().linkurl("error", (object)("?msg=" + Utils.UrlEncode("对不起,您支付的订单号不存在或已删除!")))); return; } if (model.order_amount != formDecimal) { this.Response.Redirect(new BasePage().linkurl("error", (object)("?msg=" + Utils.UrlEncode("对不起,您支付的订单金额与实际金额不一致!")))); return; } str = "1"; } string parameterValue = string.IsNullOrEmpty(formString1) ? "匿名用户" : "支付会员:" + formString1; RequestHandler requestHandler = new RequestHandler(this.Context); requestHandler.init(); requestHandler.setKey(tenpayUtil.key); requestHandler.setGateUrl("https://gw.tenpay.com/gateway/pay.htm"); requestHandler.setParameter("partner", tenpayUtil.partner); requestHandler.setParameter("out_trade_no", upper); requestHandler.setParameter("total_fee", (Convert.ToDouble(formDecimal) * 100.0).ToString()); requestHandler.setParameter("return_url", tenpayUtil.return_url); requestHandler.setParameter("notify_url", tenpayUtil.notify_url); requestHandler.setParameter("body", parameterValue); requestHandler.setParameter("bank_type", "DEFAULT"); requestHandler.setParameter("spbill_create_ip", this.Page.Request.UserHostAddress); requestHandler.setParameter("fee_type", "1"); requestHandler.setParameter("subject", siteconfig.webname + "-" + formString2); requestHandler.setParameter("sign_type", "MD5"); requestHandler.setParameter("service_version", "1.0"); requestHandler.setParameter("input_charset", "UTF-8"); requestHandler.setParameter("sign_key_index", "1"); requestHandler.setParameter("product_fee", "0"); requestHandler.setParameter("transport_fee", "0"); requestHandler.setParameter("time_start", DateTime.Now.ToString("yyyyMMddHHmmss")); requestHandler.setParameter("time_expire", ""); requestHandler.setParameter("buyer_id", ""); requestHandler.setParameter("goods_tag", ""); requestHandler.setParameter("trade_mode", tenpayUtil.type); requestHandler.setParameter("transport_desc", ""); requestHandler.setParameter("trans_type", "1"); requestHandler.setParameter("agentid", ""); requestHandler.setParameter("agent_type", ""); requestHandler.setParameter("seller_id", ""); requestHandler.getRequestURL(); StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append("<form id='tenpaysubmit' name='tenpaysubmit' action='" + requestHandler.getGateUrl() + "' method='get'>"); foreach (DictionaryEntry allParameter in requestHandler.getAllParameters()) { stringBuilder.Append("<input type=\"hidden\" name=\"" + allParameter.Key + "\" value=\"" + allParameter.Value + "\" >\n"); } stringBuilder.Append("<input type='submit' value='确认' style='display:none;'></form>"); stringBuilder.Append("<script>document.forms['tenpaysubmit'].submit();</script>"); this.Response.Write(stringBuilder.ToString()); } }
protected void Page_Load(object sender, EventArgs e) { //读取站点配置信息 Model.sysconfig sysConfig = new BLL.sysconfig().loadConfig(); int site_payment_id = 0; //订单支付方式 //=============================获得订单信息================================ 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"); //检查参数是否正确 if (string.IsNullOrEmpty(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_recharge model = new BLL.user_recharge().GetModel(order_no); if (model == null) { Response.Redirect(new Web.UI.BasePage().linkurl("error", "?msg=" + Utils.UrlEncode("对不起,您充值的订单号不存在或已删除!"))); return; } if (model.amount != order_amount) { Response.Redirect(new Web.UI.BasePage().linkurl("error", "?msg=" + Utils.UrlEncode("对不起,您充值的订单金额与实际金额不一致!"))); return; } site_payment_id = model.payment_id; //站点支付方式ID } 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; } site_payment_id = model.payment_id; //站点支付方式ID } if (user_name != "") { user_name = "支付会员:" + user_name; } else { user_name = "匿名用户"; } //===============================建立请求================================== string GATEWAY_NEW = "https://mapi.alipay.com/gateway.do?"; //支付宝新网关地址 Dictionary <string, string> sParaTemp = new Dictionary <string, string>(); Config config = new Config(site_payment_id); sParaTemp.Add("partner", config.Partner); sParaTemp.Add("seller_id", config.Partner); sParaTemp.Add("_input_charset", config.Input_charset.ToLower()); sParaTemp.Add("service", "alipay.wap.create.direct.pay.by.user"); sParaTemp.Add("payment_type", "1"); sParaTemp.Add("notify_url", config.Notify_url); sParaTemp.Add("return_url", config.Return_url); sParaTemp.Add("out_trade_no", order_no); sParaTemp.Add("subject", sysConfig.webname + "-" + subject); sParaTemp.Add("total_fee", order_amount.ToString()); sParaTemp.Add("show_url", sysConfig.weburl); sParaTemp.Add("app_pay", "Y");//启用此参数可唤起钱包APP支付。 sParaTemp.Add("body", user_name); //建立请求 Submit submit = new Submit(site_payment_id); string sHtmlText = submit.BuildRequest(GATEWAY_NEW, sParaTemp, "get", "确认"); Response.Write(sHtmlText); }
protected void Page_Load(object sender, EventArgs e) { //读取站点配置信息 Model.sysconfig sysConfig = new BLL.sysconfig().loadConfig(); int site_payment_id = 0; //订单支付方式 //=============================获得订单信息================================ 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"); //检查参数是否正确 if (string.IsNullOrEmpty(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_recharge model = new BLL.user_recharge().GetModel(order_no); if (model == null) { Response.Redirect(new Web.UI.BasePage().linkurl("error", "?msg=" + Utils.UrlEncode("对不起,您充值的订单号不存在或已删除!"))); return; } if (model.amount != order_amount) { Response.Redirect(new Web.UI.BasePage().linkurl("error", "?msg=" + Utils.UrlEncode("对不起,您充值的订单金额与实际金额不一致!"))); return; } if (model.status == 1) { Response.Redirect(new Web.UI.BasePage().linkurl("payment", "?action=succeed&order_no=" + order_no)); return; } site_payment_id = model.payment_id; //站点支付方式ID } 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; } if (model.payment_status == 2) { Response.Redirect(new Web.UI.BasePage().linkurl("payment", "?action=succeed&order_no=" + order_no)); return; } site_payment_id = model.payment_id; //站点支付方式ID } if (user_name != "") { user_name = "支付会员:" + user_name; } else { user_name = "匿名用户"; } //===========================调用统一下单接口============================== string sendUrl = "https://api.mch.weixin.qq.com/pay/unifiedorder"; NativeConfig nativeConfig = new NativeConfig(site_payment_id); WxPayData data = new WxPayData(); data.SetValue("body", user_name); //商品描述 data.SetValue("detail", sysConfig.webname + "-" + subject); //商品详情 data.SetValue("out_trade_no", order_no); //商户订单号 data.SetValue("total_fee", (Convert.ToDouble(order_amount) * 100).ToString()); //订单总金额,以分为单位 data.SetValue("trade_type", "NATIVE"); //交易类型 data.SetValue("product_id", order_no); //商品ID data.SetValue("notify_url", nativeConfig.Notify_url); //异步通知url data.SetValue("spbill_create_ip", DTRequest.GetIP()); //终端IP data.SetValue("appid", nativeConfig.AppId); //公众账号ID data.SetValue("mch_id", nativeConfig.Partner); //商户号 data.SetValue("nonce_str", NativePay.GenerateNonceStr()); //随机字符串 data.SetValue("sign", data.MakeSign(nativeConfig.Key)); //签名 string xml = data.ToXml(); //转换成XML var startTime = DateTime.Now; //开始时间 string response = HttpService.Post(xml, sendUrl, false, 6); //发送请求 var endTime = DateTime.Now; //结束时间 int timeCost = (int)((endTime - startTime).TotalMilliseconds); //计算所用时间 WxPayData result = new WxPayData(); result.FromXml(response, nativeConfig.Key); NativePay.ReportCostTime(site_payment_id, sendUrl, timeCost, result); //测速上报 string codeUrl = result.GetValue("code_url").ToString(); //获得统一下单接口返回的二维码链接 imgQRCode.ImageUrl = "qrcode.aspx?data=" + HttpUtility.UrlEncode(codeUrl); litText.Text = order_amount.ToString("#0.00"); }
protected void Page_Load(object sender, EventArgs e) { //读取站点配置信息 Model.siteconfig siteConfig = new BLL.siteconfig().loadConfig(DTKeys.FILE_SITE_XML_CONFING); string order_type = DTRequest.GetFormString("pay_order_type"); //订单类型 string order_no = DTRequest.GetFormString("pay_order_no"); decimal order_amount = DTRequest.GetFormDecimal("pay_order_amount", 0); string subject = DTRequest.GetFormString("pay_subject"); if (order_no == "" || order_amount == 0) { Response.Redirect(siteConfig.webpath + "error.aspx?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_type.ToLower() == DTEnums.AmountTypeEnum.BuyGoods.ToString().ToLower()) //购买商品 { BLL.orders bll = new BLL.orders(); Model.orders model = bll.GetModel(order_no); if (model == null) { Response.Redirect(siteConfig.webpath + "error.aspx?msg=" + Utils.UrlEncode("对不起,商品订单号不存在!")); return; } //执行扣取账户金额 int result = new BLL.amount_log().Add(userModel.id, userModel.user_name, DTEnums.AmountTypeEnum.BuyGoods.ToString(), order_no, model.payment_id, -1 * order_amount, subject, 1); if (result > 0) { //更改订单状态 bool result1 = bll.UpdateField(order_no, "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.point_log().Add(model.user_id, model.user_name, model.point, "换购扣除积分,订单号:" + model.order_no); } //支付成功 Response.Redirect(new Web.UI.BasePage().linkurl("payment1", "succeed", order_type, order_no)); return; } } Response.Redirect(siteConfig.webpath + "error.aspx?msg=" + Utils.UrlEncode("对不起,找不到需要支付的订单类型!")); return; }
protected void Page_Load(object sender, EventArgs e) { //读取站点配置信息 Model.siteconfig siteConfig = new BLL.siteconfig().loadConfig(DTKeys.FILE_SITE_XML_CONFING); //获得订单信息 string order_type = DTRequest.GetFormString("pay_order_type"); //订单类型 string order_no = DTRequest.GetFormString("pay_order_no"); //订单号 decimal order_amount = DTRequest.GetFormDecimal("pay_order_amount", 0); //订单金额 string user_name = DTRequest.GetFormString("pay_user_name"); //支付用户名 string subject = DTRequest.GetFormString("pay_subject"); //备注说明 if (order_type == "" || order_no == "" || order_amount == 0 || user_name == "") { Response.Redirect(siteConfig.webpath + "error.aspx?msg=" + Utils.UrlEncode("对不起,您提交的参数有误!")); return; } ////////////////////////////////////////////请求参数//////////////////////////////////////////// //创建RequestHandler实例 RequestHandler reqHandler = new RequestHandler(Context); //初始化 reqHandler.init(); //设置密钥 reqHandler.setKey(TenpayUtil.tenpay_key); reqHandler.setGateUrl("https://gw.tenpay.com/gateway/pay.htm"); //----------------------------- //设置支付参数 //----------------------------- reqHandler.setParameter("partner", TenpayUtil.bargainor_id); //商户号 reqHandler.setParameter("out_trade_no", order_no); //商家订单号 reqHandler.setParameter("total_fee", (Convert.ToDouble(order_amount) * 100).ToString()); //商品金额,以分为单位 reqHandler.setParameter("return_url", TenpayUtil.tenpay_return); //交易完成后跳转的URL reqHandler.setParameter("notify_url", TenpayUtil.tenpay_notify); //接收财付通通知的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("attach", order_type); //附加数据,原样返回 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(); /*Get的实现方式 * string a_link = "<a target=\"_blank\" href=\"" + requestUrl + "\">" + "财付通支付" + "</a>"; * Response.Write(a_link);*/ //实现自动跳转=============================== 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(DTKeys.FILE_SITE_XML_CONFING); string order_type = DTRequest.GetFormString("pay_order_type"); //訂單類型 string order_no = DTRequest.GetFormString("pay_order_no"); decimal order_amount = DTRequest.GetFormDecimal("pay_order_amount", 0); string subject = DTRequest.GetFormString("pay_subject"); if (order_no == "" || order_amount == 0) { Response.Redirect(siteConfig.webpath + "error.aspx?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_type.ToLower() == DTEnums.AmountTypeEnum.BuyGoods.ToString().ToLower()) //購買商品 { BLL.orders bll = new BLL.orders(); Model.orders model = bll.GetModel(order_no); if (model == null) { Response.Redirect(siteConfig.webpath + "error.aspx?msg=" + Utils.UrlEncode("對不起,商品訂單號不存在!")); return; } if (model.payment_status == 1) { //執行扣取帳戶金額 int result = new BLL.amount_log().Add(userModel.id, userModel.user_name, DTEnums.AmountTypeEnum.BuyGoods.ToString(), order_no, model.payment_id, -1 * order_amount, subject, 1); if (result > 0) { //更改訂單狀態 bool result1 = bll.UpdateField(order_no, "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.point_log().Add(model.user_id, model.user_name, model.point, "換購扣除積分,訂單號:" + model.order_no); } } else { Response.Redirect(new Web.UI.BasePage().linkurl("payment", "error")); return; } } //付款成功 Response.Redirect(new Web.UI.BasePage().linkurl("payment1", "succeed", order_type, order_no)); return; } Response.Redirect(siteConfig.webpath + "error.aspx?msg=" + Utils.UrlEncode("對不起,找不到需要付款的訂單類型!")); return; }
protected void Page_Load(object sender, EventArgs e) { //读取站点配置信息 Model.sysconfig sysConfig = new BLL.sysconfig().loadConfig(); int site_payment_id = 0; //订单支付方式 //=============================获得订单信息================================ 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"); //检查参数是否正确 if (string.IsNullOrEmpty(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_recharge model = new BLL.user_recharge().GetModel(order_no); if (model == null) { Response.Redirect(new Web.UI.BasePage().linkurl("error", "?msg=" + Utils.UrlEncode("对不起,您充值的订单号不存在或已删除!"))); return; } if (model.amount != order_amount) { Response.Redirect(new Web.UI.BasePage().linkurl("error", "?msg=" + Utils.UrlEncode("对不起,您充值的订单金额与实际金额不一致!"))); return; } site_payment_id = model.payment_id; //站点支付方式ID } 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; } site_payment_id = model.payment_id; //站点支付方式ID } 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", sysConfig.weburl); //商品展示地址 sParaTemp.Add("out_trade_no", order_no); //网站订单号 sParaTemp.Add("subject", sysConfig.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(site_payment_id); 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(DTKeys.FILE_SITE_XML_CONFING); //獲得訂單資訊 string order_type = DTRequest.GetFormString("pay_order_type"); //訂單類型 string order_no = DTRequest.GetFormString("pay_order_no"); //訂單號 decimal order_amount = DTRequest.GetFormDecimal("pay_order_amount", 0); //訂單金額 string user_name = DTRequest.GetFormString("pay_user_name"); //付款用戶名 string subject = DTRequest.GetFormString("pay_subject"); //備註說明 if (order_type == "" || order_no == "" || order_amount == 0 || user_name == "") { Response.Redirect(siteConfig.webpath + "error.aspx?msg=" + Utils.UrlEncode("對不起,您提交的參數有誤!")); return; } ////////////////////////////////////////////請求參數//////////////////////////////////////////// //創建RequestHandler實例 RequestHandler reqHandler = new RequestHandler(Context); //初始化 reqHandler.init(); //設置金鑰 reqHandler.setKey(TenpayUtil.tenpay_key); reqHandler.setGateUrl("https://gw.tenpay.com/gateway/pay.htm"); //----------------------------- //設置付款參數 //----------------------------- reqHandler.setParameter("partner", TenpayUtil.bargainor_id); //商戶號 reqHandler.setParameter("out_trade_no", order_no); //商家訂單號 reqHandler.setParameter("total_fee", (Convert.ToDouble(order_amount) * 100).ToString()); //商品金額,以分為單位 reqHandler.setParameter("return_url", TenpayUtil.tenpay_return); //交易完成後跳轉的URL reqHandler.setParameter("notify_url", TenpayUtil.tenpay_notify); //接收財付通通知的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("attach", order_type); //附加資料,原樣返回 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(); /*Get的實現方式 * string a_link = "<a target=\"_blank\" href=\"" + requestUrl + "\">" + "財付通付款" + "</a>"; * Response.Write(a_link);*/ //實現自動跳轉=============================== 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 = 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 (string.IsNullOrEmpty(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_recharge model = new BLL.user_recharge().GetModel(order_no); if (model == null) { Response.Redirect(new Web.UI.BasePage().linkurl("error", "?msg=" + Utils.UrlEncode("对不起,您充值的订单号不存在或已删除!"))); return; } if (model.amount != 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) { Rain.Model.siteconfig siteconfig = new Rain.BLL.siteconfig().loadConfig(); string upper = DTRequest.GetFormString("pay_order_no").ToUpper(); Decimal formDecimal = DTRequest.GetFormDecimal("pay_order_amount", new Decimal(0)); string formString1 = DTRequest.GetFormString("pay_user_name"); string formString2 = DTRequest.GetFormString("pay_subject"); string empty1 = string.Empty; string empty2 = string.Empty; string str1 = string.Empty; string empty3 = string.Empty; string empty4 = string.Empty; if (string.IsNullOrEmpty(upper) || formDecimal == new Decimal(0)) { this.Response.Redirect(new BasePage().linkurl("error", (object)("?msg=" + Utils.UrlEncode("对不起,您提交的参数有误!")))); } else { string str2; string address; string telphone; string mobile; if (upper.StartsWith("R")) { Rain.Model.user_recharge model1 = new Rain.BLL.user_recharge().GetModel(upper); if (model1 == null) { this.Response.Redirect(new BasePage().linkurl("error", (object)("?msg=" + Utils.UrlEncode("对不起,您充值的订单号不存在或已删除!")))); return; } if (model1.amount != formDecimal) { this.Response.Redirect(new BasePage().linkurl("error", (object)("?msg=" + Utils.UrlEncode("对不起,您充值的订单金额与实际金额不一致!")))); return; } Rain.Model.users model2 = new Rain.BLL.users().GetModel(model1.user_id); if (model2 == null) { this.Response.Redirect(new BasePage().linkurl("error", (object)("?msg=" + Utils.UrlEncode("对不起,用户账户不存在或已删除!")))); return; } str2 = model2.nick_name; address = model2.address; telphone = model2.telphone; mobile = model2.mobile; } else { Rain.Model.orders model = new Rain.BLL.orders().GetModel(upper); if (model == null) { this.Response.Redirect(new BasePage().linkurl("error", (object)("?msg=" + Utils.UrlEncode("对不起,您支付的订单号不存在或已删除!")))); return; } if (model.order_amount != formDecimal) { this.Response.Redirect(new BasePage().linkurl("error", (object)("?msg=" + Utils.UrlEncode("对不起,您支付的订单金额与实际金额不一致!")))); return; } str2 = model.accept_name; address = model.address; str1 = model.post_code; telphone = model.telphone; mobile = model.mobile; } string str3 = !(formString1 != "") ? "匿名用户" : "支付会员:" + formString1; if (Config.Type == "1") { this.Response.Write(new Service().Create_direct_pay_by_user(new SortedDictionary <string, string>() { { "payment_type", "1" }, { "show_url", siteconfig.weburl }, { "out_trade_no", upper }, { "subject", siteconfig.webname + "-" + formString2 }, { "body", str3 }, { "total_fee", formDecimal.ToString() }, { "paymethod", "" }, { "defaultbank", "" }, { "anti_phishing_key", "" }, { "exter_invoke_ip", DTRequest.GetIP() }, { "buyer_email", "" }, { "royalty_type", "" }, { "royalty_parameters", "" } })); } else { this.Response.Write(new Service().Create_partner_trade_by_buyer(new SortedDictionary <string, string>() { { "payment_type", "1" }, { "out_trade_no", upper }, { "subject", siteconfig.webname + "-" + formString2 }, { "price", formDecimal.ToString() }, { "quantity", "1" }, { "logistics_fee", "0.00" }, { "logistics_type", "EXPRESS" }, { "logistics_payment", "SELLER_PAY" }, { "body", str3 }, { "show_url", siteconfig.weburl }, { "receive_name", str2 }, { "receive_address", address }, { "receive_zip", str1 }, { "receive_phone", telphone }, { "receive_mobile", mobile } })); } } }