/// <summary> /// 消费 /// </summary> /// <param name="mackey"></param> /// <returns></returns> public static Dictionary <string, ResultData> pay(WintopPayParam param) { Dictionary <int, string> data = new Dictionary <int, string>(); data.Add(2, param.wintopNo); //万通卡号 data.Add(3, "000000"); data.Add(4, countPrice(param.price)); //交易金额 data.Add(11, SysBLL.padLeft(getOrder(), 6)); //POS终端交易流水 data.Add(25, "00"); data.Add(41, SysConfigHelper.readerNode("ClientNo")); //终端代码 data.Add(42, SysConfigHelper.readerNode("ShopNo")); //商户代码 data.Add(48, "Y00000001"); data.Add(49, "156"); data.Add(62, getPin(param.pwd, param.wintopNo));//明文,卡号 data.Add(63, "01"); byte[] sendData = EncryptWT.EncryptData("0200", "6000000000", EncryptWT.encryptLKL(data, calculateMac(data, "0200"))); //Console.WriteLine(); string datasss = BCDUtil.byteArrToString(sendData); //Console.WriteLine(BCDUtil.byteArrToString(sendData)); AnalysisBaseWT lk = new AnalysisBaseWT(); byte[] result = Client(LakalaIp, LakalaPort, sendData); if (result.Length > 0) { return(lk.analysis(result)); //发送数据 } else { return(null); } }
/// <summary> /// 签退 /// </summary> /// <returns></returns> public static Dictionary <string, ResultData> signOut() { Dictionary <int, string> data = new Dictionary <int, string>(); data.Add(3, "000000"); data.Add(11, "000006"); data.Add(12, getHHMMSS()); data.Add(41, "pos00001"); data.Add(42, "000000000000257"); data.Add(60, "22000003000"); data.Add(63, "01"); byte[] sendData = EncryptWT.EncryptData("0820", "6000000000", EncryptWT.encryptLKL(data, calculateMac(data, "0400"))); Console.WriteLine(BCDUtil.byteArrToString(sendData)); AnalysisBaseWT lk = new AnalysisBaseWT(); byte[] result = Client(LakalaIp, LakalaPort, sendData); if (result.Length > 0) { return(lk.analysis(result)); //发送数据 } else { return(null); } }
/// <summary> /// 签退 /// </summary> /// <returns></returns> public static Dictionary <string, ResultData> signOut() { try { Dictionary <int, string> data = new Dictionary <int, string>(); data.Add(3, "000000"); data.Add(11, "000006"); data.Add(12, getHHMMSS()); data.Add(41, SysConfigHelper.readerNode("ClientNo")); data.Add(42, SysConfigHelper.readerNode("ShopNo")); data.Add(60, "22000003000"); data.Add(63, "01"); byte[] sendData = EncryptWT.EncryptData("0820", "6000000000", EncryptWT.encryptLKL(data, calculateMac(data, "0400"))); Console.WriteLine(BCDUtil.byteArrToString(sendData)); AnalysisBaseWT lk = new AnalysisBaseWT(); byte[] result = Client(LakalaIp, LakalaPort, sendData); return(lk.analysis(result)); //发送数据 } catch (WtException e) { throw e; } catch (Exception e) { throw new WtException(WtExceptionCode.Sys.WT_SIGN_OUT, e.Message); } }
/// <summary> /// 冲正 /// </summary> /// <returns></returns> public static Dictionary <string, ResultData> correct(WintopPayParam param) { Dictionary <int, string> data = new Dictionary <int, string>(); data.Add(2, param.wintopNo); data.Add(3, "000000"); data.Add(4, countPrice(param.price)); data.Add(11, SysBLL.padLeft(getOrder(), 6)); data.Add(25, "00"); data.Add(39, "17"); data.Add(41, ConfigurationManager.AppSettings["ClientNo"]); data.Add(42, ConfigurationManager.AppSettings["ShopNo"]); data.Add(48, "Y00000001"); data.Add(49, "156"); data.Add(63, "01"); byte[] sendData = EncryptWT.EncryptData("0400", "6000000000", EncryptWT.encryptLKL(data, calculateMac(data, "0400"))); Console.WriteLine(BCDUtil.byteArrToString(sendData)); AnalysisBaseWT lk = new AnalysisBaseWT(); byte[] result = Client(LakalaIp, LakalaPort, sendData); if (result.Length > 0) { return(lk.analysis(result)); //发送数据 } else { return(null); } }
public static string ConvertMoney(string money) { double _tempPayMoney = Convert.ToDouble(money) * 100; return(BCDUtil.leftpad(decimal.Parse(_tempPayMoney + "").ToString(), 12)); //int _tempPayMoney = (Int32)(Convert.ToDouble(money) * 100); //return BCDUtil.leftpad(Convert.ToString(_tempPayMoney), 12); }
/// <summary> /// 计算mac 公共类 /// </summary> /// <param name="data"></param> /// <returns></returns> public static byte[] calculateMac(Dictionary <int, string> data, string msgType) { //计算MAC用到的数据 byte[] countMacData = EncryptWT.countMacData(msgType, EncryptWT.encryptLKL(data, null)); Console.WriteLine(BCDUtil.byteArrToString(countMacData)); string str = MacUtils.CSMMAC(mackey, BCDUtil.byteArrToString(countMacData));//ConfigurationManager.AppSettings["WTMacKey"] Console.WriteLine("bcd2Str:" + PosProtocol.bcd2Str(System.Text.Encoding.Default.GetBytes(str.Substring(0, 8)))); //MAC转byte[] String strMac = PosProtocol.bcd2Str(System.Text.Encoding.Default.GetBytes(str.Substring(0, 8).ToUpper())); byte[] macByte = BCDUtil.ToByteArray(strMac); return(macByte); }
/// <summary> /// 验证数据是否通过验证 /// </summary> /// <param name="data"></param> /// <returns></returns> public static string validateKey(string data, string key) { string validata = data.Substring(data.Length - 8, 8).ToUpper(); byte[] sources = BCDUtil.HexStrToByteArray(data.Substring(0, 32)); byte[] desKeys = BCDUtil.HexStrToByteArray(key); byte[] encSource = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; byte[] encKeys = CSm4.DecriptB(desKeys, sources); if (PosProtocol.bytesToHexString(CSm4.EncriptB(encKeys, encSource)).Substring(0, 8).Equals(validata)) { Console.WriteLine("密钥验证通过返回灌输密钥!!!!"); return(PosProtocol.bytesToHexString(encKeys)); } return(""); }
/// <summary> /// 消费 /// </summary> /// <param name="mackey"></param> /// <returns></returns> public static Dictionary <string, string> pay(WintopPayParam param) { Dictionary <string, string> map = new Dictionary <string, string>(); Dictionary <int, string> data = new Dictionary <int, string>(); data.Add(2, param.wintopNo); //万通卡号 data.Add(3, "000000"); data.Add(4, countPrice(param.price)); //交易金额 data.Add(11, param.orderNo); //POS终端交易流水 data.Add(25, "00"); data.Add(41, ConfigurationManager.AppSettings["ClientNo"]); //终端代码 data.Add(42, ConfigurationManager.AppSettings["ShopNo"]); //商户代码 data.Add(48, "Y00000001"); data.Add(49, "156"); data.Add(62, param.ExpressPwd);//明文,卡号 data.Add(63, "01"); byte[] countMacData = EncryptWT.countMacData("0200", EncryptWT.encryptLKL(data, null)); byte[] mac = PasswordBLL.GetMac(2, countMacData); byte[] sendData = EncryptWT.EncryptData("0200", "6000000000", EncryptWT.encryptLKL(data, mac)); //Console.WriteLine(); //Console.WriteLine(BCDUtil.byteArrToString(sendData)); AnalysisBaseWT lk = new AnalysisBaseWT(); byte[] result = Client(LakalaIp, LakalaPort, sendData); if (result.Length > 0) { string recode = Wanton.handleDataMac(lk.analysis(result)); //发送数据 //发送的数据 string sendStr = BCDUtil.byteArrToString(sendData); //接收的数据 string receiveStr = BCDUtil.byteArrToString(result); map.Add("recode", recode); map.Add("sendStr", sendStr); map.Add("receiveStr", receiveStr); map.Add("ShopNo", param.orderNo + "|" + data[41] + "|" + data[42]); return(map); } else { return(null); } }
public static string pinKey = "CFB06A0F384F99DB226E1BAFA752F68A"; // string.Empty; /// <summary> /// 客户端 /// </summary> /// <param name="ip"></param> /// <param name="port"></param> /// <param name="message"></param> public static byte[] Client(string ip, int port, byte[] messages) { string sfd = BCDUtil.byteArrToString(messages); byte[] datas; try { //1.发送数据 TcpClient client = new TcpClient(ip, port); IPEndPoint ipendpoint = client.Client.RemoteEndPoint as IPEndPoint; NetworkStream stream = client.GetStream(); stream.Write(messages, 0, messages.Length); BCDUtil.printData("推送数据", messages); //2.接收状态,长度<1024字节 byte[] bytes = new Byte[1024 * 8]; string data = string.Empty; //读取超时时间,10秒 stream.ReadTimeout = 30000; int length = stream.Read(bytes, 0, bytes.Length); if (length == 2) { string headLenStr1 = Convert.ToString(bytes[0], 10); string headLenStr2 = Convert.ToString(bytes[1], 10); int headLen = Convert.ToInt32(headLenStr1 + headLenStr2); length = stream.Read(bytes, length, (headLen)); length += 2; } datas = new byte[length]; Array.Copy(bytes, datas, length); BCDUtil.printData("接收数据", datas); //3.关闭对象 stream.Close(); client.Close(); return(datas); } catch (Exception ex) { Console.WriteLine(string.Format("{0:HH:mm:ss}->{1}", DateTime.Now, ex.Message)); } //Console.ReadKey(); datas = new byte[0]; return(datas); }
/// <summary> /// 换算PIN /// </summary> /// <param name="pwd">用户输入的密码</param> /// <param name="cardNo">获取的ic卡卡号</param> /// <returns></returns> public static string getPin(string pwd, string cardNo) { string result = string.Empty; int len = cardNo.Length - 4; string pwdLen = pwd.Length + ""; if (pwdLen.Length == 1) { pwd = "0" + pwdLen + pwd; } string cardNoCover = ""; if (len < 12) { cardNo = cardNo.Substring(4, len); for (int i = 0; i < 12 - len; i++) { cardNoCover += "f"; } } else { cardNo = cardNo.Substring(3, 12); } cardNo = cardNoCover + cardNo; for (int i = 0; i < 32; i++) { if (cardNo.Length < 32) { cardNo = "0" + cardNo; } if (pwd.Length < 32) { pwd = pwd + "f"; } } string orx = MacUtils.xOrString(cardNo, pwd); //Console.WriteLine("orx="+ orx); result = BCDUtil.byteArrToString(CSm4.EncriptB(BCDUtil.ToByteArray(pinKey), BCDUtil.ToByteArray(orx)));//BCDUtil.ToByteArray(ConfigurationManager.AppSettings["WTPinKey"]) // Console.WriteLine("result="+ result); Console.WriteLine(result.ToUpper()); return(result.ToUpper()); }
public static void pay(PayParam param, ref string sendDataStr) { try { Dictionary <string, string> map = new Dictionary <string, string>(); Dictionary <int, string> data = new Dictionary <int, string>(); data.Add(2, param.WtNo); //万通卡号 data.Add(3, "000000"); data.Add(4, wtPayUtils.ConvertMoney(param.rechageAmount)); //交易金额 data.Add(11, param.WtLklorderNo); //POS终端交易流水 map.Add("11", data[11]); data.Add(25, "00"); data.Add(41, SysConfigHelper.readerNode("ClientNo"));//终端代码 map.Add("41", data[41]); data.Add(42, SysConfigHelper.readerNode("ShopNo")); //商户代码 data.Add(48, "TC_ONE|Y00000001|" + param.MERCHANTNO_shopNo); //data.Add(48, "TC_ONE|Y00000001|"+secondShopNo); //data.Add(48, "Y00000001"); data.Add(49, "156"); data.Add(62, param.pwd);//明文,卡号z data.Add(63, "01"); byte[] countMacData = EncryptWT.countMacData("0200", EncryptWT.encryptLKL(data, null)); byte[] mac = PasswordBLL.GetMac(2, countMacData); byte[] sendData = EncryptWT.EncryptData("0200", "6000000000", EncryptWT.encryptLKL(data, mac)); //发送的数据 string sendStr = BCDUtil.byteArrToString(sendData); sendDataStr = sendStr; } catch (WtException e) { throw e; } catch (Exception e) { throw new WtException(WtExceptionCode.Bus.WT_PAY, e.Message); } }
public SendMessage Handle(ref Operate opeate) { SendMessage msg = new SendMessage() { CenterCode = 0x01, ClientCode = BCDUtil.ConvertFrom(opeate.ClientCode, 6), SendTime = SendTime, Serial = 0, FunctionCode = opeate.FunctionCode }; msg.Body = GetBody(); opeate.State = OperateState.Sended; opeate.Content = BytesUtil.ToHexString(msg.ToByte()); opeate.SendTime = SendTime; return(msg); }
public static string wtRefund(Dictionary <string, string> list, string secondShopNo) { string _2 = list["2"], _4 = list["4"], _59 = list["59"]; string theOrderNo = Wanton.GetOrderNo(); string termailNo = SysConfigHelper.readerNode("ClientNo"); string shopNo = SysConfigHelper.readerNode("ShopNo"); Dictionary <string, string> map = new Dictionary <string, string>(); Dictionary <int, string> data = new Dictionary <int, string>(); data.Add(2, _2); data.Add(3, "200000"); data.Add(4, wtPayUtils.ConvertMoney(_4)); data.Add(11, theOrderNo); map.Add("11", data[11]); data.Add(22, "051"); data.Add(25, "00"); data.Add(41, termailNo); map.Add("41", data[41]); data.Add(42, shopNo); data.Add(48, "TC_ONE|Y00000001|" + secondShopNo); //data.Add(48, "Y00000001"); data.Add(49, "156"); data.Add(59, _59); data.Add(60, "22000003000"); data.Add(63, "01"); byte[] countMacData = EncryptWT.countMacData("0200", EncryptWT.encryptLKL(data, null)); byte[] mac = PasswordBLL.GetMac(2, countMacData); byte[] sendData = EncryptWT.EncryptData("0200", "6000000000", EncryptWT.encryptLKL(data, mac)); //byte[] sendData = EncryptWT.EncryptData("0200", "6000000000", EncryptWT.encryptLKL(data, calculateMac(data, "0200"))); Console.WriteLine(); Console.WriteLine(BCDUtil.byteArrToString(sendData)); return(BCDUtil.byteArrToString(sendData)); }
/// <summary> /// 签到 /// </summary> /// <returns></returns> public static Dictionary <string, ResultData> sign() { //签到 Dictionary <int, string> data = new Dictionary <int, string>(); data.Add(3, "000000"); data.Add(41, ConfigurationManager.AppSettings["ClientNo"]); //终端代码 data.Add(42, ConfigurationManager.AppSettings["ShopNo"]); //商户代码 data.Add(63, "01"); byte[] result = Client(LakalaIp, LakalaPort, EncryptWT.EncryptData("0800", "6000000000", EncryptWT.encryptLKL(data, null))); //发送数据 if (result == null || result.Length <= 0) { return(null); } Console.WriteLine(BCDUtil.byteArrToString(result)); AnalysisBaseWT lk = new AnalysisBaseWTSign(); Dictionary <string, ResultData> rd = lk.analysis(result); return(rd); }
/// <summary> /// 签到 /// </summary> /// <returns></returns> public static SignParam sign() { //签到 Dictionary <int, string> data = new Dictionary <int, string>(); data.Add(3, "000000"); data.Add(41, SysConfigHelper.readerNode("ClientNo")); //终端代码 data.Add(42, SysConfigHelper.readerNode("ShopNo")); //商户代码 data.Add(63, "01"); byte[] result = EncryptWT.EncryptData("0800", "6000000000", EncryptWT.encryptLKL(data, null)); if (result == null || result.Length <= 0) { return(null); } SignParam param = new SignParam(); param.data = BCDUtil.byteArrToString(result); param.shop_type = "1"; //Console.WriteLine(); //AnalysisBaseWT lk = new AnalysisBaseWTSign(); //Dictionary<string, ResultData> rd = lk.analysis(result); return(param); }
/// <summary> /// 冲正 /// </summary> /// <returns></returns> public static void correct(PayParam param, ref string sendDataStr) { try { string termailNo = SysConfigHelper.readerNode("ClientNo"); Dictionary <int, string> data = new Dictionary <int, string>(); data.Add(2, param.WtNo); data.Add(3, "000000"); data.Add(4, wtPayUtils.ConvertMoney(param.rechageAmount)); data.Add(11, param.WtLklorderNo); data.Add(25, "00"); data.Add(39, "17"); data.Add(41, termailNo); data.Add(42, SysConfigHelper.readerNode("ShopNo")); data.Add(48, "TC_ONE|Y00000001|" + param.MERCHANTNO_shopNo); //data.Add(48, "Y00000001"); data.Add(49, "156"); data.Add(63, "01"); byte[] countMacData = EncryptWT.countMacData("0400", EncryptWT.encryptLKL(data, null)); byte[] mac = PasswordBLL.GetMac(2, countMacData); byte[] sendData = EncryptWT.EncryptData("0400", "6000000000", EncryptWT.encryptLKL(data, mac)); //发送的数据 sendDataStr = BCDUtil.byteArrToString(sendData); } catch (Exception e) { } }
/// <summary> /// 退款 /// </summary> /// <returns></returns> public static Dictionary <string, string> refund(WintopPayParam param, string _59, string secondShopNo) { string theOrderNo = Wanton.GetOrderNo(); string termailNo = SysConfigHelper.readerNode("ClientNo"); Dictionary <string, string> map = new Dictionary <string, string>(); Dictionary <int, string> data = new Dictionary <int, string>(); data.Add(2, param.wintopNo); data.Add(3, "200000"); data.Add(4, wtPayUtils.ConvertMoney(param.price)); data.Add(11, getHHMMSS()); map.Add("11", data[11]); data.Add(22, "051"); data.Add(25, "00"); data.Add(41, SysConfigHelper.readerNode("ClientNo")); map.Add("41", data[41]); data.Add(42, SysConfigHelper.readerNode("ShopNo")); data.Add(48, "TC_ONE|Y00000001|" + secondShopNo); //data.Add(48, "Y00000001"); data.Add(49, "156"); data.Add(59, _59); data.Add(60, "22000003000"); data.Add(63, "01"); byte[] countMacData = EncryptWT.countMacData("0200", EncryptWT.encryptLKL(data, null)); byte[] mac = PasswordBLL.GetMac(2, countMacData); byte[] sendData = EncryptWT.EncryptData("0200", "6000000000", EncryptWT.encryptLKL(data, mac)); string sendStr = BCDUtil.byteArrToString(sendData); log.Write("发送退款的数据:" + sendStr); //byte[] sendData = EncryptWT.EncryptData("0200", "6000000000", EncryptWT.encryptLKL(data, calculateMac(data, "0200"))); Console.WriteLine(); Console.WriteLine(BCDUtil.byteArrToString(sendData)); AnalysisBaseWT lk = new AnalysisBaseWT(); byte[] result = Client(LakalaIp, LakalaPort, sendData); //result string resultstr = BCDUtil.byteArrToString(result); log.Write("接收退款的数据:" + resultstr); string recode = Wanton.handleDataMac(lk.analysis(result)); //发送数据 log.Write("万通退款结果" + recode); string serialStr = JsonConvert.SerializeObject(map); //接收的数据 string receiveStr = BCDUtil.byteArrToString(result); map.Add("recode", recode); map.Add("sendStr", sendStr); map.Add("receiveStr", receiveStr); map.Add("ShopNo", param.orderNo + "|" + data[41] + "|" + data[42]); map.Add("money", param.price); return(map); //if (result.Length > 0) //{ // return lk.analysis(result); //发送数据 //} //else //{ // return null; //} }
public static Dictionary <string, string> pay(WintopPayParam param, string secondShopNo) { try { Dictionary <string, string> map = new Dictionary <string, string>(); Dictionary <int, string> data = new Dictionary <int, string>(); data.Add(2, param.wintopNo); //万通卡号 data.Add(3, "000000"); data.Add(4, wtPayUtils.ConvertMoney(param.price)); //交易金额 data.Add(11, param.orderNo); //POS终端交易流水 map.Add("11", data[11]); data.Add(25, "00"); data.Add(41, SysConfigHelper.readerNode("ClientNo"));//终端代码 map.Add("41", data[41]); data.Add(42, SysConfigHelper.readerNode("ShopNo")); //商户代码 data.Add(48, "TC_ONE|Y00000001|" + secondShopNo); //data.Add(48, "TC_ONE|Y00000001|"+secondShopNo); //data.Add(48, "Y00000001"); data.Add(49, "156"); data.Add(62, param.pwd);//明文,卡号 data.Add(63, "01"); byte[] countMacData = EncryptWT.countMacData("0200", EncryptWT.encryptLKL(data, null)); byte[] mac = PasswordBLL.GetMac(2, countMacData); byte[] sendData = EncryptWT.EncryptData("0200", "6000000000", EncryptWT.encryptLKL(data, mac)); //发送的数据 string sendStr = BCDUtil.byteArrToString(sendData); log.Write("发送支付的数据:" + sendStr); //Console.WriteLine(); //Console.WriteLine(BCDUtil.byteArrToString(sendData)); AnalysisBaseWT lk = new AnalysisBaseWT(); byte[] result = Client(LakalaIp, LakalaPort, sendData); //接收的数据 string receiveStr = BCDUtil.byteArrToString(result); log.Write("接收支付的数据:" + receiveStr); Dictionary <string, ResultData> ret = lk.analysis(result); string recode = Wanton.handleDataMac(ret); //发送数据 log.Write("支付返回码:" + recode); if ("00".Equals(recode)) { } else if ("A0".Equals(recode)) { DeviceState.SendState("333333"); } else { } map.Add("recode", recode); map.Add("sendStr", sendStr); map.Add("receiveStr", receiveStr); map.Add("ShopNo", param.orderNo + "|" + data[41] + "|" + data[42]); map.Add("money", param.price); if (ret.ContainsKey("2")) { map.Add("2", ret["2"].value); } map.Add("4", param.price); if (ret.ContainsKey("59")) { map.Add("59", ret["59"].value); map.Add("cloudOrderNo", ret["59"].value); } string serialStr = JsonConvert.SerializeObject(map); return(map); } catch (WtException e) { throw e; } catch (Exception e) { throw new WtException(WtExceptionCode.Bus.WT_PAY, e.Message); } }
/// <summary> /// 冲正 /// </summary> /// <returns></returns> public static Dictionary <string, string> correct(WintopPayParam param, string secondShopNo) { try { string termailNo = SysConfigHelper.readerNode("ClientNo"); Dictionary <string, string> map = new Dictionary <string, string>(); Dictionary <int, string> data = new Dictionary <int, string>(); data.Add(2, param.wintopNo); data.Add(3, "000000"); data.Add(4, wtPayUtils.ConvertMoney(param.price)); data.Add(11, param.orderNo); map.Add("11", data[11]); data.Add(25, "00"); data.Add(39, "17"); data.Add(41, termailNo); map.Add("41", data[41]); data.Add(42, SysConfigHelper.readerNode("ShopNo")); data.Add(48, "TC_ONE|Y00000001|" + secondShopNo); //data.Add(48, "Y00000001"); data.Add(49, "156"); data.Add(63, "01"); byte[] countMacData = EncryptWT.countMacData("0400", EncryptWT.encryptLKL(data, null)); byte[] mac = PasswordBLL.GetMac(2, countMacData); byte[] sendData = EncryptWT.EncryptData("0400", "6000000000", EncryptWT.encryptLKL(data, mac)); //发送的数据 string sendStr = BCDUtil.byteArrToString(sendData); log.Write("发送冲正的数据:" + sendStr); //byte[] sendData = EncryptWT.EncryptData("0400", "6000000000", EncryptWT.encryptLKL(data, calculateMac(data, "0400"))); Console.WriteLine(BCDUtil.byteArrToString(sendData)); AnalysisBaseWT lk = new AnalysisBaseWT(); byte[] result = Client(LakalaIp, LakalaPort, sendData); string recode = Wanton.handleDataMac(lk.analysis(result)); //发送数据 //接收的数据 string receiveStr = BCDUtil.byteArrToString(result); log.Write("接收冲正的数据:" + result); map.Add("recode", recode); map.Add("sendStr", sendStr); map.Add("receiveStr", receiveStr); map.Add("ShopNo", param.orderNo + "|" + data[41] + "|" + data[42]); map.Add("money", param.price); string serialStr = JsonConvert.SerializeObject(map); return(map); } catch (Exception e) { return(new Dictionary <string, string>()); } }
public static Dictionary <string, string> refund(string _2, string _4, string _59, TradeRecord tradeRecord, string secondShopNo) { string theOrderNo = Wanton.GetOrderNo(); string termailNo = SysConfigHelper.readerNode("ClientNo"); string shopNo = SysConfigHelper.readerNode("ShopNo"); tradeRecord.amount = _4; tradeRecord.batch_no = "" + "|" + SysBLL.getMMDDHHMMSSTime() + "|" + _2; tradeRecord.order_no = theOrderNo; tradeRecord.termail_no = termailNo; tradeRecord.lkl_wt_shop_no = shopNo; Dictionary <string, string> map = new Dictionary <string, string>(); Dictionary <int, string> data = new Dictionary <int, string>(); data.Add(2, _2); data.Add(3, "200000"); data.Add(4, wtPayUtils.ConvertMoney(_4)); data.Add(11, theOrderNo); map.Add("11", data[11]); data.Add(22, "051"); data.Add(25, "00"); data.Add(41, termailNo); map.Add("41", data[41]); data.Add(42, shopNo); data.Add(48, "TC_ONE|Y00000001|" + secondShopNo); //data.Add(48, "Y00000001"); data.Add(49, "156"); data.Add(59, _59); data.Add(60, "22000003000"); data.Add(63, "01"); byte[] countMacData = EncryptWT.countMacData("0200", EncryptWT.encryptLKL(data, null)); byte[] mac = PasswordBLL.GetMac(2, countMacData); byte[] sendData = EncryptWT.EncryptData("0200", "6000000000", EncryptWT.encryptLKL(data, mac)); //byte[] sendData = EncryptWT.EncryptData("0200", "6000000000", EncryptWT.encryptLKL(data, calculateMac(data, "0200"))); Console.WriteLine(); Console.WriteLine(BCDUtil.byteArrToString(sendData)); AnalysisBaseWT lk = new AnalysisBaseWT(); byte[] result = Client(LakalaIp, LakalaPort, sendData); //接收的数据 string receiveStr1 = BCDUtil.byteArrToString(result); log.Write("tuikuan的数据:" + receiveStr1); Dictionary <string, ResultData> ret = lk.analysis(result); string recode = Wanton.handleDataMac(ret); //发送数据 if ("00".Equals(recode)) { tradeRecord.lkl_wt_state = "1"; tradeRecord.order_state = "1"; } else { tradeRecord.lkl_wt_state = "2"; tradeRecord.order_state = "0"; } //发送的数据 string sendStr = BCDUtil.byteArrToString(sendData); //接收的数据 string receiveStr = BCDUtil.byteArrToString(result); map.Add("recode", recode); map.Add("sendStr", sendStr); map.Add("receiveStr", receiveStr); map.Add("ShopNo", data[11] + "|" + data[41] + "|" + data[42]); map.Add("39", ret["39"].value); log.Write("万通卡退款交易返回" + ret["39"].value); string serialStr = JsonConvert.SerializeObject(map); tradeRecord.data_id = serialStr; TradeBLL.SendOrderRefundRecord(tradeRecord); return(map); //if (result.Length > 0) //{ // return lk.analysis(result); //发送数据 //} //else //{ // return null; //} }