Collaboration diagram for C# Smart Card Manager API:
Modules | |
Objects | |
Enumerations | |
Events related with Smart Card, devices, readers and cards | |
Classes | |
class | EmvCard |
class | MifareClassicCard |
class | MifareDesfireCard |
class | MifareUltralightCard |
class | SamCard |
class | SmartCard |
class | ScmManager |
Implementation for IScmManager. Start point for interact with Smart Card Manager More... | |
interface | IEmvCard |
Emv card to be used for payments More... | |
interface | IMifareClassicCard |
MifareClassic card More... | |
interface | IMifareDesfireCard |
MifareDesfire card More... | |
interface | IMifareUltraligthCard |
MifareClassic card More... | |
interface | ISamCard |
SAM card More... | |
interface | ISmartCard |
interface | ISmartCardDevice |
Smart card device More... | |
interface | ISmartCardReader |
Smart Card Reader More... | |
Detailed Description
To work with Deepsy Smart Card Manager (SCM) service it is necessary to use ScmManager located in GMV.ITS.HAL.DEEPSY.Scm.Facade for getting the initial ScmManager object.
ScmManager scmManager = new ScmManager("");
ScmManager has an optional parameter indicating the ip address of remote service. For instance:
ScmManager scmManager = new ScmManager("172.22.198.103");
ScmManager implements IDisposable. It can hold resources (such as socket handles) until it is disposed. The Dispose method is automatically called when existing a using or try / catch block, for which the object has been declared. This construction ensures prompt release, avoiding resource exhaustion exceptions and errors that may otherwise occur.
- * ScmManager scmManager= null;try{scmManager = new ScmManager("172.22.198.103");IList<ISmartCardDevice> devicesList = scmManager.Devices;} catch (Exception e) {throw e;}
Examples
-
Getting available smart card devices, readers and cards
using System;using System.Collections.Generic;namespace GMV.ITS.HAL.DEEPSY.Examples.Scm{class GettingAvailableScmApp{static void Main(string[] args){string ip = "192.168.0.144";using (ScmManager smartCardManager = new ScmManager(ip)){IList<ISmartCardDevice> deviceList = smartCardManager.Devices;foreach(ISmartCardDevice device in deviceList){Console.WriteLine($" - {device.Id}");IList<ISmartCardReader> readerList = device.Readers;foreach(ISmartCardReader reader in readerList){Console.WriteLine($" |- {reader.Id}");IList<ISmartCard> cardList = reader.SmartCards;foreach(ISmartCard card in cardList){Console.WriteLine($" |- {card.Uid}");}}}}}}}
-
Remove, set and get MifareClassic keys
using System;using System.Collections.Generic;namespace GMV.ITS.HAL.DEEPSY.Examples.Scm{class MifareClassicApp{static void Main(string[] args){string ip = "192.168.0.144";using (ScmManager smartCardManager = new ScmManager(ip)){IList<ISmartCardDevice> deviceList = smartCardManager.Devices;foreach (ISmartCardDevice device in deviceList){device.ClearMifareClassicKeys();IList<IMifareClassicKeyGroup> keyGroupList = new List<IMifareClassicKeyGroup>();IList<IMifareClassicKey> keyList = new List<IMifareClassicKey>();for(int i = 0; i < 4; i++){keyList.Add(new MifareClassicKey(){Index = i,Key = "FFFFFFFFFFFF",});}keyGroupList.Add(new MifareClassicKeyGroup(){Priority =1,Keys = keyList});device.AddMifareClassicKeys(keyGroupList);IList<IMifareClassicKeyGroup> keyGroupList2 = device.MifareClassicKeys;foreach (IMifareClassicKeyGroup keygroup in keyGroupList2){Console.WriteLine($"Key group with priority {keygroup.Priority}");foreach (IMifareClassicKey key in keygroup.Keys){Console.WriteLine($"Index {key.Index} type {key.Type.ToString()} key {key.Key}");}}}}}}}
-
Subscribe to smart card events
using System;using System.Collections.Generic;namespace GMV.ITS.HAL.DEEPSY.Examples.Scm{class SubscribeScmApp{static void Main(string[] args){string ip = "192.168.0.144";using (ScmManager smartCardManager = new ScmManager(ip)){IList<ISmartCardDevice> deviceList = smartCardManager.Devices;foreach (ISmartCardDevice device in deviceList){Console.WriteLine($" - {device.Id}");IList<ISmartCardReader> readersList = device.Readers;foreach (ISmartCardReader reader in readersList){reader.CardEvent += Reader_CardEvent;}}Console.WriteLine("Press ESC for exit.");ConsoleKey key = Console.ReadKey().Key;while (key != ConsoleKey.Escape){key = Console.ReadKey().Key;}}}private static void Reader_CardEvent(object sender, ICardEvent e){Console.WriteLine($"{e.Action} card with id {e.SmartCard.Uid}");}}}
-
Detect and read smart card
using System;using System.Collections.Generic;namespace GMV.ITS.HAL.DEEPSY.Examples.Scm{class DetectSmartCardApp{static void Main(string[] args){string ip = "192.168.0.144";using (ScmManager smartCardManager = new ScmManager(ip)){IList<ISmartCardDevice> deviceList = smartCardManager.Devices;foreach (ISmartCardDevice device in deviceList){Console.WriteLine($" - {device.Id}");IList<ISmartCardReader> readersList = device.Readers;foreach (ISmartCardReader reader in readersList){reader.CardEvent += Reader_CardEvent; ;}}Console.WriteLine("Press ESC for exit.");ConsoleKey key = Console.ReadKey().Key;while (key != ConsoleKey.Escape){key = Console.ReadKey().Key;}}}private static void Reader_CardEvent(object sender, ICardEvent e){Console.WriteLine($"{e.Action} card with id {e.SmartCard.Uid}");if(e.Action == SmartCardAction.Action.ADDED){IList<ISmartCardInformationBlock> blockList = new List<ISmartCardInformationBlock>();ISmartCard smartCard = e.SmartCard;if(smartCard.GetType() == typeof(MifareClassicCard)){MifareClassicCard sm = (MifareClassicCard)e.SmartCard;try{blockList = sm.ReadBlocks(new List<int> { 1,2,3 } );}catch (HalException deepsyEx){Console.WriteLine($"Deepsy error : {deepsyEx.ErrorCode}");}catch (Exception ex){Console.WriteLine($"Error {ex.StackTrace}");}}else if(smartCard.GetType() == typeof(MifareUltralightCard)){MifareUltralightCard sm = (MifareUltralightCard)e.SmartCard;try{blockList = sm.ReadPages(new List<int> { 1, 2, 3 });}catch (HalException deepsyEx){Console.WriteLine($"Deepsy error : {deepsyEx.ErrorCode}");}catch (Exception ex){Console.WriteLine($"Error {ex.StackTrace}");}}Console.WriteLine("Card content:");foreach (ISmartCardInformationBlock block in blockList){Console.WriteLine(block.Content);}Console.WriteLine("-------------");}}}}
-
Detect and read smart card with specific priority in Mifare Classic (optimization)
using System;using System.Collections.Generic;namespace GMV.ITS.HAL.DEEPSY.Examples.Scm{class DetectMifareClassicApp{static void Main(string[] args){string ip = "192.168.0.144";using (ScmManager smartCardManager = new ScmManager(ip)){IList<ISmartCardDevice> deviceList = smartCardManager.Devices;foreach (ISmartCardDevice device in deviceList){Console.WriteLine($" - {device.Id}");IList<ISmartCardReader> readersList = device.Readers;foreach (ISmartCardReader reader in readersList){reader.CardEvent += Reader_CardEvent; ;}}Console.WriteLine("Press ESC for exit.");ConsoleKey key = Console.ReadKey().Key;while (key != ConsoleKey.Escape){key = Console.ReadKey().Key;}}}private static void Reader_CardEvent(object sender, ICardEvent e){Console.WriteLine($"{e.Action} card with id {e.SmartCard.Uid}");if(e.Action == SmartCardAction.Action.ADDED){IList<ISmartCardInformationBlock> blockList = new List<ISmartCardInformationBlock>();ISmartCard smartCard = e.SmartCard;if(smartCard.GetType() == typeof(MifareClassicCard)){MifareClassicCard sm = (MifareClassicCard)e.SmartCard;try{var blocksId = new List<IDictionary<int, int>>();blocksId.Add(new Dictionary<int, int>() { { 1, 2 } });blocksId.Add(new Dictionary<int, int>() { { 2, 2 } });blocksId.Add(new Dictionary<int, int>() { { 3, 2 } });blockList = sm.ReadBlocksForcePriority(blocksId);}catch (HalException deepsyEx){Console.WriteLine($"Deepsy error : {deepsyEx.ErrorCode}");}catch (Exception ex){Console.WriteLine($"Error {ex.StackTrace}");}}else if(smartCard.GetType() == typeof(MifareUltralightCard)){MifareUltralightCard sm = (MifareUltralightCard)e.SmartCard;try{blockList = sm.ReadPages(new List<int> { 4, 5, 6 });}catch (HalException deepsyEx){Console.WriteLine($"Deepsy error : {deepsyEx.ErrorCode}");}catch (Exception ex){Console.WriteLine($"Error {ex.StackTrace}");}}Console.WriteLine("Card content:");foreach (ISmartCardInformationBlock block in blockList){Console.WriteLine(block.Content);}Console.WriteLine("-------------");}}}}
-
Add a custom media profile and play the existing media profiles in the devices
using System;using System.Collections.Generic;namespace GMV.ITS.HAL.DEEPSY.Examples.Scm{class MediaProfileScmApp{static void Main(string[] args){string ip = "192.168.0.144";using (ScmManager smartCardManager = new ScmManager(ip)){IList<ISmartCardDevice> deviceList = smartCardManager.Devices;foreach (ISmartCardDevice device in deviceList){device.AddMediaProfiles(new List<ISmartCardDeviceMediaProfile> { CustomMediaProfile() });foreach(ISmartCardDeviceMediaProfile mediaProfile in device.MediaProfiles){Console.WriteLine($"Playing media profile {mediaProfile.Id} for device {device.Id}");device.PlayMediaProfile(mediaProfile.Id);System.Threading.Thread.Sleep(5000);}}Console.WriteLine("Press ESC for exit.");ConsoleKey key = Console.ReadKey().Key;while (key != ConsoleKey.Escape){key = Console.ReadKey().Key;}}}private static ISmartCardDeviceMediaProfile CustomMediaProfile(){IList<ISmartCardDeviceSound> sounds = new List<ISmartCardDeviceSound> {new SmartCardDeviceSound(){DurationMs = 200,ToneHz = 2000},new SmartCardDeviceSound(){DurationMs = 0,ToneHz = 1000},new SmartCardDeviceSound(){DurationMs = 200,ToneHz = 2000}};IList<ISmartCardDeviceLed> firstLedList = new List<ISmartCardDeviceLed>{};IList<ISmartCardDeviceLed> secondLedList = new List<ISmartCardDeviceLed>{};// Add leds with same duration as soundsSmartCardDeviceLedGroupState firstLedGroup = new SmartCardDeviceLedGroupState() { DurationMs = 200, Leds = firstLedList };SmartCardDeviceLedGroupState secondLedGroup = new SmartCardDeviceLedGroupState() { DurationMs = 200, Leds = secondLedList };SmartCardDeviceLedGroupState thirdLedGroup = new SmartCardDeviceLedGroupState() { DurationMs = 200, Leds = firstLedList};SmartCardDeviceMediaProfile customProfile = new SmartCardDeviceMediaProfile(){Id = "Custom_media_profile",LedStates = new List<ISmartCardDeviceLedGroupState> { firstLedGroup , secondLedGroup, thirdLedGroup},Sounds = sounds};return customProfile;}}}
-
Retrieve PCI reboot time and set a new PCI reboot time while listening to reboot notifications
using System;using System.Collections.Generic;namespace GMV.ITS.HAL.DEEPSY.Examples.Scm{class PciRebootScmApp{static void Main(string[] args){string ip = "192.168.0.144";using (ScmManager smartCardManager = new ScmManager(ip)){IList<ISmartCardDevice> deviceList = smartCardManager.Devices;foreach (ISmartCardDevice device in deviceList){device.PciRebootTimeEvent += Device_PciRebootTimeEvent;DateTime currentRebootTime = device.PciRebootTime();Console.WriteLine($"Current reboot time for device {device.Id} is {currentRebootTime}");DateTime newRebootTime = DateTime.UtcNow.Date;newRebootTime = newRebootTime.AddHours(3);Console.WriteLine($"Setting reboot time for device {device.Id} for 3:00 am UTC time {newRebootTime}");device.SetPciRebootTime(newRebootTime);DateTime stablishedRebootTime = device.PciRebootTime();Console.WriteLine($"New reboot time for device {device.Id} is {stablishedRebootTime}");}Console.WriteLine("Press ESC for exit.");ConsoleKey key = Console.ReadKey().Key;while (key != ConsoleKey.Escape){key = Console.ReadKey().Key;}}}private static void Device_PciRebootTimeEvent(object sender, ISmartCardDeviceRebootEvent e){Console.WriteLine($"Pci Reboot Time event Device {e.Device.Id} new Datetime {e.DateTime}");}}}
-
Set and get Payment App Configuration
using System;using System.Collections.Generic;namespace GMV.ITS.HAL.DEEPSY.Examples.Scm{class PaymentConfigurationScmApp{static void Main(string[] args){string ip = "192.168.0.144";using (ScmManager smartCardManager = new ScmManager(ip)){IList<ISmartCardDevice> deviceList = smartCardManager.Devices;foreach(ISmartCardDevice device in deviceList){Console.WriteLine($" - {device.Id}");SetPaymentConf(device);ShowPaymentAppConf(device);}Console.WriteLine("Press ESC for exit.");ConsoleKey key = Console.ReadKey().Key;while (key != ConsoleKey.Escape){key = Console.ReadKey().Key;}}}private static IList<ISmartCardPaymentAppConfiguration> Configurations(){IList<ISmartCardPaymentAppConfiguration> configurations = new List<ISmartCardPaymentAppConfiguration>();configurations.Add(new SmartCardPaymentAppConfiguration() { Property = Property.Prop.ACCESS_POINT_CODE, Value = "3" });configurations.Add(new SmartCardPaymentAppConfiguration() { Property = Property.Prop.ACCESS_POINT_TYPE, Value = "ENT" });configurations.Add(new SmartCardPaymentAppConfiguration() { Property = Property.Prop.TRANSPORT_OPERATOR_ID, Value = "000201" });configurations.Add(new SmartCardPaymentAppConfiguration() { Property = Property.Prop.PRICING_PLAN, Value = "101" });configurations.Add(new SmartCardPaymentAppConfiguration() { Property = Property.Prop.ONLINE_MODE, Value = "0" });configurations.Add(new SmartCardPaymentAppConfiguration() { Property = Property.Prop.OFFLINE_MODE, Value = "1" });configurations.Add(new SmartCardPaymentAppConfiguration() { Property = Property.Prop.OFFLINE_BACKUP, Value = "0" });configurations.Add(new SmartCardPaymentAppConfiguration() { Property = Property.Prop.PRICE, Value = "0000000001" });configurations.Add(new SmartCardPaymentAppConfiguration() { Property = Property.Prop.TRANSACTION_MODE_CONF, Value = "432" });configurations.Add(new SmartCardPaymentAppConfiguration() { Property = Property.Prop.END_OF_DAY_TIME, Value = "2359" });configurations.Add(new SmartCardPaymentAppConfiguration() { Property = Property.Prop.BLACKLIST, Value = "01" });configurations.Add(new SmartCardPaymentAppConfiguration() { Property = Property.Prop.BLACK_LIST_UPDATE_TIMER, Value = "30" });configurations.Add(new SmartCardPaymentAppConfiguration() { Property = Property.Prop.BLACK_LIST_UPDATE_RETRIES, Value = "02" });configurations.Add(new SmartCardPaymentAppConfiguration() { Property = Property.Prop.BLACK_LIST_TIME_WITHOUT_UPDATES, Value = "02" });configurations.Add(new SmartCardPaymentAppConfiguration() { Property = Property.Prop.FINANCIAL_BLACK_LIST, Value = "00" });configurations.Add(new SmartCardPaymentAppConfiguration() { Property = Property.Prop.WHITE_LIST, Value = "00" });configurations.Add(new SmartCardPaymentAppConfiguration() { Property = Property.Prop.ODA_CARDS, Value = "00" });configurations.Add(new SmartCardPaymentAppConfiguration() { Property = Property.Prop.PASSBACK_TIMER, Value = "02" });configurations.Add(new SmartCardPaymentAppConfiguration() { Property = Property.Prop.PASSBACK_NUMBER, Value = "006" });configurations.Add(new SmartCardPaymentAppConfiguration() { Property = Property.Prop.LANGUAGE, Value = "00" });configurations.Add(new SmartCardPaymentAppConfiguration() { Property = Property.Prop.DESTINATION_MODE, Value = "000A" });configurations.Add(new SmartCardPaymentAppConfiguration() { Property = Property.Prop.ROUTE, Value = "ROUTE1" });configurations.Add(new SmartCardPaymentAppConfiguration() { Property = Property.Prop.STOP, Value = "STOP1" });configurations.Add(new SmartCardPaymentAppConfiguration() { Property = Property.Prop.EMPLOYEE_ID, Value = "EMPLOYEEID1" });configurations.Add(new SmartCardPaymentAppConfiguration() { Property = Property.Prop.VEHICLE, Value = "VEHICLE1" });configurations.Add(new SmartCardPaymentAppConfiguration() { Property = Property.Prop.EXTRA, Value = "Extra information" });return configurations;}private static void SetPaymentConf(ISmartCardDevice device){try{IList<ISmartCardPaymentAppConfiguration> configurations = Configurations();device.SetPaymentAppConf(configurations);Console.WriteLine($" setPaymentAppConf correct {device.Id}");}catch (HalException deepsyEx){Console.WriteLine($"Deepsy error : {deepsyEx.ErrorCode}");}catch (Exception e){Console.WriteLine($" setPaymentAppConf incorrect {device.Id}");Console.WriteLine($"{e.StackTrace}");}}private static void ShowPaymentAppConf(ISmartCardDevice device){try{IList<ISmartCardPaymentAppConfiguration> configurations = Configurations();IList<ISmartCardPaymentAppConfiguration> configurations_response = device.PaymentAppConf(configurations);foreach (ISmartCardPaymentAppConfiguration configuration in configurations_response){Console.WriteLine($"configuration property: {configuration.Property}");Console.WriteLine($"configuration property: {configuration.Value}");}}catch (HalException deepsyEx){Console.WriteLine($"Deepsy error : {deepsyEx.ErrorCode}");}catch (Exception e){Console.WriteLine($"{e.StackTrace}");}}}}
-
Set and Get device network configuration
using System;using System.Collections.Generic;namespace GMV.ITS.HAL.DEEPSY.Examples.Scm{class NetworkConfigurationScmApp{static void Main(string[] args){string ip = "192.168.0.144";SmartCardDeviceNetworkConfiguration network_configuration = new SmartCardDeviceNetworkConfiguration(){NetMask = "255.255.255.0",DnsServer = "8.8.8.8",Gateway = "192.168.0.1",HostName = "Ux410-1",LocalIpAddress = "192.168.0.236",Dhcp = "0"};using (ScmManager smartCardManager = new ScmManager(ip)){IList<ISmartCardDevice> deviceList = smartCardManager.Devices;foreach(ISmartCardDevice device in deviceList){ShowNetworkConfiguration(device);device.SetNetworkConfiguration(network_configuration);}deviceList = smartCardManager.Devices;foreach (ISmartCardDevice device in deviceList){ShowNetworkConfiguration(device);}}}private static void ShowNetworkConfiguration(ISmartCardDevice device){ISmartCardDeviceNetworkConfiguration network_configurration = device.NetworkConfiguration;Console.WriteLine($" {network_configurration}");Console.WriteLine($"LocalIpAddress {network_configurration.LocalIpAddress}");Console.WriteLine($"Netmask: {network_configurration.NetMask}");Console.WriteLine($"Gateway: {network_configurration.Gateway}");Console.WriteLine($"DnsServer: {network_configurration.DnsServer}");Console.WriteLine($"Dhcp: {network_configurration.Dhcp}");Console.WriteLine($"HostName: {network_configurration.HostName}");}}}
-
Get device version
using System;using System.Collections.Generic;namespace GMV.ITS.HAL.DEEPSY.Examples.Scm{class DeviceVersionScmApp{static void Main(string[] args){string ip = "192.168.0.144";using (ScmManager smartCardManager = new ScmManager(ip)){IList<ISmartCardDevice> deviceList = smartCardManager.Devices;foreach (ISmartCardDevice device in deviceList){ISmartCardDeviceVersion deviceVersion = device.Version;Console.WriteLine($" ADK Version - {deviceVersion.AdkVersion}");Console.WriteLine($" SDK Version - {deviceVersion.SdkVersion}");Console.WriteLine($" serial Number - {deviceVersion.SerialNumber}");Console.WriteLine($" OS Version - {deviceVersion.OsVersion}");Console.WriteLine($" APP Version - {deviceVersion.AppVersion}");Console.WriteLine($" Payment APP Version - {deviceVersion.PaymentAppVersion}");}}}}}
-
APDU Exchange
using System;using System.Collections.Generic;namespace GMV.ITS.HAL.DEEPSY.Examples.Scm{class APDUExchangeScmApp{static void Main(string[] args){string ip = "192.168.0.144";using (ScmManager smartCardManager = new ScmManager(ip)){IList<ISmartCardDevice> deviceList = smartCardManager.Devices;foreach (ISmartCardDevice device in deviceList){Console.WriteLine($" - {device.Id}");IList<ISmartCardReader> readersList = device.Readers;foreach (ISmartCardReader reader in readersList){reader.CardEvent += Reader_CardEvent; ;}}Console.WriteLine("Press ESC for exit.");ConsoleKey key = Console.ReadKey().Key;while (key != ConsoleKey.Escape){key = Console.ReadKey().Key;}}}private static void Reader_CardEvent(object sender, ICardEvent e){Console.WriteLine($"{e.Action} card with id {e.SmartCard.Uid}");if (e.Action == SmartCardAction.Action.ADDED){IList<IAPDUResponse> responses = new List<IAPDUResponse>();ISmartCard smartCard = e.SmartCard;if (smartCard.GetType() == typeof(IMifareDesfireCard)){MifareDesfireCard sm = (MifareDesfireCard)e.SmartCard;try{IList<IAPDUCommand> commands = new List<IAPDUCommand>();commands.Add(new APDUCommand(0x90, 0x60, 0x00, 0x00, "", 0));responses = sm.ApduExchange(commands);}catch (HalException deepsyEx){Console.WriteLine($"Deepsy error : {deepsyEx.ErrorCode}");}catch (Exception ex){Console.WriteLine($"Error {ex.StackTrace}");}}Console.WriteLine("Card content:");foreach (IAPDUResponse response in responses){Console.WriteLine($"{String.Format("%02X", response.Sw1)} : {String.Format("%02X", response.Sw2)} {response.ResponseData}");}Console.WriteLine("-------------");}}}}
-
Passthrough
using System;using System.Collections.Generic;namespace GMV.ITS.HAL.DEEPSY.Examples.Scm{class PassthroughScmApp{static void Main(string[] args){//string ip = "192.168.0.144";string ip = "212.169.153.91";using (ScmManager smartCardManager = new ScmManager(ip)){IList<ISmartCardDevice> deviceList = smartCardManager.Devices;foreach (ISmartCardDevice device in deviceList){Console.WriteLine($" - {device.Id}");IList<ISmartCardReader> readersList = device.Readers;foreach (ISmartCardReader reader in readersList){reader.CardEvent += Reader_CardEvent; ;}}Console.WriteLine("Press ESC for exit.");ConsoleKey key = Console.ReadKey().Key;while (key != ConsoleKey.Escape){key = Console.ReadKey().Key;}}}private static void Reader_CardEvent(object sender, ICardEvent e){Console.WriteLine($"{e.Action} card with id {e.SmartCard.Uid}");if (e.Action == SmartCardAction.Action.ADDED){IList<String> responses = new List<String>();try{responses = e.SmartCard.SendPasstroughCommands(new List<string> { "A50101000000", "3901" });}catch (HalException deepsyEx){Console.WriteLine($"Deepsy error : {deepsyEx.ErrorCode}");}catch (Exception ex){Console.WriteLine($"{ex.StackTrace}");}foreach (string response in responses){Console.WriteLine($"{response}");}Console.WriteLine("-------------");}}}}
-
Emv Transaction
using System;using System.Collections.Generic;namespace GMV.ITS.HAL.DEEPSY.Examples.Scm{class EmvTransactionScmApp{public static int OPERATION_CODE_SUCCESS = 98;public static int OPERATION_CODE_SUCCESS_2 = 95;static void Main(string[] args){string ip = "192.168.0.144";using (ScmManager smartCardManager = new ScmManager(ip)){IList<ISmartCardDevice> deviceList = smartCardManager.Devices;foreach (ISmartCardDevice device in deviceList){Console.WriteLine($" - {device.Id}");EnablePayment(device);ManagePaymentConfiguration(device);IList<ISmartCardReader> readersList = device.Readers;foreach (ISmartCardReader reader in readersList){reader.CardEvent += Reader_CardEvent;reader.ChargeResultEvent += Reader_ChargeResultEvent;}}Console.WriteLine("Press ESC for exit.");ConsoleKey key = Console.ReadKey().Key;while (key != ConsoleKey.Escape){key = Console.ReadKey().Key;}}}private static void Reader_ChargeResultEvent(object sender, ISmartCardReaderEmvEvent e){SolutionCode.Code code = e.SmartCardChargeResult.SolutionCode;if (e.SmartCardChargeResult.ErrorCode == OPERATION_CODE_SUCCESS || e.SmartCardChargeResult.ErrorCode == OPERATION_CODE_SUCCESS_2){try{IEmvCard emvCard = e.EmvCard;// ConfirmCharge(bool abort); true -> abort operationemvCard.ConfirmCharge(false);}catch (HalException deepsyEx){Console.WriteLine($"Deepsy error : {deepsyEx.ErrorCode}");}catch (Exception ex){Console.WriteLine($"{ex.StackTrace}");}}}private static void Reader_CardEvent(object sender, ICardEvent e){Console.WriteLine($"{e.Action} card with id {e.SmartCard.Uid}");if (e.Action == SmartCardAction.Action.ADDED){if (e.SmartCard.GetType() == typeof(EmvCard)) {EmvCard emvCard = (EmvCard)e.SmartCard;try{ISmartCardCharge charge = new SmartCardCharge(){Price = "00000001",TicketMode = DEEPSY.Scm.Interface.Dto.TicketMode.Mode.DISABLE_TICKET};emvCard.RequestCharge(charge);}catch (HalException deepsyEx){Console.WriteLine($"Deepsy error : {deepsyEx.ErrorCode}");}catch (Exception ex){Console.WriteLine($"{ex.StackTrace}");}}}}private static void EnablePayment(ISmartCardDevice device){ISmartCardPaymentAppStatus smartCardPaymentAppStatus = new SmartCardPaymentAppStatus(){WorkMode = SmartCardPaymentWorkMode.WorkMode.GW_DISABLE,};try{device.SetPaymentAppStatus(smartCardPaymentAppStatus);}catch (HalException deepsyEx){Console.WriteLine($"Deepsy error : {deepsyEx.ErrorCode}");}catch (Exception ex){Console.WriteLine($"{ex.StackTrace}");}try{ISmartCardPaymentAppInformation smartCardPaymentAppInformation = device.PaymentAppInfo;Console.WriteLine($"Payment application status:");Console.WriteLine($" - Workmode: {smartCardPaymentAppInformation.WorkMode}");Console.WriteLine($" - FunctionalityIndicator: {smartCardPaymentAppInformation.FunctionalityIndicator}");Console.WriteLine($" - ProtocolVersion: {smartCardPaymentAppInformation.ProtocolVersion}");Console.WriteLine($" - Timestamp: {smartCardPaymentAppInformation.TimeStamp}");}catch (HalException deepsyEx){Console.WriteLine($"Deepsy error : {deepsyEx.ErrorCode}");}catch (Exception ex){Console.WriteLine($"{ex.StackTrace}");}}private static void ManagePaymentConfiguration(ISmartCardDevice device){IList<ISmartCardPaymentAppConfiguration> configurations = new List<ISmartCardPaymentAppConfiguration>();configurations.Add(new SmartCardPaymentAppConfiguration() { Property = Property.Prop.ACCESS_POINT_CODE, Value = "3" });configurations.Add(new SmartCardPaymentAppConfiguration() { Property = Property.Prop.ACCESS_POINT_TYPE, Value = "ENT" });configurations.Add(new SmartCardPaymentAppConfiguration() { Property = Property.Prop.TRANSPORT_OPERATOR_ID, Value = "000201" });configurations.Add(new SmartCardPaymentAppConfiguration() { Property = Property.Prop.PRICING_PLAN, Value = "101" });configurations.Add(new SmartCardPaymentAppConfiguration() { Property = Property.Prop.ONLINE_MODE, Value = "0" });configurations.Add(new SmartCardPaymentAppConfiguration() { Property = Property.Prop.OFFLINE_MODE, Value = "1" });configurations.Add(new SmartCardPaymentAppConfiguration() { Property = Property.Prop.OFFLINE_BACKUP, Value = "0" });configurations.Add(new SmartCardPaymentAppConfiguration() { Property = Property.Prop.PRICE, Value = "0000000001" });configurations.Add(new SmartCardPaymentAppConfiguration() { Property = Property.Prop.TRANSACTION_MODE_CONF, Value = "432" });configurations.Add(new SmartCardPaymentAppConfiguration() { Property = Property.Prop.END_OF_DAY_TIME, Value = "2359" });configurations.Add(new SmartCardPaymentAppConfiguration() { Property = Property.Prop.BLACKLIST, Value = "01" });configurations.Add(new SmartCardPaymentAppConfiguration() { Property = Property.Prop.BLACK_LIST_UPDATE_TIMER, Value = "30" });configurations.Add(new SmartCardPaymentAppConfiguration() { Property = Property.Prop.BLACK_LIST_UPDATE_RETRIES, Value = "02" });configurations.Add(new SmartCardPaymentAppConfiguration() { Property = Property.Prop.BLACK_LIST_TIME_WITHOUT_UPDATES, Value = "02" });configurations.Add(new SmartCardPaymentAppConfiguration() { Property = Property.Prop.FINANCIAL_BLACK_LIST, Value = "00" });configurations.Add(new SmartCardPaymentAppConfiguration() { Property = Property.Prop.WHITE_LIST, Value = "00" });configurations.Add(new SmartCardPaymentAppConfiguration() { Property = Property.Prop.ODA_CARDS, Value = "00" });configurations.Add(new SmartCardPaymentAppConfiguration() { Property = Property.Prop.PASSBACK_TIMER, Value = "02" });configurations.Add(new SmartCardPaymentAppConfiguration() { Property = Property.Prop.PASSBACK_NUMBER, Value = "006" });configurations.Add(new SmartCardPaymentAppConfiguration() { Property = Property.Prop.LANGUAGE, Value = "00" });configurations.Add(new SmartCardPaymentAppConfiguration() { Property = Property.Prop.DESTINATION_MODE, Value = "000A" });configurations.Add(new SmartCardPaymentAppConfiguration() { Property = Property.Prop.ROUTE, Value = "ROUTE1" });configurations.Add(new SmartCardPaymentAppConfiguration() { Property = Property.Prop.STOP, Value = "STOP1" });configurations.Add(new SmartCardPaymentAppConfiguration() { Property = Property.Prop.EMPLOYEE_ID, Value = "EMPLOYEEID1" });configurations.Add(new SmartCardPaymentAppConfiguration() { Property = Property.Prop.VEHICLE, Value = "VEHICLE1" });configurations.Add(new SmartCardPaymentAppConfiguration() { Property = Property.Prop.EXTRA, Value = "Extra information" });IList<ISmartCardPaymentAppConfiguration> configurations_response = device.PaymentAppConf(configurations);foreach (ISmartCardPaymentAppConfiguration configuration in configurations_response){Console.WriteLine($"configuration property: {configuration.Property}");Console.WriteLine($"configuration property: {configuration.Value}");}}}}