public override void SendRequest() { Dictionary <string, string> data = new Dictionary <string, string>(); BUConfig.MerId = SDKConfig.MerId = this.Vmid; SDKConfig.SignCertPwd = this.Key; SDKConfig.signCertPath = Path.Combine(SDKConfig.validateCertDir, this.SignCertFileName); BUConfig.CertId = CertUtil.GetSignCertId(); data.Add("version", BUConfig.Version); data.Add("encoding", BUConfig.Encoding); data.Add("certId", BUConfig.CertId); data.Add("signMethod", BUConfig.SignMethod); data.Add("txnType", BUConfig.TxnType); data.Add("txnSubType", BUConfig.TxnSubType); data.Add("bizType", BUConfig.BizType); data.Add("channelType", BUConfig.ChannelType); data.Add("frontUrl", BUConfig.FrontUrl); data.Add("backUrl", BUConfig.BackUrl); data.Add("accessType", BUConfig.AccessType); data.Add("merId", BUConfig.MerId); data.Add("orderId", BUConfig.OrderId); data.Add("txnTime", BUConfig.TxnTime); data.Add("txnAmt", BUConfig.TxnAmt); data.Add("currencyCode", BUConfig.CurrencyCode); data.Add("userMac", "userMac"); SDKUtil.Sign(data, Encoding.UTF8); string msg = SDKUtil.CreateAutoSubmitForm("https://gateway.95516.com/gateway/api/frontTransReq.do", data, Encoding.UTF8); PayLog.writeLog(data, "", "", msg, LogType.BankUnion_GateWay); this.SubmitPaymentForm(msg); }
/// <summary> /// 生成App支付订单参数信息 /// </summary> /// <param name="outTradeNo">业务单号</param> /// <param name="subject">支付标题</param> /// <param name="body">支付内容</param> /// <param name="totalFee">支付金额</param> /// <returns></returns> public static UniionpayResult GetPayString(string outTradeNo, string orderDesc, decimal totalAmount, bool isPrePay, out string payParam) { UniionpayResult result = new UniionpayResult(); //构造待签名数据 Dictionary <string, string> param = new Dictionary <string, string>(); try { //填写参数 param["version"] = "5.0.0"; //版本号 param["encoding"] = "UTF-8"; //编码方式 param["certId"] = CertUtil.GetSignCertId(); //证书ID param["txnType"] = isPrePay ? TxnType.PrePay : TxnType.Consume; //交易类型 param["txnSubType"] = "01"; //交易子类 param["bizType"] = "000000"; //业务类型 param["backUrl"] = SDKConfig.BackTransUrl; //后台异步通知地址 param["signMethod"] = "01"; //签名方法,01:表示采用RSA param["channelType"] = "08"; //渠道类型,07-PC,08-手机 param["accessType"] = "0"; //接入类型,0:商户直连接入 1:收单机构接入 2:平台商户接入 param["merId"] = SDKConfig.MerId; //商户号,请改成自己的商户号 param["orderId"] = outTradeNo; //商户订单号 param["txnTime"] = DateTime.Now.ToString("yyyyMMddHHmmss"); //订单发送时间 param["txnAmt"] = (totalAmount * 100).ToString("0"); //交易金额,单位分 param["currencyCode"] = "156"; //交易币种 param["orderDesc"] = orderDesc; //订单描述,可不上送,上送时控件中会显示该信息 SDKUtil.Sign(param, Encoding.UTF8); // 签名 payParam = JsonConvert.SerializeObject(param); // 初始化通信处理类 HttpClient hc = new HttpClient(SDKConfig.AppRequestUrl); // 发送请求获取通信应答 int status = hc.Send(param, Encoding.UTF8); // 返回结果 string results = hc.Result; Dictionary <string, string> resData = SDKUtil.CoverstringToDictionary(results); result.respcode = resData["respCode"]; if (result.respcode != "00") { result.respMsg = resData["respMsg"]; return(result); } if (!SDKUtil.Validate(resData, Encoding.UTF8)) { LogHelper.SaveFileLog("获取银联支付信息失败!", "商户端验证返回报文签名失败:" + JsonConvert.SerializeObject(resData)); result.respMsg = resData["respMsg"]; return(result); } result.tn = resData["tn"]; } catch (Exception ex) { payParam = JsonConvert.SerializeObject(param); LogHelper.SaveFileLog("获取银联支付信息失败!", ex.Message); result.respcode = ""; result.respMsg = ""; } return(result); }
/// <summary> /// java main方法 数据提交 对数据进行签名 /// </summary> /// <param name="contentData">交易数据</param> /// <returns>签名后的map对象</returns> public static Dictionary <string, string> SignData(Dictionary <string, string> contentData) { var submitFromData = new Dictionary <string, string>(); foreach (var item in contentData) { if (!string.IsNullOrEmpty(item.Value)) { submitFromData.Add(item.Key, item.Value); } } /** * 签名 */ SDKUtil.Sign(submitFromData, Encoding.UTF8); return(submitFromData); }
public ActionResult AppConsume(string txnAmt, string orderDesc) { LogerHelper.DefaultInfo(Request.ToString()); Dictionary <string, string> param = new Dictionary <string, string>(); // 随机构造一个订单号(演示用) Random rnd = new Random(); string orderID = DateTime.Now.ToString("yyyyMMddHHmmss") + (rnd.Next(900) + 100).ToString().Trim(); //填写参数 param["version"] = "5.0.0"; //版本号 param["encoding"] = "UTF-8"; //编码方式 param["certId"] = CertUtil.GetSignCertId(); //证书ID param["txnType"] = "01"; //交易类型 param["txnSubType"] = "01"; //交易子类 param["bizType"] = "000201"; //业务类型 param["frontUrl"] = "http://localhost:8080/demo/utf8/FrontRcvResponse.aspx"; //前台通知地址 ,控件接入方式无作用 param["backUrl"] = "http://weixin.mandelaauto.com/Pay/CupComplete"; //后台通知地址 param["signMethod"] = "01"; //签名方法 param["channelType"] = "08"; //渠道类型,07-PC,08-手机 param["accessType"] = "0"; //接入类型 param["merId"] = Properties.getHost(); //商户号,请改成自己的商户号 param["orderId"] = orderID; //商户订单号 param["txnTime"] = DateTime.Now.ToString("yyyyMMddHHmmss"); //订单发送时间 param["txnAmt"] = txnAmt; //交易金额,单位分 param["currencyCode"] = "156"; //交易币种 param["orderDesc"] = orderDesc; //订单描述,可不上送,上送时控件中会显示该信息 param["reqReserved"] = "透传信息"; //请求方保留域,透传字段,查询、通知、对账文件中均会原样出现 SDKUtil.Sign(param, Encoding.UTF8); // 签名 Response.Write("\n" + "请求报文=[" + SDKUtil.PrintDictionaryToString(param) + "]\n"); // 初始化通信处理类 HttpClient hc = new HttpClient(SDKConfig.AppRequestUrl); //// 发送请求获取通信应答 int status = hc.Send(param, Encoding.UTF8); // 返回结果 string result = hc.Result; if (status == 200) { Response.Write("返回报文=[" + result + "]\n"); LogerHelper.DefaultInfo(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss ") + result); Dictionary <string, string> resData = SDKUtil.CoverstringToDictionary(result); foreach (var x in resData.Keys) { LogerHelper.DefaultInfo(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss ") + x); } string respcode = resData["respCode"]; if (SDKUtil.Validate(resData, Encoding.UTF8)) { Response.Write("商户端验证返回报文签名成功\n"); } else { Response.Write("商户端验证返回报文签名失败\n"); } } else { Response.Write("请求失败\n"); Response.Write("返回报文=[" + result + "]\n"); } return(Content("success")); }