Ejemplo n.º 1
0
        protected override void Packet()
        {
            switch (m_process)
            {
            case 0:
            {
                string strCount = "1" + m_aidList.Count.ToString("00");
                SendPackage.SetString(0, "0820");
                SendPackage.SetString(60, "00" + GetBatchNo() + "382");
                SendPackage.SetArrayData(63, Encoding.Default.GetBytes(strCount), 0, 3);
            } break;

            case 1:
            {
                SendPackage.SetString(0, "0800");
                SendPackage.SetString(60, "00" + GetBatchNo() + "380");
                SendPackage.SetArrayData(63, m_downAID);
            } break;

            case 2:
            {
                SendPackage.SetString(0, "0800");
                SendPackage.SetString(60, "00" + GetBatchNo() + "381");
            } break;
            }
        }
Ejemplo n.º 2
0
        protected override void Packet()
        {
            SendPackage.SetString(0, "0100");
            //SendPackage.SetString(2, CommonData.BankCardNum); //c
            //if (!string.IsNullOrEmpty(CommonData.BankCardNum) && CommonData.BankCardNum.Length != 0)
            //{
            //    SendPackage.SetString(2, CommonData.BankCardNum);
            //}
            SendPackage.SetString(3, "310000");
            //SendPackage.SetString(4, Utility.AmountToString(CommonData.Amount.ToString()));
            SendPackage.SetString(11, GetTraceNo());
            SendPackage.SetString(12, DateTime.Now.ToString("HHmmss"));
            SendPackage.SetString(13, DateTime.Now.ToString("MMdd"));
            SendPackage.SetString(25, "92");

            //SendPackage.SetString(37, PayEntity.PayReferenceNo);
            SendPackage.SetString(41, GetTerminalNo());
            SendPackage.SetString(42, GetMerchantNo());

            SendPackage.SetArrayData(48, PacketField48());
            SendPackage.SetString(49, "195");
            //SendPackage.SetArrayData(57, PacketField57());
            //SendPackage.SetString(57, (PayEntity.PowerCardData.EF31 + PayEntity.PowerCardData.EF32).PadRight(999, ' '));
            SendPackage.SetString(60, "00" + GetBatchNo() + "000");
        }
Ejemplo n.º 3
0
        protected override void Packet()
        {
            SendPackage.SetString(0, "0100");
            //if (!string.IsNullOrEmpty(PayEntity.signBankCardNo))
            //{
            //    SendPackage.SetString(2, PayEntity.signBankCardNo);
            //}
            SendPackage.SetString(3, "354000");
            SendPackage.SetArrayData(4, Encoding.Default.GetBytes("0"));
            PayEntity.PayTraceNo = GetTraceNo();
            SendPackage.SetString(11, PayEntity.PayTraceNo);
            SendPackage.SetString(12, DateTime.Now.ToString("HHmmss"));
            SendPackage.SetString(13, DateTime.Now.ToString("yyyyMMdd"));
            SendPackage.SetArrayData(18, Encoding.Default.GetBytes("STA"));
            SendPackage.SetArrayData(41, Encoding.ASCII.GetBytes(GetMerchantNo()));
            SendPackage.SetArrayData(42, Encoding.ASCII.GetBytes(GetTerminalNo()));
            SendPackage.SetString(47, PayEntity.unitNo + PayEntity.cardinfo.cardNo.PadRight(42, ' '));

            if (string.Compare(PayEntity.cardinfo.cardType, "0") == 0)
            {
                //工业卡充钱
                PayEntity.buyNums = 0;
            }
            SendPackage.SetArrayData(48, Encoding.Default.GetBytes("ICDATA" + PayEntity.cardinfo.cardNo + "|" + PayEntity.cardinfo.icMark + "|" + PayEntity.cardinfo.icNum + "|" + GetTerminalNo() + "|" + PayEntity.cardinfo.strEnCrypt + "|" + PayEntity.buyNums.ToString()));
            SendPackage.SetString(49, "156");
        }
Ejemplo n.º 4
0
 public void SetField55Value(byte[] field55, int len)
 {
     if (len != 0)
     {
         SendPackage.SetArrayData(55, field55, 0, len);
     }
 }
Ejemplo n.º 5
0
 protected override void Packet()
 {
     if (SendPackage.ExistBit(55))
     {
         byte[] bSend55 = SendPackage.GetArrayData(55);
         byte[] field55 = GetICAutoField55(bSend55, bSend55.Length);//IC卡55域有变动
         SendPackage.SetArrayData(55, field55, 0, field55.Length);
     }
     PackReverse(Reason);
 }
