예제 #1
0
        public Form1()
        {
            InitializeComponent();
            Cursor.Hide();

            if (!GoogleVasLicense.AutoLoad())
            {
                Logger.Info("No Google VAS license file");
            }

            if (!AppleVasLicense.AutoLoad())
            {
                Logger.Info("No Apple VAS license file");
            }

            readerList   = new List <string>();
            googleConfig = GoogleVasConfig.SpringCardDemo();

            const string TestMerchantName = "pass.com.springcard.springblue.generic";
            const string TestKeyPrivate   = "MHcCAQEEICp+PT7K8FQSOi2HED1Ar5RqxxN2EkiKJMCSfaL4htYNoAoGCCqGSM49AwEHoUQDQgAE9RCZaHxXUIjQFQnwKmq6+cVqFBNO6ZKQmekosMQRZmutPs8szUsiLokILdaiT/7F5qUl8qSfEvlocYy6z98jIw==";
            string       json             = $@"{{
                ""P2"" : ""FullVAS"",
                ""Capabilities"": ""SingleMode"",
	            ""Merchants"" : [
		            {{
			            ""Name"" : ""{TestMerchantName}"",
			            ""PrivateKey"" : ""{TestKeyPrivate}"",
			            ""Url"": ""https://springpass.springcard.com""
                    }}
	            ],
	            ""Description"" : ""FullVAS, DualMode, 2 merchant IDs with 2nd matching, merchants have an URL""
            }}";

            appleConfig = AppleVasTerminalConfig.LoadFromJson(json);

            LoadReaders();



            if (readerList.Count > 0)
            {
                string reader = readerList[0];
                Logger.Trace("Starting...");

                resetUiEvent();

                activeReader = new SCardReader(reader);
                activeReader.StartWaitCard(new SCardReader.CardConnectedCallback(CardConnectedCallback), new SCardReader.CardRemovedCallback(CardRemovedCallback));
            }
            else
            {
                ShowResult("No reader found");
            }
        }
예제 #2
0
        static void Main(string[] args)
        {
            SystemConsole.ReadArgs(args);
            Logger.ReadArgs(args);

            string ConfigFileName = null;

            for (int i = 0; i < args.Length; i++)
            {
                if (args[i].StartsWith("-"))
                {
                    continue;
                }
                if (ConfigFileName == null)
                {
                    ConfigFileName = args[i];
                }
            }

            Logger.Info("SpringCard.GoogleVAS library version: {0}", Library.ModuleInfo.LongVersion);

            Application.ThreadException += new ThreadExceptionEventHandler(Application_ThreadException);
            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);

            if (!GoogleVasLicense.AutoLoad())
            {
                Logger.Info("No license file");
            }

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            MainForm f = new MainForm(args);

            if (ConfigFileName != null)
            {
                f.LoadConfigFromFile(ConfigFileName);
            }
            Application.Run(f);
        }
예제 #3
0
        static void Main(string[] args)
        {
            SystemConsole.ReadArgs(args);
            Logger.ReadArgs(args);

            string ConfigFileName = null;

            for (int i = 0; i < args.Length; i++)
            {
                if (args[i].StartsWith("-"))
                {
                    continue;
                }
                if (ConfigFileName == null)
                {
                    ConfigFileName = args[i];
                }
            }

            if (!GoogleVasLicense.AutoLoad())
            {
                Logger.Info("No Google VAS license file");
            }

            if (!AppleVasLicense.AutoLoad())
            {
                Logger.Info("No Apple VAS license file");
            }

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            MainForm f = new MainForm(args);

            /* if (ConfigFileName != null)
             *   f.LoadConfigFromFile(ConfigFileName);*/
            Application.Run(f);
        }
예제 #4
0
        int Run(string[] args)
        {
            if (!ParseArgs(args))
            {
                return(1);
            }

            Logger.Debug("Loading the list of PC/SC readers");

            string[] ReaderNames = (new SCardReaderList()).Readers;

            if (ListReaders)
            {
                Console.WriteLine(string.Format("{0} PC/SC Reader(s) found", ReaderNames.Length));
                for (int i = 0; i < ReaderNames.Length; i++)
                {
                    Console.WriteLine(string.Format("{0}: {1}", i, ReaderNames[i]));
                }
                return(0);
            }


            if (!GoogleVasLicense.AutoLoad())
            {
                Logger.Info("No license file");
            }

            GoogleVasConfig config;

            if (ConfigFileName != null)
            {
                config = GoogleVasConfig.LoadFromJsonFile(ConfigFileName);
            }
            else
            {
                config = GoogleVasConfig.GoogleDemo();
            }

            if (ExportedFileName != null)
            {
                GoogleVasConfig.SaveToSpringCoreConfigFile(config, ExportedFileName);
                Logger.Info("Export done, treminate program");
                return(0);
            }

            if (ReaderName == null)
            {
                if (ReaderIndex < 0)
                {
                    ReaderIndex = 0;
                }

                Logger.Debug("Selecting the PC/SC reader at index {0}", ReaderIndex);

                if ((ReaderIndex >= ReaderNames.Length))
                {
                    Console.WriteLine("No PC/SC Reader at index {0}", ReaderIndex);
                    Console.WriteLine("Use " + ProgName + " --list-readers");
                    return(1);
                }

                ReaderName = ReaderNames[ReaderIndex];
            }

            Logger.Debug("Using PC/SC reader {0}", ReaderName);

            Logger.Debug("Opening the PC/SC reader");

            SCardReader reader = new SCardReader(ReaderName);

            Logger.Debug("Expecting to find a 'smartcard'");

            SCardChannel channel = new SCardChannel(reader);

            if (!channel.CardPresent)
            {
                ConsoleError("No NFC card or smartphone on the reader");
                return(1);
            }

            Logger.Debug("Connecting to the 'smartcard'");

            if (!channel.Connect())
            {
                ConsoleError("Failed to open the communication with the NFC card or smartphone");
                return(1);
            }

            if (!GoogleVasLicense.ReadDeviceId(channel))
            {
                ConsoleError("Not a SpringCard device?");
                return(1);
            }

            if (!GoogleVasLicense.LoadCollectorId(config.CollectorId_4))
            {
                ConsoleError("Wrong Collector ID?");
                return(1);
            }

            GoogleVasError error;

            GoogleVasTerminal terminal = new GoogleVasTerminal(config);

            if (terminal.DoTransaction(channel, out GoogleVasData data, out error))
            {
                Logger.Debug($"Message is OK, transaction done in {terminal.TransactionDuration} ms");
            }