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) { string encryptOrderData = string.Empty; //加密数据 string pfx, bankcert; //证书 NEWCOM2Lib.seServer seServerObj = new NEWCOM2Lib.seServer(); //读取商户证书 seServerObj.readcert(ConfigManager.GetString("CMBCMerchantCertFile")); pfx = seServerObj.cert; //读取银行证书 seServerObj.readcert(ConfigManager.GetString("CMBCBankCertFile")); bankcert = seServerObj.cert; 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 md5Builder = new StringBuilder(); md5Builder.Append(order.SysOrderNo + "|"); //订单号 md5Builder.Append(order.OrderAmount + "|"); //交易金额 md5Builder.Append("01|"); //币种 01为人民币 md5Builder.Append(v_ymd + "|"); //交易日期 格式:20021010 md5Builder.Append(v_hms + "|"); //交易时间 格式:112647 md5Builder.Append("01001|"); //商户号 md5Builder.Append("深圳普特投资发展有限公司|"); //商户名称 md5Builder.Append("备注1|"); //备注1 md5Builder.Append("备注2|"); //备注1 md5Builder.Append("0|"); //是否实时返回标志 0:即时返回 1:查询 md5Builder.Append(order.ResultNotifyURL + "|"); //处理结果返回的URL md5Builder.Append("PT9999"); //MAC 因采用了证书机制,此项可不用 //加密,"1111"为商户私钥文件口令,生产环境改成正式口令 seServerObj.EnvelopData(md5Builder.ToString(), bankcert, pfx, "1111"); if (seServerObj.retCode == 0) { //加密成功,返回加密后的订单信息 encryptOrderData = seServerObj.EnveData; } else { //加密出错 encryptOrderData = "Decrypt Error"; } HttpHelper http = new HttpHelper(); http.Url = order.PayOnlineProviderUrl; http.Add("orderinfo", encryptOrderData); http.Post(); }
public void PostProcessPayment(PaymentInfo order) { string encryptOrderData = string.Empty;//加密数据 string pfx, bankcert; //证书 NEWCOM2Lib.seServer seServerObj = new NEWCOM2Lib.seServer(); //读取商户证书 seServerObj.readcert(ConfigManager.GetString("CMBCMerchantCertFile")); pfx = seServerObj.cert; //读取银行证书 seServerObj.readcert(ConfigManager.GetString("CMBCBankCertFile")); bankcert = seServerObj.cert; 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 md5Builder = new StringBuilder(); md5Builder.Append(order.SysOrderNo + "|");//订单号 md5Builder.Append(order.OrderAmount + "|");//交易金额 md5Builder.Append("01|");//币种 01为人民币 md5Builder.Append(v_ymd + "|");//交易日期 格式:20021010 md5Builder.Append(v_hms + "|");//交易时间 格式:112647 md5Builder.Append("01001|");//商户号 md5Builder.Append("深圳普特投资发展有限公司|");//商户名称 md5Builder.Append("备注1|");//备注1 md5Builder.Append("备注2|");//备注1 md5Builder.Append("0|");//是否实时返回标志 0:即时返回 1:查询 md5Builder.Append(order.ResultNotifyURL + "|");//处理结果返回的URL md5Builder.Append("PT9999");//MAC 因采用了证书机制,此项可不用 //加密,"1111"为商户私钥文件口令,生产环境改成正式口令 seServerObj.EnvelopData(md5Builder.ToString(), bankcert, pfx, "1111"); if (seServerObj.retCode == 0) { //加密成功,返回加密后的订单信息 encryptOrderData = seServerObj.EnveData; } else { //加密出错 encryptOrderData = "Decrypt Error"; } HttpHelper http = new HttpHelper(); http.Url = order.PayOnlineProviderUrl; http.Add("orderinfo", encryptOrderData); 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) { //修改交通银行支付接口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) { 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(); }
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(); }