Ejemplo n.º 6
0
 protected override void Packet()
 {
     SendPackage.SetString(0, "0100");
     SendPackage.SetString(3, "310000");
     SendPackage.SetString(11, GetTraceNo());
     SendPackage.SetString(25, "92"); //服务点条件代码
     SendPackage.SetArrayData(48, PacketField48());
     SendPackage.SetString(49, "156");
     SendPackage.SetString(60, "00" + GetBatchNo() + "000");
 }
Ejemplo n.º 7
0
        protected override void Packet()
        {
            bool bIsIC = false;

            if (CommonData.UserCardType == UserBankCardType.ICCard ||
                CommonData.UserCardType == UserBankCardType.IcMagCard)
            {
                bIsIC = true;
            }
            SendPackage.SetString(0, "0100");
            if (!string.IsNullOrEmpty(CommonData.BankCardNum) && CommonData.BankCardNum.Length != 0)
            {
                SendPackage.SetString(2, CommonData.BankCardNum);
            }

            SendPackage.SetString(3, "351000");
            SendPackage.SetArrayData(4, Encoding.Default.GetBytes(Utility.AmountToString(CommonData.Amount.ToString())));

            PayEntity.PayTraceNo = GetTraceNo();
            SendPackage.SetString(11, PayEntity.PayTraceNo);
            SendPackage.SetString(12, DateTime.Now.ToString("HHmmss"));
            SendPackage.SetString(13, DateTime.Now.ToString("yyyyMMdd"));
            SendPackage.SetArrayData(18, Encoding.Default.GetBytes("STA"));

            if (bIsIC)
            {
                SendPackage.SetArrayData(22, Utility.str2Bcd("051".PadRight(28, '0')));
            }
            if (!string.IsNullOrEmpty(CommonData.BankCardSeqNum) && CommonData.BankCardSeqNum.Length != 0)//卡序列号
            {
                SendPackage.SetArrayData(23, Encoding.Default.GetBytes(CommonData.BankCardSeqNum));
            }
            //SendPackage.SetArrayData(25, Encoding.Default.GetBytes("91")); //服务点条件代码


            if (!string.IsNullOrEmpty(CommonData.Track2) && CommonData.Track2.Length != 0)
            {
                SendPackage.SetArrayData(35, Encoding.Default.GetBytes(CommonData.Track2.Replace('=', 'D')));
            }
            SendPackage.SetArrayData(41, Encoding.ASCII.GetBytes(GetMerchantNo()));
            SendPackage.SetArrayData(42, Encoding.ASCII.GetBytes(GetTerminalNo()));
            SendPackage.SetString(47, PayEntity.unitNo + PayEntity.cardinfo.cardNo.PadRight(42, ' '));
            SendPackage.SetArrayData(48, Encoding.Default.GetBytes(PayEntity.cardinfo.cardNo + "|" + PayEntity.cardinfo.icMark + "|" + PayEntity.cardinfo.icNum + "|" + GetTerminalNo() + "|" + "" + "|" + PayEntity.cardinfo.strEnCrypt));
            SendPackage.SetString(49, "159");
            SendPackage.SetArrayData(52, Utility.str2Bcd(CommonData.BankPassWord));
            if ((bIsIC) && PayEntity.SendField55 != null && PayEntity.SendField55.Length != 0)
            {
                SendPackage.SetString(55, Utility.bcd2str(PayEntity.SendField55, PayEntity.SendField55.Length));
            }

            //SendPackage.SetString(60, ("00" + GetBatchNo() + "000"));
        }
Ejemplo n.º 8
0
        protected override void Packet()
        {
            SendPackage.SetString(0, "0320");
            SendPackage.SetString(2, CommonData.BankCardNum);
            SendPackage.SetString(3, "290000");
            SendPackage.SetString(4, Utility.AmountToString(CommonData.Amount.ToString()));

            SendPackage.SetString(11, GetTraceNo());
            SendPackage.SetString(25, "00"); //服务点条件代码
            SendPackage.SetArrayData(48, PacketField48());
            SendPackage.SetString(49, "156");
            SendPackage.SetString(60, "00" + GetBatchNo() + "362");
        }
