/// <summary> /// 实时代收样例 /// </summary> /// <returns></returns> private static CryptUtils_Csharp.MessageCryptWorker.trafficMessage SampleCollectionMessage( string pfxFilePath, string pfxPassword, string cerFilePath, string merId, string ServerUrl, string transCode) { Dictionary <string, string> dic = new Dictionary <string, string>(); dic.Add("version", "01"); dic.Add("cityNo", "010000"); dic.Add("certType", "0001"); dic.Add("productId", "00000002"); dic.Add("purpose", "collection"); dic.Add("accNo", "6226220209634996"); dic.Add("accName", "TEST"); dic.Add("bankInsCode", "48270000"); dic.Add("bankName", "世界银行"); dic.Add("accAttr", "0"); dic.Add("timeOut", "20161115123021"); dic.Add("certNo", "321281198702253717"); dic.Add("tranTime", "20161114123021"); dic.Add("provNo", "010000"); dic.Add("phone", "12345678901"); dic.Add("cardId", "321281198702253717"); dic.Add("tranAmt", "000000000100"); dic.Add("orderCode", "201611131000001042"); dic.Add("accType", "4"); dic.Add("currencyCode", "156"); //报文结构体初始化 CryptUtils_Csharp.MessageCryptWorker.trafficMessage msgRequestSource = new CryptUtils_Csharp.MessageCryptWorker.trafficMessage(); //发送类实体化 CryptUtils_Csharp.MessageCryptWorker worker = new CryptUtils_Csharp.MessageCryptWorker(); worker.EncodeCode = Encoding.UTF8; //encoding 使用utf8 worker.PFXFile = pfxFilePath; //商户pfx证书路径 worker.PFXPassword = pfxPassword; //商户pfx证书密码 worker.CerFile = cerFilePath; //杉德cer证书路径 msgRequestSource.merId = merId; //商户号 msgRequestSource.transCode = transCode; //交易代码 msgRequestSource.extend = ""; //扩展域 //报文体json JavaScriptSerializer jsonSer = new JavaScriptSerializer(); msgRequestSource.encryptData = jsonSer.Serialize(dic); //encrytpKey会在发送前加密时自动生成16位的随机字符 Console.WriteLine("待发送报文为:" + msgRequestSource.encryptData); CryptUtils_Csharp.MessageCryptWorker.trafficMessage respMessage = worker.postMessage(ServerUrl, msgRequestSource); Console.WriteLine("服务器返回为:" + respMessage.encryptData); return(respMessage); }
/// <summary> /// 实时代付样例 /// </summary> /// <returns></returns> private static CryptUtils_Csharp.MessageCryptWorker.trafficMessage SampleAgentPayMessage( string pfxFilePath, string pfxPassword, string cerFilePath, string merId, string ServerUrl, string transCode) { Dictionary <string, string> dic = new Dictionary <string, string>(); dic.Add("version", "01"); dic.Add("productId", "00000003");// 代收对公 00000001 代收对私 00000002 代付对私 00000004 dic.Add("tranTime", "20161114123021"); dic.Add("orderCode", "20161113000000001038"); dic.Add("timeOut", "20161115123021"); dic.Add("tranAmt", "000000000001"); dic.Add("currencyCode", "156"); dic.Add("accAttr", "0"); dic.Add("accType", "2"); dic.Add("accNo", "6216261000000000018"); dic.Add("accName", "啊啊"); dic.Add("bankName", "aaa"); dic.Add("bankType", "1234567890"); dic.Add("remark", "pay"); dic.Add("reqReserved", ""); dic.Add("noticeUrl", ""); dic.Add("extend", ""); //报文结构体初始化 CryptUtils_Csharp.MessageCryptWorker.trafficMessage msgRequestSource = new CryptUtils_Csharp.MessageCryptWorker.trafficMessage(); //发送类实体化 CryptUtils_Csharp.MessageCryptWorker worker = new CryptUtils_Csharp.MessageCryptWorker(); worker.EncodeCode = Encoding.UTF8; //encoding 使用utf8 worker.PFXFile = pfxFilePath; //商户pfx证书路径 worker.PFXPassword = pfxPassword; //商户pfx证书密码 worker.CerFile = cerFilePath; //杉德cer证书路径 msgRequestSource.merId = merId; //商户号 msgRequestSource.transCode = transCode; //交易代码 msgRequestSource.extend = ""; //扩展域 //报文体json JavaScriptSerializer jsonSer = new JavaScriptSerializer(); msgRequestSource.encryptData = jsonSer.Serialize(dic); //encrytpKey会在发送前加密时自动生成16位的随机字符 Console.WriteLine("待发送报文为:" + msgRequestSource.encryptData); CryptUtils_Csharp.MessageCryptWorker.trafficMessage respMessage = worker.postMessage(ServerUrl, msgRequestSource); Console.WriteLine("服务器返回为:" + respMessage.encryptData); return(respMessage); }
/// <summary> /// 订单查询样例 /// </summary> /// <returns></returns> private static CryptUtils_Csharp.MessageCryptWorker.trafficMessage SampleQueryOrderMessage(string pfxFilePath, string pfxPassword, string cerFilePath, string merId, string ServerUrl, string transCode) { Dictionary <string, string> dic = new Dictionary <string, string>(); dic.Add("version", "01"); dic.Add("productId", "00000003");// 代收对公 00000001 代收对私 00000002 代付对私 00000004 dic.Add("tranTime", "20161114123021"); dic.Add("orderCode", "20161113000000001038"); //报文结构体初始化 CryptUtils_Csharp.MessageCryptWorker.trafficMessage msgRequestSource = new CryptUtils_Csharp.MessageCryptWorker.trafficMessage(); //发送类实体化 CryptUtils_Csharp.MessageCryptWorker worker = new CryptUtils_Csharp.MessageCryptWorker(); worker.EncodeCode = Encoding.UTF8; //encoding 使用utf8 worker.PFXFile = pfxFilePath; //商户pfx证书路径 worker.PFXPassword = pfxPassword; //商户pfx证书密码 worker.CerFile = cerFilePath; //杉德cer证书路径 msgRequestSource.merId = merId; //商户号 msgRequestSource.transCode = transCode; //交易代码 msgRequestSource.extend = ""; //扩展域 //报文体json JavaScriptSerializer jsonSer = new JavaScriptSerializer(); msgRequestSource.encryptData = jsonSer.Serialize(dic); //encrytpKey会在发送前加密时自动生成16位的随机字符 Console.WriteLine("待发送报文为:" + msgRequestSource.encryptData); CryptUtils_Csharp.MessageCryptWorker.trafficMessage respMessage = worker.postMessage(ServerUrl, msgRequestSource); Console.WriteLine("服务器返回为:" + respMessage.encryptData); return(respMessage); }