Beispiel #1
0
        public static void Display(byte[] bytes)
        {
            I8583 i8583 = new I8583(I8583.GetMessageType(bytes));

            i8583.UnPack8583(bytes.Skip(2).ToArray());
            Display(i8583);
        }
Beispiel #2
0
        public static void SetMac(this I8583 current, string packNo, string key)
        {
            var i8583 = current.Clone();

            i8583.settabx_data(63, "");
            var    data = i8583.Pack8583(packNo);
            string mac  = LCDES.MACEncrypt(data, key, 2);

            current.settabx_data(63, mac);
        }
Beispiel #3
0
        protected override byte[] OnGetData()
        {
            if (Result == ResponseCode.Success && !BadDeals.Check(BatchNo, SerialNo, ShopName, PosName))
            {
                string accountName = AccountName.Substring(0, AccountNameLength);
                lock (string.Intern(ShopName))
                {
                    string token = GetToken();
                    _i8583.settabx_data(1, accountName);

                    //KeysEntry key = GetCurrentKey();
                    var       PosKey = Context.AccountDealService.GetPosKey(ShopName, PosName);
                    KeysEntry key    = PosKey == null ? null : new KeysEntry()
                    {
                        Key1 = PosKey.Key1, Key2 = PosKey.Key2, PosName = PosName, ShopName = ShopName
                    };
                    if (Result == ResponseCode.Success)
                    {
                        string passwrod = "";
                        if (this.AccountName.IndexOf("d") > -1)
                        {
                            passwrod = GetPassword(accountName);//´ÅÌõ¿¨
                        }
                        else
                        {
                            passwrod = GetPassword(this.AccountName);//IC¿¨
                        }
                        string seriaNo = _i8583.gettabx_data(60);
                        if (seriaNo.Length > 12)
                        {
                            seriaNo = seriaNo.Substring(0, 12);
                        }
                        AccountServiceResponse rsp =
                            Context.AccountDealService.CancelPay(new CancelPayRequest(accountName, passwrod, PosName, DealAmount,
                                                                                      BatchNo + SerialNo, seriaNo, token, ShopName));
                        Result = rsp.Code;
                        if (Result == ResponseCode.Success)
                        {
                            SerialServerNo = rsp.SerialServerNo;
                            Amount         = rsp.Amount;
                            I8583 i8583 = _i8583.Clone();
                            i8583.settabx_data(63, "");
                            byte[] data = i8583.Pack8583("0210");
                            string mac  = LCDES.MACEncrypt(data, key.Key2, 2);
                            mac = Helper.WrapMac("cancel_deal", mac);
                            _i8583.settabx_data(63, mac);
                        }
                    }
                }
            }
            return(_i8583.Pack8583("0210"));
        }
Beispiel #4
0
        public static string Display(this I8583 i8583)
        {
            StringBuilder buf = new StringBuilder();

            buf.AppendLine("msgtype--" + i8583.MessageType);
            for (int i = 0; i < 64; i++)
            {
                if (i8583.Gettabx_flag(i) == "1")
                {
                    buf.AppendLine((i + 1).ToString() + "--" + i8583.gettabx_data(i));
                }
            }
            return(buf.ToString());
        }
Beispiel #5
0
        public T GetResponse <T>(params int[] poss) where T : ResponseBase
        {
            for (int i = 0; i < poss.Length; i++)
            {
                poss[i]--;
            }
            var i8583 = new I8583(_i8583.MessageType);

            i8583.settabx_data(11, DateTime.Now.ToString("HHmmss"));
            i8583.settabx_data(12, DateTime.Now.ToString("MMdd"));
            i8583.settabx_data(31, "00");
            i8583.settabx_data(43, "0001");
            _i8583.CopyTo(i8583, poss);


            ResponseBase response = (ResponseBase)Activator.CreateInstance(typeof(T));

            response.Context = Context;
            response.I8583   = i8583;
            return((T)response);
        }
Beispiel #6
0
        public static IRequest Create(byte[] bytes, I8638Context context)
        {
            var i8583 = new I8583(I8583.GetMessageType(bytes));

            Logger.Debug("长度匹配......");
            i8583.UnPack8583(bytes);
            Logger.Debug("解析协议完成");
            switch (i8583.MessageType)
            {
            case "0800":
                return(new SignInRequest(i8583)
                {
                    Context = context
                });

            case "0200":
                return(new DealRequest(i8583, bytes)
                {
                    Context = context
                });

            case "0100":
                return(new PrePayRequest(i8583, bytes)
                {
                    Context = context
                });

            //case "1000":
            //    return new QueryShopRequest(i8583, bytes) { Context = context };
            case "0400":
                return(new DealRequest_(i8583, bytes)
                {
                    Context = context
                });

            default:
                throw new NotSupportedException();
            }
        }
Beispiel #7
0
 public SignInRequest(I8583 i8583)
     : base(i8583)
 {
 }
Beispiel #8
0
 public DealRequest_(I8583 i8583, byte[] data)
     : base(i8583)
 {
     _data = data;
 }
Beispiel #9
0
 public PrePayRequest(I8583 i8583, byte[] data)
     : base(i8583)
 {
     _data = data;
 }
Beispiel #10
0
 public RequestBase(I8583 i8583)
 {
     _i8583 = i8583;
 }