Ejemplo n.º 9
0
 protected override void Packet()
 {
     SendPackage.SetString(0, "0100");
     SendPackage.SetString(3, "350000");
     PayEntity.PayTraceNo = GetTraceNo();
     SendPackage.SetString(11, PayEntity.PayTraceNo);
     SendPackage.SetString(12, DateTime.Now.ToString("HHmmss"));
     SendPackage.SetString(13, DateTime.Now.ToString("yyyyMMdd"));
     SendPackage.SetArrayData(18, Encoding.Default.GetBytes("STA"));
     SendPackage.SetArrayData(41, Encoding.ASCII.GetBytes(GetMerchantNo()));
     SendPackage.SetArrayData(42, Encoding.ASCII.GetBytes(GetTerminalNo()));
     SendPackage.SetString(47, PayEntity.unitNo + DateTime.Now.ToString("yyyyMMddHHmm"));
 }
Ejemplo n.º 10
0
 protected override void Packet()
 {
     SendPackage.SetString(0, "0100");
     SendPackage.SetString(3, "381008");
     PayEntity.PayTraceNo = GetTraceNo();
     SendPackage.SetString(11, PayEntity.PayTraceNo);
     SendPackage.SetString(12, DateTime.Now.ToString("HHmmss"));
     SendPackage.SetString(13, DateTime.Now.ToString("yyyyMMdd"));
     SendPackage.SetArrayData(18, Encoding.Default.GetBytes("STA"));
     SendPackage.SetArrayData(41, Encoding.ASCII.GetBytes(GetMerchantNo()));
     SendPackage.SetArrayData(42, Encoding.ASCII.GetBytes(GetTerminalNo()));
     SendPackage.SetString(47, PayEntity.unitNo + PayEntity.cardinfo.cardNo.PadRight(20, ' '));
     SendPackage.SetArrayData(48, Encoding.Default.GetBytes(PayEntity.cardinfo.cardNo + "|" + PayEntity.cardinfo.icMark + "|" + PayEntity.cardinfo.icNum + "|" + GetTerminalNo() + "|"));
     SendPackage.SetString(49, "159");
 }
Ejemplo n.º 11
0
 protected override void Packet()
 {
     SendPackage.SetString(0, "0320");
     SendPackage.SetString(3, "290000");
     SendPackage.SetString(4, Utility.AmountToString(CommonData.Amount.ToString()));
     SendPackage.SetString(11, GetTraceNo());
     SendPackage.SetString(25, "00"); //服务点条件代码
     SendPackage.SetString(41, GetTerminalNo());
     SendPackage.SetString(42, GetMerchantNo());
     SendPackage.SetArrayData(48, PacketField48());
     SendPackage.SetString(49, "156");
     //byte[] field57 = PacketField57();
     //if (field57!=null && field57.Length > 0)
     SendPackage.SetArrayData(57, PacketField57());
     SendPackage.SetString(60, "00" + GetBatchNo() + "362");
 }
Ejemplo n.º 12
0
        protected override void Packet()
        {
            SendPackage.SetString(0, "0800");
            SendPackage.SetString(11, GetTraceNo());
            switch (DType)
            {
            case DesType.TripleDes:
                SendPackage.SetString(60, "00" + GetBatchNo() + "003");
                break;

            default:
                SendPackage.SetString(60, "00" + GetBatchNo() + "001");
                break;
            }
            SendPackage.SetArrayData(63, Encoding.Default.GetBytes("001"));
        }
Ejemplo n.º 13
0
        protected override void Packet()
        {
            SendPackage.SetString(0, "0100");
            SendPackage.SetString(2, PayEntity.CreditcardNum);
            SendPackage.SetString(3, "310000");
            SendPackage.SetString(4, Utility.AmountToString(CommonData.Amount.ToString()));
            SendPackage.SetString(11, GetTraceNo());
            SendPackage.SetString(22, "012");
            SendPackage.SetString(25, "92");
            //SendPackage.SetString(48, "PA" + "08" + PayEntity.CreditcardNum.PadRight(19, ' ') + "0".PadRight(11, '0') + "#");
            string f48 = "PA" + "08" + PayEntity.CreditcardNum.PadRight(19, ' ') + "0".PadRight(11, '0') + "#";

            SendPackage.SetArrayData(48, Encoding.Default.GetBytes(f48));

            SendPackage.SetString(49, "156");
        }
