public void PostProcessPayment(PaymentInfo order) { DateTime datatime = DateTime.Now; string v_hms = datatime.ToString("HHmmss", System.Globalization.DateTimeFormatInfo.InvariantInfo); string v_ymd = datatime.ToString("yyyyMMdd", System.Globalization.DateTimeFormatInfo.InvariantInfo); string icbcAmount = decimal.Ceiling(order.OrderAmount.ToDecimal() * 100).ToString(); //订单金额,以分为单位 StringBuilder TranData = new StringBuilder(); TranData.Append("<?xml version=\"1.0\" encoding=\"GBK\" standalone=\"no\"?>"); TranData.Append("<B2CReq>"); TranData.Append("<interfaceName>ICBC_PERBANK_B2C</interfaceName>"); //接口名 TranData.Append("<interfaceVersion>1.0.0.3</interfaceVersion>"); //版本号 TranData.Append("<orderInfo>"); TranData.Append("<orderDate>" + v_ymd + v_hms + "</orderDate>"); //交易日期时间格式为:YYYYMMDDHHmmss TranData.Append("<orderid>" + order.SysOrderNo + "</orderid>"); //订单号 TranData.Append("<amount>" + icbcAmount + "</amount>"); //订单金额 TranData.Append("<curType>001</curType>"); //支付币种 TranData.Append("<merID>4000EC20001125</merID>"); //商户代码 TranData.Append("<merAcct>4000023819200132437</merAcct>"); //商户账号 TranData.Append("</orderInfo>"); TranData.Append("<custom>"); TranData.Append("<verifyJoinFlag>0</verifyJoinFlag>"); //检验联名标志 TranData.Append("<Language>ZH_CN</Language>"); //语言版本 TranData.Append("</custom>"); TranData.Append("<message>"); TranData.Append("<goodsID></goodsID>"); //商品编号 TranData.Append("<goodsName></goodsName>"); //商品名称 TranData.Append("<goodsNum></goodsNum>"); //商品数量 TranData.Append("<carriageAmt></carriageAmt>"); //已含运费金额 TranData.Append("<merHint></merHint>"); //商城提示 TranData.Append("<remark1></remark1>"); //备注字段1 TranData.Append("<remark2></remark2>"); //备注字段2 TranData.Append("<merURL>" + order.ResultNotifyURL + "</merURL>"); //返回商户URL TranData.Append("<merVAR></merVAR>"); //返回商户变量 TranData.Append("</message>"); TranData.Append("</B2CReq>"); string tranData = TranData.ToString(); ICBCEBANKUTILLib.B2CUtil icbc = new ICBCEBANKUTILLib.B2CUtil(); int IcbcNew = icbc.init(HttpContext.Current.Server.MapPath("key/icbc/ICBC_Produce.crt"), HttpContext.Current.Server.MapPath("key/icbc/ICBC_Produce.crt"), HttpContext.Current.Server.MapPath("key/icbc/ICBC_Produce.key"), "12345679"); string Icbcsign = icbc.signC(tranData, tranData.Length); string merCert = icbc.getCert(1); tranData = PayHelper.Base64Code(tranData); HttpHelper http = new HttpHelper(); http.Url = order.PayOnlineProviderUrl; http.Add("interfaceName", "ICBC_PERBANK_B2C"); //接口名 http.Add("interfaceVersion", "1.0.0.3"); //版本号 http.Add("tranData", tranData); //交易数据 http.Add("merSignMsg", Icbcsign); //订单签名数据 http.Add("merCert", merCert); //商城公匙 http.Post(); }
public void PostProcessPayment(PaymentInfo order) { //修改交通银行支付接口xml配置文件 PayHelper.ModXml("LogPath", HttpContext.Current.Server.MapPath("bocomm/log")); PayHelper.ModXml("SettlementFilePath", HttpContext.Current.Server.MapPath("bocomm/settlement")); PayHelper.ModXml("MerchantCertFile", HttpContext.Current.Server.MapPath("bocomm/cert/pt9999.pfx")); PayHelper.ModXml("RootCertFile", HttpContext.Current.Server.MapPath("bocomm/cert/root.cer")); //string merID = "";//商户客户号 //string orderid = "";//订单号 //string orderContent = "";//订单内容 商家填写的其他订单信息,在个人客户页面显示 //string orderMono = "";//商家备注 不在个人客户页面显示的备注,但可在商户管理页面上显示 //string phdFlag = "1";//物流配送标志 0非物流1物流配送 //string payBatchNo = "";//商家可填入自己的批次号,对账使用 //string proxyMerName = "";//二级商户编号/或证件号码 //string proxyMerType = "";//代理商家证件类型 //string proxyMerCredentials = "";//代理商家证件号码 //string merSignMsg = "";//商家签名 detech 方式签名 string v_hms = DateTime.Now.ToString("HHmmss", System.Globalization.DateTimeFormatInfo.InvariantInfo); string v_ymd = DateTime.Now.ToString("yyyyMMdd", System.Globalization.DateTimeFormatInfo.InvariantInfo); HttpHelper http = new HttpHelper(); http.Url = order.PayOnlineProviderUrl; http.Add("interfaceVersion", "1.0.0.0");//消息版本号 http.Add("orderid", order.SysOrderNo); http.Add("orderDate", v_ymd); http.Add("orderTime", v_hms); http.Add("tranType", "0"); //交易类型:0 为B2C http.Add("amount", order.OrderAmount); http.Add("curType", "CNY"); //订单币种人民币为:CNY http.Add("notifyType", "1"); //通知方式 0 不通知 1 通知 2 转页面 http.Add("merURL", order.ResultNotifyURL); http.Add("goodsURL", ""); //取货URL http.Add("jumpSeconds", ""); //等待N秒后自动跳转取货URL,不填写则表示不自动跳转。 http.Add("netType", "0"); //渠道编号 固定填0:(html 渠道) http.Post(); }
public void PostProcessPayment(PaymentInfo order) { DateTime datatime = DateTime.Now; string v_hms = datatime.ToString("HHmmss", System.Globalization.DateTimeFormatInfo.InvariantInfo); string v_ymd = datatime.ToString("yyyyMMdd", System.Globalization.DateTimeFormatInfo.InvariantInfo); string v_mid = "1204790601"; string payOnlineKey = "a75ee55ded934c96968f747c809005b9"; string v_oid = order.SysOrderNo; string v_url = order.ResultNotifyURL; Random rnd = new Random(); int Sequence = (v_oid.Substring(v_oid.Length - 10, 10)).ToInt() + rnd.Next(1, 9);//序列号,保证唯一性 string transaction_id = v_mid + v_ymd + Sequence; string amount = decimal.Round(order.OrderAmount.ToDecimal() * 100, 0) + ""; string md5string = PayHelper.GetMD5("cmdno=1&date=" + v_ymd + "&bargainor_id=" + v_mid + "&transaction_id=" + transaction_id + "&sp_billno=" + v_oid + "&total_fee=" + amount + "&fee_type=1&return_url=" + v_url + "&attach=my_magic_string&key=" + payOnlineKey, ""); HttpHelper http = new HttpHelper(); http.Url = order.PayOnlineProviderUrl; http.Add("cmdno", "1"); //业务代码,1表示支付 http.Add("date", v_ymd); //商户日期 http.Add("bank_type", "0"); //银行类型:财付通,0 http.Add("desc", v_oid); //交易的商品名称 http.Add("purchaser_id", ""); //用户(买方)的财付通帐户,可以为空 http.Add("bargainor_id", v_mid); //商家的商户号 http.Add("transaction_id", transaction_id); //交易号(订单号) http.Add("sp_billno", v_oid); //商户系统内部的订单号 http.Add("total_fee", amount); //总金额,以分为单位 http.Add("fee_type", "1"); //现金支付币种,1人民币 http.Add("return_url", v_url); //接收财付通返回结果的URL http.Add("attach", "attachmy_magic_string"); //商家数据包,原样返回 http.Add("sign", md5string); //MD5签名 http.Post(); }
public void PostProcessPayment(PaymentInfo order) { //修改农行支付接口配置文件 PayHelper.SaveConfig("TrustPayCertFile", HttpContext.Current.Server.MapPath("key/abc/TrustPay.cer")); PayHelper.SaveConfig("TrustStoreFile", HttpContext.Current.Server.MapPath("key/abc/abc.truststore")); PayHelper.SaveConfig("MerchantCertFile", HttpContext.Current.Server.MapPath("key/abc/ABC002.pfx")); DateTime datatime = new DateTime(); string OrderDate = datatime.ToString("yyyy/MM/dd", System.Globalization.DateTimeFormatInfo.InvariantInfo); string OrderTime = datatime.ToString("HH:mm:ss", System.Globalization.DateTimeFormatInfo.InvariantInfo); string OrderURL = "QueryOrderABC.aspx?QueryType=1&ON=" + order.SysOrderNo; Random m_Rnd = new Random(); //1、生成订单对象 com.hitrust.trustpay.client.b2c.Order tOrder = new com.hitrust.trustpay.client.b2c.Order(); tOrder.OrderNo = order.SysOrderNo + m_Rnd.Next(1111, 9999); //设定订单编号 (必要信息),这里加上4个随机数 tOrder.OrderDesc = ""; //设定订单说明 tOrder.OrderDate = OrderDate; //设定订单日期 (必要信息 - YYYY/MM/DD) tOrder.OrderTime = OrderTime; //设定订单时间 (必要信息 - HH:MM:SS) tOrder.OrderAmount = order.OrderAmount.ToDouble(); //设定订单金额 (必要信息) tOrder.OrderURL = OrderURL; //设定订单网址 //2、生成定单订单对象,并将订单明细加入定单中(可选信息) // com.hitrust.trustpay.client.b2c.OrderItem tOrderItem = new com.hitrust.trustpay.client.b2c.OrderItem(); // tOrderItem.ProductID = "IP000001"; // tOrderItem.ProductName = "中国移动IP卡"; // tOrderItem.UnitPrice = 1.00; // tOrderItem.Qty = 1; // tOrder.addOrderItem(tOrderItem); // tOrderItem = new com.hitrust.trustpay.client.b2c.OrderItem(); // tOrderItem.ProductID = "IP000002"; // tOrderItem.ProductName = "网通IP卡"; // tOrderItem.UnitPrice = 1.00; // tOrderItem.Qty = 2; // tOrder.addOrderItem(tOrderItem); //3、生成支付请求对象 com.hitrust.trustpay.client.b2c.PaymentRequest tPaymentRequest = new com.hitrust.trustpay.client.b2c.PaymentRequest(); tPaymentRequest.Order = tOrder; //设定支付请求的订单 (必要信息) tPaymentRequest.ProductType = "1"; //设定商品种类 (必要信息) tPaymentRequest.PaymentType = "1"; //设定支付类型 tPaymentRequest.NotifyType = "0"; //设定支付结果通知类型,0-页面跳转,1-服务器端通知 tPaymentRequest.ResultNotifyURL = order.ResultNotifyURL; //设定支付结果回传网址 (必要信息) tPaymentRequest.MerchantRemarks = ""; //设定商户备注信息 tPaymentRequest.PayLinkType = "1"; //设定支付接入方式 //4、传送支付请求并取得支付网址 com.hitrust.trustpay.client.TrxResponse tTrxResponse = tPaymentRequest.postRequest(); string strMessage = ""; HttpResponse response = HttpContext.Current.Response; if (tTrxResponse.isSuccess()) { //5、支付请求提交成功,将客户端导向支付页面 response.Redirect(tTrxResponse.getValue("PaymentURL")); } else { //6、支付请求提交失败,商户自定后续动作 strMessage = "ReturnCode = [" + tTrxResponse.ReturnCode + "]<br/>" + "ErrorMessage = [" + tTrxResponse.ErrorMessage + "]<br/>"; response.Write(strMessage); } response.End(); }
public void PostProcessPayment(PaymentInfo order) { string service = "trade_create_by_buyer"; string partner = "2088101147064570"; //合作伙伴ID string sign_type = "MD5"; //签名加密方式 string subject = order.SysOrderNo, //商品名称 - 订单号 body = order.SysOrderNo, // 订单号 应支付的货款 商品描述 out_trade_no = order.SysOrderNo; //订单号 string quantity = "1"; //数量 string price = order.OrderAmount; //总金额 0.01~50000.00 string seller_email = "*****@*****.**"; //卖家账号 string key = "gebkrkj0p9wzyluaprrcilcao52sremh|2088101147064570"; //partner账户的支付宝安全校验码 string return_url = order.ResultNotifyURL; //结果返回URL string notify_url = order.ResultNotifyURL; //服务器端通知返回URL string logistics_type = "EMS"; string _input_charset = "UTF-8"; string logistics_fee = "0"; string logistics_payment = "SELLER_PAY"; //string logistics_type_1 = "EXPRESS"; //string logistics_fee_1 = "2"; //string logistics_payment_1 = "SELLER_PAY"; string payment_type = "1"; if (key.IndexOf("|") > 0) { string[] ArrMD5Key = key.Split(new char[] { '|' }); key = ArrMD5Key[0]; partner = ArrMD5Key[1]; } //构造数组; string[] Params = { "logistics_fee=" + logistics_fee, "logistics_payment=" + logistics_payment, "logistics_type=" + logistics_type, "notify_url=" + notify_url, "out_trade_no=" + out_trade_no, "partner=" + partner, "payment_type=" + payment_type, "price=" + price, "quantity=" + quantity, "return_url=" + return_url, "seller_email=" + seller_email, "service=" + service, "subject=" + subject }; //进行排序 string[] SortedParams = PayHelper.BubbleSort(Params); StringBuilder prestr = new StringBuilder(); for (int i = 0; i < SortedParams.Length; i++) { if (i == SortedParams.Length - 1) { prestr.Append(SortedParams[i]); } else { prestr.Append(SortedParams[i] + "&"); } } prestr.Append(key); string sign = PayHelper.GetMD5(prestr.ToString(), _input_charset).ToLower(); HttpHelper http = new HttpHelper(); http.Url = order.PayOnlineProviderUrl; http.Method = "GET"; http.Add("service", service); http.Add("logistics_type", logistics_type); http.Add("logistics_fee", logistics_fee); http.Add("logistics_payment", logistics_payment); http.Add("payment_type", payment_type); http.Add("seller_email", seller_email); http.Add("subject", subject); http.Add("out_trade_no", out_trade_no); http.Add("price", price); http.Add("partner", partner); http.Add("quantity", quantity); http.Add("notify_url", notify_url); http.Add("sign", sign); http.Add("sign_type", sign_type); http.Add("return_url", return_url); http.Post(); }
/// <summary> /// 根据支付方式构建表单 /// </summary> /// <param name="OrderId">订单号</param> /// <param name="payPlatID">支付平台编号</param> /// <param name="totalPrice">订单总额</param> /// <returns>表单数据</returns> public static string BuilderData(string OrderId, int payPlatID, string totalPrice) { #region 初始化参数 string v_oid = ""; //订单编号 string v_amount = ""; //实际支付金额 string v_mid = ""; //商户编号 string v_url = ""; //支付动作完成后返回到该url,支付结果以POST方式发送 string payOnlineKey = ""; //MD5私钥 //decimal vmoney = 0; //支付金额 int payPlatformId = 0; //支付平台ID string md5string; //订单MD5校验码 //int orderId; //订单ID //string userName = ""; //登录用户名 string paymentNum = ""; //支付序号 //int pointAmount = 0; //购买点券数 string _returnurl = string.Empty; //支付相关的页面放置文件夹 string PayFolder = ConfigManager.GetString("PayFolder"); //表单提交方式 string FormSubmitMethod = ""; //获取返回地址 string _port = HttpContext.Current.Request.ServerVariables["SERVER_PORT"].ToString(); _returnurl = "http://" + HttpContext.Current.Request.ServerVariables["SERVER_NAME"].ToString() + ((string.IsNullOrEmpty(_port) || _port == "80") ? "" : ":" + _port); //获得交易编号 string out_trade_no = PayHelper.GetTradeNo(); v_oid = OrderId; paymentNum = v_oid; DateTime datatime = DateTime.Now; string v_hms = datatime.ToString("HHmmss", System.Globalization.DateTimeFormatInfo.InvariantInfo); string v_ymd = datatime.ToString("yyyyMMdd", System.Globalization.DateTimeFormatInfo.InvariantInfo); StringBuilder strHiddenField = new StringBuilder(); //构造提交表单 StringBuilder md5Builder = new StringBuilder(); //构造提交加密数据 StringBuilder v_urlBuilder = new StringBuilder(); //构造返回URL string applicationName = UrlHelper.GetAppPath(); //bool isFabrication = false; string v_ShowResultUrl = v_urlBuilder.ToString() + PayFolder + "ShowResult.aspx?PayMessage=ok"; string m_PayOnlineProviderUrl = ""; payPlatformId = payPlatID; v_amount = totalPrice; #endregion #region 支付平台 switch (payPlatformId) { case 1: #region 网银在线 m_PayOnlineProviderUrl = "https://pay3.chinabank.com.cn/PayGate"; //生成返回URL v_urlBuilder.Append(PayFolder + "PayResultChinabank.aspx"); v_url = v_urlBuilder.ToString(); //生成MD5校验数据字符串 md5Builder.Append(v_amount); md5Builder.Append("0"); md5Builder.Append(v_oid); md5Builder.Append(v_mid); md5Builder.Append(v_url); md5Builder.Append(payOnlineKey); md5string = PayHelper.GetMD5(md5Builder.ToString(), "").ToUpper(); strHiddenField.Append("<input type='hidden' name='v_md5info' value='" + md5string + "'>"); strHiddenField.Append("<input type='hidden' name='v_mid' value='" + v_mid + "'>"); strHiddenField.Append("<input type='hidden' name='v_oid' value='" + v_oid + "'>"); strHiddenField.Append("<input type='hidden' name='v_amount' value='" + v_amount + "'>"); strHiddenField.Append("<input type='hidden' name='v_moneytype' value='0'>"); strHiddenField.Append("<input type='hidden' name='v_url' value='" + v_url + "'>"); break; #endregion case 2: #region 中国在线支付网 m_PayOnlineProviderUrl = "http://www.ipay.cn/4.0/bank.shtml"; v_urlBuilder.Append(PayFolder + "PayResultIpay.aspx"); v_url = v_urlBuilder.ToString(); md5Builder.Append(v_mid); md5Builder.Append(v_oid); md5Builder.Append(v_amount); md5Builder.Append("[email protected]"); md5Builder.Append(payOnlineKey); md5string = PayHelper.GetMD5(md5Builder.ToString(), ""); strHiddenField.Append("<input type='hidden' name='v_mid' value='" + v_mid + "'>"); strHiddenField.Append("<input type='hidden' name='v_oid' value='" + v_oid + "'>"); strHiddenField.Append("<input type='hidden' name='v_amount' value='" + v_amount + "'>"); strHiddenField.Append("<input type='hidden' name='v_email' value='*****@*****.**'>"); strHiddenField.Append("<input type='hidden' name='v_mobile' value='13800138000'>"); strHiddenField.Append("<input type='hidden' name='v_md5' value='" + md5string + "'>"); strHiddenField.Append("<input type='hidden' name='v_url' value='" + v_url + "'>"); break; #endregion case 3: #region 海环迅 m_PayOnlineProviderUrl = "http://pay.ips.com.cn/ipayment.aspx"; //m_PayOnlineProviderUrl = "http://pay.ips.net.cn/ipayment.aspx"; //测试接口,配合测试帐号测试 v_urlBuilder.Append(PayFolder + "PayResultIps.aspx"); v_url = v_urlBuilder.ToString(); md5Builder.Append(v_oid); md5Builder.Append(v_amount); md5Builder.Append(v_ymd); md5Builder.Append("RMB"); md5Builder.Append(payOnlineKey); md5string = PayHelper.GetMD5(md5Builder.ToString(), "").ToLower(); strHiddenField.Append("<input type='hidden' name='mer_code' value='" + v_mid + "'>"); strHiddenField.Append("<input type='hidden' name='billNo' value='" + v_oid + "'>"); strHiddenField.Append("<input type='hidden' name='amount' value='" + v_amount + "'>"); strHiddenField.Append("<input type='hidden' name='date' value='" + v_ymd + "'>"); strHiddenField.Append("<input type='hidden' name='lang' value='GB'>"); strHiddenField.Append("<input type='hidden' name='Gateway_type' value='01'>"); strHiddenField.Append("<input type='hidden' name='Currency_Type' value='RMB'>"); strHiddenField.Append("<input type='hidden' name='Merchanturl' value='" + v_url + "'>"); strHiddenField.Append("<input type='hidden' name='OrderEncodeType' value='2'>"); strHiddenField.Append("<input type='hidden' name='RetEncodeType' value='12'>"); strHiddenField.Append("<input type='hidden' name='RetType' value='0'>"); strHiddenField.Append("<input type='hidden' name='SignMD5' value='" + md5string + "'>"); strHiddenField.Append("<input type='hidden' name='ServerUrl' value=''>"); break; #endregion case 5: #region 西部支付 m_PayOnlineProviderUrl = "http://www.yeepay.com/Pay/WestPayReceiveOrderFromMerchant.asp"; v_urlBuilder.Append(PayFolder + "PayResultYeepay.aspx"); v_url = v_urlBuilder.ToString(); strHiddenField.Append("<input type='hidden' name='MerchantID' value='" + v_mid + "'>"); strHiddenField.Append("<input type='hidden' name='OrderNumber' value='" + v_oid + "'>"); strHiddenField.Append("<input type='hidden' name='OrderAmount' value='" + v_amount + "'>"); strHiddenField.Append("<input type='hidden' name='PostBackURL' value='" + v_url + "'>"); break; #endregion case 6: #region 易付通 m_PayOnlineProviderUrl = "http://pay.xpay.cn/Pay.aspx"; v_urlBuilder.Append(PayFolder + "PayResultXpay.aspx"); v_url = v_urlBuilder.ToString(); md5Builder.Append(payOnlineKey); md5Builder.Append(":"); md5Builder.Append(v_amount); md5Builder.Append(","); md5Builder.Append(v_oid); md5Builder.Append(","); md5Builder.Append(v_mid); md5Builder.Append(",bank,,sell,,2.0"); md5string = PayHelper.GetMD5(md5Builder.ToString(), "").ToLower(); strHiddenField.Append("<input type='hidden' name='Tid' value='" + v_mid + "'>"); strHiddenField.Append("<input type='hidden' name='Bid' value='" + v_oid + "'>"); strHiddenField.Append("<input type='hidden' name='Prc' value='" + v_amount + "'>"); strHiddenField.Append("<input type='hidden' name='url' value='" + v_url + "'>"); strHiddenField.Append("<input type='hidden' name='Card' value='bank'>"); strHiddenField.Append("<input type='hidden' name='Scard' value=''>"); strHiddenField.Append("<input type='hidden' name='ActionCode' value='sell'>"); strHiddenField.Append("<input type='hidden' name='ActionParameter' value=''>"); strHiddenField.Append("<input type='hidden' name='Ver' value='2.0'>"); strHiddenField.Append("<input type='hidden' name='Pdt' value='" + applicationName + "'>"); strHiddenField.Append("<input type='hidden' name='type' value=''>"); strHiddenField.Append("<input type='hidden' name='lang' value='gb2312'>"); strHiddenField.Append("<input type='hidden' name='md' value='" + md5string + "'>"); break; #endregion case 7: #region 云网支付 m_PayOnlineProviderUrl = "https://www.cncard.net/purchase/getorder.asp"; v_urlBuilder.Append(PayFolder + "PayResultCncard.aspx"); v_url = v_urlBuilder.ToString(); md5Builder.Append(v_mid); md5Builder.Append(v_oid); md5Builder.Append(v_amount); md5Builder.Append(v_ymd); md5Builder.Append("01"); md5Builder.Append(v_url); md5Builder.Append("00"); md5Builder.Append(payOnlineKey); md5string = PayHelper.GetMD5(md5Builder.ToString(), "").ToLower(); strHiddenField.Append("<input type='hidden' name='c_mid' value='" + v_mid + "'>"); strHiddenField.Append("<input type='hidden' name='c_order' value='" + v_oid + "'>"); strHiddenField.Append("<input type='hidden' name='c_orderamount' value='" + v_amount + "'>"); strHiddenField.Append("<input type='hidden' name='c_ymd' value='" + v_ymd + "'>"); strHiddenField.Append("<input type='hidden' name='c_moneytype' value='0'>"); strHiddenField.Append("<input type='hidden' name='c_retflag' value='1'>"); strHiddenField.Append("<input type='hidden' name='c_paygate' value=''>"); strHiddenField.Append("<input type='hidden' name='c_returl' value='" + v_url + "'>"); strHiddenField.Append("<input type='hidden' name='c_memo1' value=''>"); strHiddenField.Append("<input type='hidden' name='c_memo2' value=''>"); strHiddenField.Append("<input type='hidden' name='c_language' value='0'>"); strHiddenField.Append("<input type='hidden' name='notifytype' value='0'>"); strHiddenField.Append("<input type='hidden' name='c_signstr' value='" + md5string + "'>"); break; #endregion case 8: case 9: #region 快钱支付 m_PayOnlineProviderUrl = "https://www.99bill.com/gateway/recvMerchantInfoAction.htm"; //生成返回URL v_urlBuilder.Append(PayFolder + "PayResult99bill.aspx"); v_url = v_urlBuilder.ToString(); string merchantAcctId = v_mid; //网关账户号 string key = payOnlineKey; //网关密钥 string inputCharset = "3"; //1代表UTF-8; 2代表GBK; 3代表gb2312 string pageUrl = v_url; //接受支付结果的页面地址 string bgUrl = ""; //服务器接受支付结果的后台地址 string version = "v2.0"; //网关版本.固定值 string language = "1"; //1代表中文;2代表英文 string signType = "1"; //1代表MD5签名 string payerName = ""; //支付人姓名 string payerContactType = ""; //支付人联系方式类型 1代表Email;2代表手机号 string payerContact = ""; //支付人联系方式,只能选择Email或手机号 string orderAmount = Convert.ToString(decimal.Ceiling(DataConverter.CDecimal(v_amount) * 100)); //订单金额,以分为单位 string orderTime = v_ymd + v_hms; //订单提交时间,14位数字 string productName = ""; //商品名称 string productNum = ""; //商品数量 string productId = ""; //商品代码 string productDesc = ""; //商品描述 string ext1 = ""; //扩展字段1,在支付结束后原样返回给商户 string ext2 = ""; //扩展字段2 string payType = "00"; //支付方式,00:组合支付,显示快钱支持的各种支付方式,11:电话银行支付,12:快钱账户支付,13:线下支付,14:B2B支付 string bankId = ""; //银行代码,实现直接跳转到银行页面去支付,具体代码参见 接口文档银行代码列表,只在payType=10时才需设置参数 string redoFlag = "1"; //同一订单禁止重复提交标志:1代表同一订单号只允许提交1次,0表示同一订单号在没有支付成功的前提下可重复提交多次 string pid = ""; //快钱的合作伙伴的账户号 string signMsgVal = ""; md5string = PayHelper.GetMD5(signMsgVal, "").ToUpper(); strHiddenField.Append("<input type='hidden' name='inputCharset' value='" + inputCharset + "'>\n"); strHiddenField.Append("<input type='hidden' name='bgUrl' value='" + bgUrl + "'>\n"); strHiddenField.Append("<input type='hidden' name='pageUrl' value='" + pageUrl + "'>\n"); strHiddenField.Append("<input type='hidden' name='version' value='" + version + "'>\n"); strHiddenField.Append("<input type='hidden' name='language' value='" + language + "'>\n"); strHiddenField.Append("<input type='hidden' name='signType' value='" + signType + "'>\n"); strHiddenField.Append("<input type='hidden' name='signMsg' value='" + md5string + "'>\n"); strHiddenField.Append("<input type='hidden' name='merchantAcctId' value='" + merchantAcctId + "'>\n"); strHiddenField.Append("<input type='hidden' name='payerName' value='" + payerName + "'>\n"); strHiddenField.Append("<input type='hidden' name='payerContactType' value='" + payerContactType + "'>\n"); strHiddenField.Append("<input type='hidden' name='payerContact' value='" + payerContact + "'>\n"); strHiddenField.Append("<input type='hidden' name='orderId' value='" + v_oid + "'>\n"); strHiddenField.Append("<input type='hidden' name='orderAmount' value='" + orderAmount + "'>\n"); strHiddenField.Append("<input type='hidden' name='orderTime' value='" + orderTime + "'>\n"); strHiddenField.Append("<input type='hidden' name='productName' value='" + productName + "'>\n"); strHiddenField.Append("<input type='hidden' name='productNum' value='" + productNum + "'>\n"); strHiddenField.Append("<input type='hidden' name='productId' value='" + productId + "'>\n"); strHiddenField.Append("<input type='hidden' name='productDesc' value='" + productDesc + "'>\n"); strHiddenField.Append("<input type='hidden' name='ext1' value='" + ext1 + "'>\n"); strHiddenField.Append("<input type='hidden' name='ext2' value='" + ext2 + "'>\n"); strHiddenField.Append("<input type='hidden' name='payType' value='" + payType + "'>\n"); strHiddenField.Append("<input type='hidden' name='bankId' value='" + bankId + "'>\n"); strHiddenField.Append("<input type='hidden' name='redoFlag' value='" + redoFlag + "'>\n"); strHiddenField.Append("<input type='hidden' name='pid' value='" + pid + "'>\n"); break; #endregion case 11: #region 快钱神州行 m_PayOnlineProviderUrl = "https://www.99bill.com/szxgateway/recvMerchantInfoAction.htm"; //生成返回URL v_urlBuilder.Append(PayFolder + "PayResult99billSzx.aspx"); v_url = v_urlBuilder.ToString(); merchantAcctId = v_mid; //神州行网关账户号 key = payOnlineKey; //设置人民币网关密钥 inputCharset = "3"; //1代表UTF-8; 2代表GBK; 3代表gb2312 bgUrl = ""; //服务器接受支付结果的后台地址 pageUrl = v_url; //接受支付结果的页面地址 version = "v2.0"; //网关版本.固定值 language = "1"; //1代表中文;2代表英文 signType = "1"; //签名类型.固定值 payerName = ""; //支付人姓名 payerContactType = ""; //支付人联系方式类型,1代表Email;2代表手机号 payerContact = ""; //支付人联系方式,只能选择Email或手机号 orderAmount = Convert.ToString(decimal.Ceiling(DataConverter.CDecimal(v_amount) * 100)); //订单金额,以分为单位,必须是整型数字 orderTime = v_ymd + v_hms; //订单提交时间 productName = ""; //商品名称 productNum = ""; //商品数量 productId = ""; //商品代码 productDesc = ""; //商品描述 ext1 = ""; //扩展字段1 ext2 = ""; //扩展字段2 payType = "00"; //只能选择00,代表支持神州行卡和快钱帐户支付 string cardNumber = ""; //神州行卡序号,仅在商户定制了神州行卡密直连功能时填写 string cardPwd = ""; //神州行卡密码,仅在商户定制了神州行卡密直连功能时填写 //全额支付标志 ////0代表卡面额小于订单金额时返回支付结果为失败;1代表卡面额小于订单金额是返回支付结果为成功,同时订单金额和实际支付金额都为神州行卡的面额.如果商户定制神州行卡密直连时,本参数固定值为1 string fullAmountFlag = "0"; //0代表卡面额小于订单金额时返回支付结果为失败 //请务必按照如下顺序和规则组成加密串! signMsgVal = ""; md5string = PayHelper.GetMD5(signMsgVal, "").ToUpper(); strHiddenField.Append("<input type='hidden' name='inputCharset' value='" + inputCharset + "'>\n"); strHiddenField.Append("<input type='hidden' name='bgUrl' value='" + bgUrl + "'>\n"); strHiddenField.Append("<input type='hidden' name='pageUrl' value='" + pageUrl + "'>\n"); strHiddenField.Append("<input type='hidden' name='version' value='" + version + "'>\n"); strHiddenField.Append("<input type='hidden' name='language' value='" + language + "'>\n"); strHiddenField.Append("<input type='hidden' name='signType' value='" + signType + "'>\n"); strHiddenField.Append("<input type='hidden' name='merchantAcctId' value='" + merchantAcctId + "'>\n"); strHiddenField.Append("<input type='hidden' name='payerName' value='" + payerName + "'>\n"); strHiddenField.Append("<input type='hidden' name='payerContactType' value='" + payerContactType + "'>\n"); strHiddenField.Append("<input type='hidden' name='payerContact' value='" + payerContact + "'>\n"); strHiddenField.Append("<input type='hidden' name='orderId' value='" + v_oid + "'>\n"); strHiddenField.Append("<input type='hidden' name='orderAmount' value='" + orderAmount + "'>\n"); strHiddenField.Append("<input type='hidden' name='orderTime' value='" + orderTime + "'>\n"); strHiddenField.Append("<input type='hidden' name='productName' value='" + productName + "'>\n"); strHiddenField.Append("<input type='hidden' name='productNum' value='" + productNum + "'>\n"); strHiddenField.Append("<input type='hidden' name='productId' value='" + productId + "'>\n"); strHiddenField.Append("<input type='hidden' name='productDesc' value='" + productDesc + "'>\n"); strHiddenField.Append("<input type='hidden' name='ext1' value='" + ext1 + "'>\n"); strHiddenField.Append("<input type='hidden' name='ext2' value='" + ext2 + "'>\n"); strHiddenField.Append("<input type='hidden' name='payType' value='" + payType + "'>\n"); strHiddenField.Append("<input type='hidden' name='fullAmountFlag' value='" + fullAmountFlag + "'>\n"); strHiddenField.Append("<input type='hidden' name='cardNumber' value='" + cardNumber + "'>\n"); strHiddenField.Append("<input type='hidden' name='cardPwd' value='" + cardPwd + "'>\n"); strHiddenField.Append("<input type='hidden' name='signMsg' value='" + md5string + "'>\n"); break; #endregion case 12: #region 支付宝即时到帐 m_PayOnlineProviderUrl = "https://www.alipay.com/cooperate/gateway.do"; v_urlBuilder.Append(PayFolder + "PayResultAlipayInstant.aspx"); v_url = v_urlBuilder.ToString(); v_ShowResultUrl = v_ShowResultUrl + "&PaymentNum=" + v_oid; string partner = ""; if (payOnlineKey.IndexOf("|") > 0) { string[] ArrMD5Key = payOnlineKey.Split(new char[] { '|' }); payOnlineKey = ArrMD5Key[0]; partner = ArrMD5Key[1]; } md5Builder.Append("discount=0"); md5Builder.Append("¬ify_url=" + v_url); md5Builder.Append("&out_trade_no=" + v_oid); md5Builder.Append("&partner=" + partner); md5Builder.Append("&payment_type=1"); md5Builder.Append("&price=" + v_amount); md5Builder.Append("&quantity=1"); md5Builder.Append("&return_url=" + v_ShowResultUrl); md5Builder.Append("&seller_email=" + v_mid); md5Builder.Append("&service=create_direct_pay_by_user"); md5Builder.Append("&subject=" + v_oid); md5Builder.Append(payOnlineKey); md5string = PayHelper.GetMD5(md5Builder.ToString(), "").ToLower(); strHiddenField.Append("<input type='hidden' name='discount' value='0'>\n"); strHiddenField.Append("<input type='hidden' name='notify_url' value='" + v_url + "'>\n"); strHiddenField.Append("<input type='hidden' name='out_trade_no' value='" + v_oid + "'>\n"); strHiddenField.Append("<input type='hidden' name='payment_type' value='1'>\n"); strHiddenField.Append("<input type='hidden' name='partner' value='" + partner + "'>\n"); strHiddenField.Append("<input type='hidden' name='price' value='" + v_amount + "'>\n"); strHiddenField.Append("<input type='hidden' name='quantity' value='1'>\n"); strHiddenField.Append("<input type='hidden' name='seller_email' value='" + v_mid + "'>\n"); strHiddenField.Append("<input type='hidden' name='service' value='create_direct_pay_by_user'>\n"); strHiddenField.Append("<input type='hidden' name='subject' value='" + v_oid + "'>\n"); strHiddenField.Append("<input type='hidden' name='sign' value='" + md5string + "'>\n"); strHiddenField.Append("<input type='hidden' name='sign_type' value='MD5'>\n"); strHiddenField.Append("<input type='hidden' name='return_url' value='" + v_ShowResultUrl + "'>\n"); break; #endregion case 13: case 15: #region 财付通中介支付 m_PayOnlineProviderUrl = "https://www.tenpay.com/cgi-bin/med/show_opentrans.cgi"; version = "2"; // 否 整数 [1,4] 版本号,取值如下:1:先前版本。2:本次更新的版本。对于旧版本,不此字段,对于新版本,此字段必填。 int cmdno = 12; // 是 整数 [1,4] 任务代码,暂取定值:12 int encode_type = 1; // 否 整数 [1,2] 1:GB2312编码,默认为GB2312编码。 2:UTF-8编码。 string chnid = v_mid; // 否 字符串 [1,65] 平台提供者的财付通账号 string seller = v_mid; // 是 字符串 [1,65] 收款方财付通账号 string mch_name = v_oid; // 否 字符串 [1,32] 商品名称,不能包含<>’”%特殊字符 string mch_price = Convert.ToString(decimal.Round(DataConverter.CDecimal(v_amount) * 100, 0)); // 否 整数 [1,10] 商品总价,单位为分。而财付通界面不再允许选择数量 string transport_desc = v_mid + v_ymd + v_oid.Substring(v_oid.Length - 10, 10); // 否 字符串 [32] 物流公司或物流方式说明 int transport_fee = 0; // 否 整数 [1,10] 需买方另支付的物流费用。如已包含在商品价格中,请填写0。如果不填,默认为0。 string mch_desc = "caifutong"; // 否 字符串 [1,64] 交易说明,不能包含<>’”%特殊字符 int need_buyerinfo = 2; // 否 整数 [0,1] 是否需要在财付通填定物流信息,1:需要,2:不需要。 int mch_type = 1; // 否 整数 [1,1] 交易类型:1、实物交易,2、虚拟交易。 string mch_vno = v_oid; // 否 整数 [12] 商家的定单号 string mch_returl = v_urlBuilder.ToString() + PayFolder + "PayResultTenpayMed.aspx"; // 否 字符串 [1,255] 回调通知URL,如果cmdno为12且此字段填写有效回调链接,财付通将把交易相关信息通知给此URL,通知格式如下述.3.4节 string show_url = v_urlBuilder.ToString() + PayFolder + "PayResultTenpayMedShow.aspx"; // 否 字符串 [1,255] 支付后的商户支付结果展示页面。 string attach = v_oid; // 否 字符串 [1,200] 该参数财付通不做处理。回调时原样返回。为商户可能的个性化应用预留。 //string sign; 是 字符串 [32,32] Md5签名信息,签名方法如下: //1、 对所有请求字段,其值为空的不加入MD5验证 //2、 对所有请求字段,按字段名的ASCII顺序进行连接,连接方式同URL参数连接方式。 //3、 Key=总是附加在签名串的最后,不参与ASCII排序。 StringBuilder buf = new StringBuilder(); PayHelper.AddParameter(buf, "attach", attach); PayHelper.AddParameter(buf, "chnid", chnid); PayHelper.AddParameter(buf, "cmdno", (cmdno).ToString()); PayHelper.AddParameter(buf, "encode_type", (encode_type).ToString()); PayHelper.AddParameter(buf, "mch_desc", mch_desc); PayHelper.AddParameter(buf, "mch_name", mch_name); PayHelper.AddParameter(buf, "mch_price", (mch_price).ToString()); PayHelper.AddParameter(buf, "mch_returl", mch_returl); PayHelper.AddParameter(buf, "mch_type", (mch_type).ToString()); PayHelper.AddParameter(buf, "mch_vno", mch_vno.ToString()); PayHelper.AddParameter(buf, "need_buyerinfo", (need_buyerinfo).ToString()); PayHelper.AddParameter(buf, "seller", seller); PayHelper.AddParameter(buf, "show_url", show_url); PayHelper.AddParameter(buf, "transport_desc", transport_desc); PayHelper.AddParameter(buf, "transport_fee", (transport_fee).ToString()); PayHelper.AddParameter(buf, "version", version.ToString()); PayHelper.AddParameter(buf, "key", payOnlineKey); string sign = PayHelper.GetMD5(buf.ToString(), ""); m_PayOnlineProviderUrl = m_PayOnlineProviderUrl + "?attach=" + attach + "&chnid=" + chnid + "&cmdno=" + cmdno + "&encode_type=" + encode_type + "&mch_desc=" + mch_desc + "&mch_name=" + mch_name + "&mch_price=" + mch_price + "&mch_returl=" + mch_returl + "&mch_type=" + mch_type + "&mch_vno=" + mch_vno + "&need_buyerinfo=" + need_buyerinfo + "&seller=" + seller + "&show_url=" + show_url + "&transport_desc=" + transport_desc + "&transport_fee=" + transport_fee + "&version=" + version + "&sign=" + sign; break; #endregion case 100: case 101: case 102: case 103: case 104: case 108: default: break; } #endregion #region 构建表单 if (FormSubmitMethod == "") { string newForm = "<form method=\"post\" action='" + m_PayOnlineProviderUrl + "' id=\"PayForm\" target=\"_self\">"; string endFrom = "</form>"; string m_HiddenValue = newForm + strHiddenField.ToString() + endFrom; return(m_HiddenValue); } else { string newForm = "<form method=\"GET\" action='" + m_PayOnlineProviderUrl + "' id=\"PayForm\" target=\"_self\">"; string endFrom = "</form>"; string m_HiddenValue = newForm + strHiddenField.ToString() + endFrom; return(m_HiddenValue); } #endregion }