示例#1
0
        public int ChangeText(string text)
        {
            PP_DISPPARM pp_dispparm = new PP_DISPPARM
            {
                text        = new byte[40 + 1],
                offset      = (byte)0,
                clear_lines = (byte)(1 | 2),
                reserved    = new byte[4],
            };

            byte[] tempB = Encoding.ASCII.GetBytes(text);

            for (int i = 0; i < Math.Min(tempB.Length, 40); i++)
            {
                pp_dispparm.text[i] = tempB[i];
            }
            ;
            pp_dispparm.text[Math.Min(tempB.Length, 40)] = 0;

            // pp_dispparm.text = Encoding.ASCII.GetBytes(text);

            IntPtr pAddressOfFunctionToCall = NativeMethods.GetProcAddress(pDll, "_PinpadDisplay");

            _PinpadDisplay pinpadDisplay = (_PinpadDisplay)Marshal.GetDelegateForFunctionPointer(pAddressOfFunctionToCall,
                                                                                                 typeof(_PinpadDisplay));

            int result = pinpadDisplay(ref pp_dispparm);

            return(result);
        }
示例#2
0
        //public string GetPin(string textDisplay, string cardNo)
        public DeviceReply GetPin(string textDisplay, string cardNo)
        {
            DeviceReply dev         = new DeviceReply();
            PP_DISPPARM pp_dispparm = new PP_DISPPARM
            {
                text        = new byte[40 + 1],
                offset      = (byte)0,
                clear_lines = (byte)(1 | 2),
                reserved    = new byte[4],
            };

            PP_PINPARM pp_pinpadrm = new PP_PINPARM
            {
                mindigits = (byte)6,
                maxdigits = (byte)6,
                timeout   = (byte)30,
                offset    = (byte)20,
                beep      = (byte)1,
                format    = (byte)0,
                keyid     = (byte)2,
                PANdata   = new byte[20],
                reserved  = new byte[4],
            };



            byte[] tempB = Encoding.ASCII.GetBytes(textDisplay);

            for (int i = 0; i < Math.Min(tempB.Length, 40); i++)
            {
                pp_dispparm.text[i] = tempB[i];
            }
            ;
            pp_dispparm.text[Math.Min(tempB.Length, 40)] = 0;

            //card
            byte[] tempC = Encoding.ASCII.GetBytes(cardNo);

            for (int i = 0; i < Math.Min(tempC.Length, 20); i++)
            {
                pp_pinpadrm.PANdata[i] = tempC[i];
            }
            ;
            pp_pinpadrm.PANdata[Math.Min(tempC.Length, 20)] = 0;



            byte[] buffer = new byte[8];


            IntPtr pAddressOfFunctionToCall = NativeMethods.GetProcAddress(pDll, "_PinpadGetPIN");

            _PinpadGetPIN pinpadGetPin = (_PinpadGetPIN)Marshal.GetDelegateForFunctionPointer(pAddressOfFunctionToCall, typeof(_PinpadGetPIN));

            int result = pinpadGetPin(ref pp_dispparm, ref pp_pinpadrm, buffer);

            Console.WriteLine("pin :" + buffer);
            Hashtable errTable = new Hashtable();

            errTable.Add(0, "operation was successful");
            errTable.Add(1, "processing PIN request");
            errTable.Add(2, "invalid field");
            errTable.Add(3, "a parameter value was incorrect");
            errTable.Add(12, "incorrect command or response length");
            errTable.Add(32, "data entry cancelled by user");
            errTable.Add(33, "operation timed out");
            errTable.Add(34, "MSR track read error");
            errTable.Add(87, "pinpad is not responding");
            errTable.Add(89, "comms error occurred");
            errTable.Add(96, "card inserted but no chip detected");
            errTable.Add(97, "transaction no complete");
            errTable.Add(98, "invalid data on chip or no tracks were able to read from the chip");
            errTable.Add(997, "an unknown response rxed from pinpad");
            errTable.Add(998, "bad parameter passed to API");
            string hsl_cvt = toHexa(buffer);
            string err_msg = "";

            if (result == 0)
            {
                err_msg = toHexa(buffer);
            }
            else
            {
                bool checkKey = errTable.ContainsKey(result);
                err_msg = checkKey == true ? errTable[result].ToString() : "";
            }
            dev.Error_code  = result;
            dev.Err_message = err_msg;

            return(dev);
        }
示例#3
0
        //public string SwipeCard(string text)
        public DeviceReply SwipeCard(string text)
        {
            DeviceReply dev         = new DeviceReply();
            PP_DISPPARM pp_dispparm = new PP_DISPPARM
            {
                text        = new byte[40 + 1],
                offset      = (byte)0,
                clear_lines = (byte)(1 | 2),
                reserved    = new byte[4],
            };

            PP_MSR pp_msr = new PP_MSR();

            byte[] tempB = Encoding.ASCII.GetBytes(text);

            for (int i = 0; i < Math.Min(tempB.Length, 40); i++)
            {
                pp_dispparm.text[i] = tempB[i];
            }
            ;
            pp_dispparm.text[Math.Min(tempB.Length, 40)] = 0;

            IntPtr pAddressOfFunctionToCall = NativeMethods.GetProcAddress(pDll, "_PinpadMSRRead");

            _PinpadMSRRead pinpadMSRRead = (_PinpadMSRRead)Marshal.GetDelegateForFunctionPointer(pAddressOfFunctionToCall,
                                                                                                 typeof(_PinpadMSRRead));

            int       result   = pinpadMSRRead((byte)30, ref pp_dispparm, ref pp_msr);
            string    err_msg  = "";
            string    trak2    = Encoding.ASCII.GetString(pp_msr.data2);
            Hashtable errTable = new Hashtable();

            errTable.Add(0, "operation was successful");
            errTable.Add(1, "processing PIN request");
            errTable.Add(2, "invalid field");
            errTable.Add(3, "a parameter value was incorrect");
            errTable.Add(12, "incorrect command or response length");
            errTable.Add(32, "data entry cancelled by user");
            errTable.Add(33, "operation timed out");
            errTable.Add(34, "MSR track read error");
            errTable.Add(87, "pinpad is not responding");
            errTable.Add(89, "comms error occurred");
            errTable.Add(96, "card inserted but no chip detected");
            errTable.Add(97, "transaction no complete");
            errTable.Add(98, "invalid data on chip or no tracks were able to read from the chip");
            errTable.Add(997, "an unknown response rxed from pinpad");
            errTable.Add(998, "bad parameter passed to API");
            if (trak2 != "")
            {
                string cardNo = trak2.Split('=')[0];
                err_msg = cardNo;
            }
            else
            {
                bool checkKey = errTable.ContainsKey(result);

                err_msg = checkKey == true ? errTable[result].ToString() : "";
            }
            dev.Error_code  = result;
            dev.Err_message = err_msg;
            return(dev);
        }