Ejemplo n.º 14
0
 protected override void Packet()
 {
     SendPackage.SetString(0, "0100");
     if (!string.IsNullOrEmpty(PayEntity.cardinfo.cardNo))
     {
         SendPackage.SetString(2, PayEntity.cardinfo.cardNo);
     }
     SendPackage.SetString(3, "300644");
     PayEntity.PayTraceNo = GetTraceNo();
     SendPackage.SetString(11, PayEntity.PayTraceNo);
     SendPackage.SetString(12, DateTime.Now.ToString("HHmmss"));
     SendPackage.SetString(13, DateTime.Now.ToString("yyyyMMdd"));
     SendPackage.SetArrayData(18, Encoding.Default.GetBytes("STA"));
     SendPackage.SetArrayData(41, Encoding.ASCII.GetBytes(GetMerchantNo()));
     SendPackage.SetArrayData(42, Encoding.ASCII.GetBytes(GetTerminalNo()));
     SendPackage.SetString(47, PayEntity.unitNo + PayEntity.cardinfo.cardNo.PadRight(20, ' '));
     SendPackage.SetString(49, "156");
 }
Ejemplo n.º 15
0
 protected override void Packet()
 {
     try
     {
         SendPackage.SetString(0, "0100");
         SendPackage.SetString(3, "349000");
         SendPackage.SetString(11, GetTraceNo());
         SendPackage.SetString(12, DateTime.Now.ToString("HHmmss"));
         SendPackage.SetString(13, DateTime.Now.ToString("yyyyMMdd"));
         //SendPackage.SetString(18, "STA");
         SendPackage.SetArrayData(18, Encoding.ASCII.GetBytes("STA"));
         SendPackage.SetArrayData(41, Encoding.ASCII.GetBytes(GetMerchantNo()));
         SendPackage.SetArrayData(42, Encoding.ASCII.GetBytes(GetTerminalNo()));
         SendPackage.SetArrayData(64, Encoding.ASCII.GetBytes("00000000"));
     }
     catch (Exception ex)
     {
         Log.Error("[ApplicationKeyPay][Packet] err", ex);
     }
 }
Ejemplo n.º 16
0
        protected override void Packet()
        {
            SendPackage.SetString(0, "0100");
            SendPackage.SetString(3, "380000");
            SendPackage.SetString(11, GetTraceNo());
            SendPackage.SetString(25, "00"); //服务点条件代码
            SendPackage.SetArrayData(48, PacketField48());
            SendPackage.SetString(49, "156");
            switch (DType)
            {
            case DesType.Des:
                SendPackage.SetString(53, "20");
                break;

            case DesType.TripleDes:
                SendPackage.SetString(53, "26");
                break;
            }
            SendPackage.SetString(60, "00" + GetBatchNo() + "000");
        }
Ejemplo n.º 17
0
 protected override void Packet()
 {
     SendPackage.SetString(0, "0820");
     SendPackage.SetString(60, "00" + GetBatchNo() + "382");
     SendPackage.SetArrayData(63, Encoding.Default.GetBytes(StrField62), 0, 3);
 }
