Exemple #1
0
        public CardTerminalClient(ICardTerminalApi cardTerminalApi, ushort portNumber = 1, ushort terminalID = 1)
        {
            this.cardTerminalApi = cardTerminalApi;
            this.portNumber      = portNumber;
            this.terminalID      = terminalID;

            CtReturnCode returnCode = (CtReturnCode)this.cardTerminalApi.Init(this.terminalID, this.portNumber);

            if (returnCode != CtReturnCode.OK)
            {
                throw new Exception(returnCode.ToString());
            }
        }
Exemple #2
0
        public byte[] ExecuteCommand(Command command)
        {
            ushort responseLength = ushort.MaxValue;

            byte[] response = new byte[responseLength];

            byte sourceAddress      = 2;
            byte destinationAddress = command.DestinationAddress;

            byte[] bytecode = command.Bytecode;

            CtReturnCode returnCode = (CtReturnCode)this.cardTerminalApi.Data(this.terminalID, ref destinationAddress, ref sourceAddress, (ushort)bytecode.Length, ref bytecode[0], ref responseLength, ref response[0]);

            if (returnCode == CtReturnCode.OK)
            {
                byte[] result = new byte[responseLength];
                Array.Copy(response, result, responseLength);
                return(result);
            }
            else
            {
                throw new Exception(returnCode.ToString());
            }
        }