Ejemplo n.º 18
0
        /// <summary>
        /// 重写通信函数
        /// </summary>
        /// <returns></returns>
        internal override TransResult transact()
        {
            int         headLen;
            TransResult ret    = TransResult.E_SEND_FAIL;
            Socket      socket = null;

            if (RealEnv)
            {
                if (!GPRSConnect())
                {
                    return(ret);
                }
                IPAddress  ip  = IPAddress.Parse(serverIP);
                IPEndPoint ipe = new IPEndPoint(ip, serverPort); //把ip和端口转化为IPEndPoint实例
                socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);

                try
                {
                    socket.SendTimeout    = sendTimeOut * 1000;
                    socket.ReceiveTimeout = recvTimeOut * 1000;
                    socket.Connect(ipe);
                }
                catch (Exception err)
                {
                    Log.Error(this.GetType().Name, err);
                    return(ret);
                }
            }

            try
            {
                ret = TransResult.E_PACKET_FAIL;
                byte[] SendBytes = new byte[0];
                PackFix();
                Packet();
                if (SendPackage.IsNull())
                {
                    return(TransResult.E_INVALID);
                }
                byte[] MAC = new byte[8];

                //计算mac并将mac打包进去
                if (NeedCalcMac())
                {
                    byte[] macKey = null;
                    //if (EnType == EncryptType.Hardware)
                    //    macKey = KeyManager.GetEnMacKey(mSectionName);
                    //else
                    macKey = KeyManager.GetDeMacKey(mSectionName);
                    if (macKey == null)
                    {
                        throw new Exception("尚未设置MAC密钥");
                    }
                    if ((DType == DesType.Des && macKey.Length == 16) || (DType == DesType.TripleDes && macKey.Length == 8))
                    {
                        throw new Exception("MAC密钥长度不符合DES算法");
                    }
                    int macField = 64;
                    if (SendPackage.ExistBit(1))
                    {
                        macField = 128;
                    }
                    SendPackage.SetArrayData(macField, new byte[8]);
                    byte[] tmp      = SendPackage.GetSendBuffer();
                    byte[] macBytes = new byte[tmp.Length - 8];
                    Array.Copy(tmp, macBytes, macBytes.Length);
                    //Log.Debug(Utility.bcd2str(macBytes, macBytes.Length));
                    if (CalcMac(macBytes, macKey, ref MAC))
                    {
                        SendPackage.SetArrayData(macField, MAC);
                    }
                    else
                    {
                        SendPackage.ClearBitAndValue(macField);
                        throw new Exception("计算MAC失败");
                    }
                }
                SendBytes = SendPackage.GetSendBuffer();
                if (SendBytes.Length <= 0)
                {
                    return(ret);
                }
                byte[] head = PackBytesAtFront(SendBytes.Length);
                headLen = head.Length;
                int sendLen_all = SendBytes.Length + head.Length;

                byte[] sendstr_all = new byte[sendLen_all];
                Array.Copy(head, sendstr_all, head.Length);
                Array.Copy(SendBytes, 0, sendstr_all, head.Length, SendBytes.Length);

                //记录原始发送日志
                //CLog.LogPackage(sendstr_all, SendPackage, CLog.LogType.Send);
                CLog.Info(CLog.GetLog(sendstr_all, SendPackage, this, CLog.LogType.Send));

                ret = TransResult.E_SEND_FAIL;
                if (RealEnv)
                {
                    int sendLen = 0;
                    sendLen = socket.Send(sendstr_all, sendLen_all, 0);
                    if (sendLen <= 0)
                    {
                        socket.Close();
                        return(ret);
                    }
                }

                //从服务器端接受返回信息
                ret = TransResult.E_RECV_FAIL;
                int recvLen = 0;
                if (RealEnv)
                {
                    sRecvBuffer.Initialize();
                    recvLen = socket.Receive(sRecvBuffer, sRecvBuffer.Length, 0);

                    if (recvLen <= 0)
                    {
                        socket.Close();
                        return(ret);
                    }
                    byte[] RecvBytes = new byte[recvLen - headLen];
                    Array.Copy(sRecvBuffer, headLen, RecvBytes, 0, recvLen - headLen);
                    byte[] headBytes = new byte[headLen];
                    Array.Copy(sRecvBuffer, headBytes, headLen);
                    //CLog.Info(RecvPackage);

                    //解包
                    ret        = TransResult.E_UNPACKET_FAIL;
                    FrontBytes = headBytes;
                    HandleFrontBytes(headBytes);//根据报文头来判断是否要下载密钥
                    RecvPackage.ParseBuffer(RecvBytes, SendPackage.ExistValue(0));
                    //CLog.Info(RecvBytes);
                    //记录原始接收日志
                    byte[] logRecv = new byte[recvLen];
                    Array.Copy(sRecvBuffer, logRecv, recvLen);
                    //CLog.LogPackage(logRecv, RecvPackage, CLog.LogType.Recv);
                    CLog.Info(CLog.GetLog(logRecv, RecvPackage, this, CLog.LogType.Recv));
                    bool nRet = UnPackFix();
                    if (!mInvokeSetResult)
                    {
                        throw new Exception("should invoke SetRespInfo() in UnPackFix()");
                    }
                    mInvokeSetResult = false;
                    if (nRet)
                    {
                        ret = TransResult.E_SUCC;
                    }
                    else
                    {
                        ret = TransResult.E_HOST_FAIL;
                    }
                }
                else
                {
                    ret = TransResult.E_SUCC;
                }
            }
            catch (System.Exception ex)
            {
                Log.Error(this.GetType().Name, ex);
            }
            finally
            {
                if (socket != null && socket.Connected)
                {
                    socket.Close();
                }
            }
            return(ret);
        }
Ejemplo n.º 19
0
 protected override void PackFix()
 {
     SendPackage.SetArrayData(41, Encoding.ASCII.GetBytes(GetMerchantNo()));
     SendPackage.SetArrayData(42, Encoding.ASCII.GetBytes(GetTerminalNo()));
 }
Ejemplo n.º 20
0
        private TransResult Pack8583()
        {
            var ret = TransResult.E_PACKET_FAIL;

            try
            {
                var SendBytes = new byte[0];
                PackFix();
                Packet();
                if (SendPackage.IsNull())
                {
                    return(TransResult.E_INVALID);
                }
                var MAC = new byte[8];

                //计算mac并将mac打包进去
                if (NeedCalcMac())
                {
                    byte[] macKey = null;
                    if (EnType == EncryptType.Hardware)
                    {
                        macKey = KeyManager.GetEnMacKey(mSectionName);
                    }
                    else
                    {
                        macKey = KeyManager.GetDeMacKey(mSectionName);
                    }
                    if (macKey == null)
                    {
                        throw new Exception("尚未设置MAC密钥");
                    }
                    if ((DType == DesType.Des && macKey.Length == 16) ||
                        (DType == DesType.TripleDes && macKey.Length == 8))
                    {
                        throw new Exception("MAC密钥长度不符合DES算法");
                    }
                    var macField = 64;
                    if (SendPackage.ExistBit(1))
                    {
                        macField = 128;
                    }
                    SendPackage.SetArrayData(macField, new byte[8]);
                    var tmp      = SendPackage.GetSendBuffer();
                    var macBytes = new byte[tmp.Length - 8];
                    Array.Copy(tmp, macBytes, macBytes.Length);

                    if (CalcMacByMackey(macBytes, MAC))
                    {
                        SendPackage.SetArrayData(macField, MAC);
                    }
                    else
                    {
                        SendPackage.ClearBitAndValue(macField);
                        throw new Exception("计算MAC失败");
                    }
                }
                SendBytes = SendPackage.GetSendBuffer();
                if (SendBytes.Length <= 0)
                {
                    return(ret);
                }
                var head_8583 = PackBytesAtFront(SendBytes.Length);
                headLen_8583 = head_8583.Length;

                #region Json复合8583包打包(子类中重写PackSendObject())方法
                SendObject = PackSendObject();
                string strJson = "";
                BaseCommunicateSendJson send = SendObject as BaseCommunicateSendJson;
                if (send != null) //对象必须是继承基类型的才采用json发送
                {
                    send.rowCount = send.DS.Length;
                    strJson       = JsonConvert.SerializeObject(SendObject);
                }
                #endregion


                //if (!string.IsNullOrEmpty(strJson))
                //{
                byte[] json = Encoding.Default.GetBytes(strJson);
                //}
                var sendLen_all = SendBytes.Length + head_8583.Length + json.Length;

                var t_head = PackHead(sendLen_all);//自定义报文头
                headLen      = t_head.Length;
                sendLen_all += headLen;
                sendstr_all  = new byte[sendLen_all];

                Array.Copy(t_head, sendstr_all, t_head.Length);
                Array.Copy(head_8583, 0, sendstr_all, headLen, head_8583.Length);
                Array.Copy(SendBytes, 0, sendstr_all, head_8583.Length + headLen, SendBytes.Length);
                if (!string.IsNullOrEmpty(strJson))
                {
                    Array.Copy(json, 0, sendstr_all, head_8583.Length + headLen + SendBytes.Length, json.Length);
                }

                ret = TransResult.E_SUCC;
            }
            catch (Exception ex)
            {
                Log.Error(GetType().Name, ex);
            }
            return(ret);
        }
Ejemplo n.º 21
0
 protected override void Packet()
 {
     SendPackage.SetString(0, "0800");
     SendPackage.SetString(60, "00" + GetBatchNo() + "370");
     SendPackage.SetArrayData(63, BField62);
 }
Ejemplo n.º 22
0
        //protected override void Packet()
        //{
        //    if (SendPackage.ExistBit(55))
        //    {
        //        byte[] bSend55 = SendPackage.GetArrayData(55);
        //        byte[] field55 = GetICAutoField55(bSend55, bSend55.Length);//IC卡55域有变动
        //        SendPackage.SetArrayData(55, field55, 0, field55.Length);
        //    }
        //    PackReverse(Reason);
        //}

        protected override void Packet()
        {
            bool bIsIC = false;

            if (CommonData.UserCardType == UserBankCardType.ICCard ||
                CommonData.UserCardType == UserBankCardType.IcMagCard)
            {
                bIsIC = true;
            }

            SendPackage.SetString(0, "0400");
            if (!string.IsNullOrEmpty(CommonData.BankCardNum) && CommonData.BankCardNum.Length != 0)
            {
                SendPackage.SetString(2, CommonData.BankCardNum);
            }
            SendPackage.SetString(3, "190000");
            SendPackage.SetString(4, Utility.AmountToString(CommonData.Amount.ToString()));
            //PayEntity.PayTraceNo = GetTraceNo();
            //SendPackage.SetString(11, PayEntity.PayTraceNo);
            if (!string.IsNullOrEmpty(CommonData.BankCardExpDate) && CommonData.BankCardExpDate.Length != 0)//卡有效期
            {
                SendPackage.SetString(14, CommonData.BankCardExpDate);
            }
            if (bIsIC)//22
            {
                SendPackage.SetString(22, "051");
            }
            else
            {
                SendPackage.SetString(22, "021");
            }
            //if (!string.IsNullOrEmpty(CommonData.BankCardSeqNum) && CommonData.BankCardSeqNum.Length != 0)//卡序列号
            //{
            //    SendPackage.SetString(23, CommonData.BankCardSeqNum);
            //}
            SendPackage.SetString(25, "81"); //服务点条件代码
            //SendPackage.SetString(26, "06");
            if (!string.IsNullOrEmpty(CommonData.Track2) && CommonData.Track2.Length != 0)
            {
                SendPackage.SetString(35, CommonData.Track2.Replace('=', 'D'));
            }
            if (!string.IsNullOrEmpty(CommonData.Track3) && CommonData.Track3.Length != 0)
            {
                SendPackage.SetString(36, CommonData.Track3.Replace('=', 'D'));
            }
            SendPackage.SetString(41, GetTerminalNo());
            SendPackage.SetString(42, GetMerchantNo());
            SendPackage.SetArrayData(48, PacketField48());
            SendPackage.SetString(49, "156");
            if (SendPackage.ExistBit(55))
            {
                byte[] bSend55 = SendPackage.GetArrayData(55);
                byte[] field55 = GetICAutoField55(bSend55, bSend55.Length);//IC卡55域有变动
                SendPackage.SetArrayData(55, field55, 0, field55.Length);
            }
            PackReverse(Reason);

            //SendPackage.SetArrayData(52, Utility.str2Bcd(CommonData.BankPassWord));
            //switch (DType)
            //{
            //    case DesType.Des:
            //        SendPackage.SetString(53, "2000000000000000");
            //        break;
            //    case DesType.TripleDes:
            //        SendPackage.SetString(53, "2600000000000000");
            //        break;
            //}
            ////55
            //if (bIsIC && PayEntity.SendField55 != null && PayEntity.SendField55.Length != 0)
            //{
            //    SendPackage.SetArrayData(55, PayEntity.SendField55);
            //}
            //if (bIsIC)
            //    SendPackage.SetString(60, "22" + GetBatchNo() + "00050");
            //else
            //    SendPackage.SetString(60, "22" + GetBatchNo());

            ////创建冲正文件 98 96 06
            //CReverse_PowerPay cr = new CReverse_PowerPay(this);
            //cr.CreateReverseFile("98");
        }
Ejemplo n.º 23
0
        protected override void Packet()
        {
            bool bIsIC = false;

            if (CommonData.UserCardType == UserBankCardType.ICCard ||
                CommonData.UserCardType == UserBankCardType.IcMagCard)
            {
                bIsIC = true;
            }

            SendPackage.SetString(0, "0200");
            if (!string.IsNullOrEmpty(CommonData.BankCardNum) && CommonData.BankCardNum.Length != 0)
            {
                SendPackage.SetString(2, CommonData.BankCardNum);
            }
            SendPackage.SetString(3, "190000");
            SendPackage.SetString(4, Utility.AmountToString(CommonData.Amount.ToString()));
            PayTraceNo = GetTraceNo();
            SendPackage.SetString(11, PayTraceNo);
            if (!string.IsNullOrEmpty(CommonData.BankCardExpDate) && CommonData.BankCardExpDate.Length != 0)//卡有效期
            {
                SendPackage.SetString(14, CommonData.BankCardExpDate);
            }
            if (bIsIC)//22
            {
                SendPackage.SetString(22, "051");
            }
            else
            {
                SendPackage.SetString(22, "021");
            }
            if (!string.IsNullOrEmpty(CommonData.BankCardSeqNum) && CommonData.BankCardSeqNum.Length != 0)//卡序列号
            {
                SendPackage.SetString(23, CommonData.BankCardSeqNum);
            }
            SendPackage.SetString(25, "81"); //服务点条件代码
            SendPackage.SetString(26, "06");
            if (!string.IsNullOrEmpty(CommonData.Track2) && CommonData.Track2.Length != 0)
            {
                SendPackage.SetString(35, CommonData.Track2.Replace('=', 'D'));
            }
            if (!string.IsNullOrEmpty(CommonData.Track3) && CommonData.Track3.Length != 0)
            {
                SendPackage.SetString(36, CommonData.Track3.Replace('=', 'D'));
            }
            SendPackage.SetArrayData(48, PacketField48());
            SendPackage.SetString(49, "156");
            SendPackage.SetArrayData(52, Utility.str2Bcd(CommonData.BankPassWord));
            switch (DType)
            {
            case DesType.Des:
                SendPackage.SetString(53, "2000000000000000");
                break;

            case DesType.TripleDes:
                SendPackage.SetString(53, "2600000000000000");
                break;
            }
            //55
            if (SendField55 != null && SendField55.Length != 0)
            {
                SendPackage.SetArrayData(55, SendField55, 0, SendField55.Length);
            }
            if (bIsIC)
            {
                SendPackage.SetString(60, "00" + GetBatchNo() + "00050");
            }
            else
            {
                SendPackage.SetString(60, "00" + GetBatchNo() + "000");
            }

            //创建冲正文件 98 96 06
            CReverse_YAPaymentPay cr = new CReverse_YAPaymentPay(this);

            cr.CreateReverseFile("98");
        }
Ejemplo n.º 24
0
        protected override void Packet()
        {
            bool bIsIC = false;

            if (CommonData.UserCardType == UserBankCardType.ICCard ||
                CommonData.UserCardType == UserBankCardType.IcMagCard)
            {
                bIsIC = true;
            }

            SendPackage.SetString(0, "0200");
            SendPackage.SetString(3, "190000");
            SendPackage.SetString(4, Utility.AmountToString(PayEntity.TotalAmount.ToString()));
            PayEntity.PayTraceNo = GetTraceNo();
            SendPackage.SetString(11, PayEntity.PayTraceNo);
            if (!string.IsNullOrEmpty(CommonData.BankCardExpDate) && CommonData.BankCardExpDate.Length != 0)//卡有效期
            {
                SendPackage.SetString(14, CommonData.BankCardExpDate);
            }
            if (bIsIC)//22
            {
                SendPackage.SetString(22, "051");
            }
            else
            {
                SendPackage.SetString(22, "021");
            }
            if (!string.IsNullOrEmpty(CommonData.BankCardSeqNum) && CommonData.BankCardSeqNum.Length != 0)//卡序列号
            {
                SendPackage.SetString(23, CommonData.BankCardSeqNum);
            }
            SendPackage.SetString(25, "00");
            SendPackage.SetString(26, "06");
            if (!string.IsNullOrEmpty(CommonData.Track2) && CommonData.Track2.Length != 0)
            {
                SendPackage.SetString(35, CommonData.Track2.Replace('=', 'D'));
            }
            if (!string.IsNullOrEmpty(CommonData.Track3))
            {
                SendPackage.SetString(36, CommonData.Track3.Replace('=', 'D'));
            }
            //SendPackage.SetString(48, "PA" + "08" + PayEntity.CreditcardNum.PadRight(20, ' ') + "N" + "0".PadRight(11, '0') + "#");
            string f48 = "PA" + "08" + PayEntity.CreditcardNum.PadRight(20, ' ') + "N" + "0".PadRight(11, '0') + "#";

            SendPackage.SetArrayData(48, Encoding.Default.GetBytes(f48));
            SendPackage.SetArrayData(52, Utility.str2Bcd(CommonData.BankPassWord));
            SendPackage.SetString(49, "156");
            switch (DType)
            {
            case DesType.Des:
                SendPackage.SetString(53, "2000000000000000");
                break;

            case DesType.TripleDes:
                SendPackage.SetString(53, "2600000000000000");
                break;
            }
            //55
            if (bIsIC && PayEntity.SendField55 != null && PayEntity.SendField55.Length != 0)
            {
                SendPackage.SetArrayData(55, PayEntity.SendField55);
            }
            if (PayEntity.UseICCard)
            {
                SendPackage.SetString(60, "00" + GetBatchNo() + "00050");
            }
            else
            {
                SendPackage.SetString(60, "00" + GetBatchNo() + "000");
            }

            //创建冲正文件 98 96 06
            CReverse_YAPaymentPay cr = new CReverse_YAPaymentPay(this);

            cr.CreateReverseFile("98");
        }