コード例 #1
0
        private bool ONLine()
        {
            Thread t = new Thread(() =>
            {
                try
                {
                    //--------------
                    // create/read configuration from a configuration file
                    PayConfiguration config = createConfigFromFile(mPfad);

                    // start a new session
                    PaySession session = new PaySession();

                    // we define a message listener for events (optional)
                    MyMessageListener msgList = new MyMessageListener(lbl_Status, btn_OK);

                    session.setListener(msgList);

                    if (!session.isLoggedIn())
                    {
                        // login (this is always the first communication to the EFT)
                        mTerminal = session.login(config);
                    }


                    try
                    {
                        // Now we start a payment of 1 cent

                        // First we create the result object PayMedia
                        PayMedia media = new PayMedia();

                        // Then we start the authorisation of the card

                        short payType = PayTerminal.__Fields.PAY_TYPE_AUTOMATIC;
                        PayTransaction transaction = mTerminal.payment(mBetrag, payType, media);

                        // When we are here, the given card was accepted. We commit the transaction.
                        // If transaction is null, the device doesn't support commit and we are finished.
                        if (transaction != null)
                        {
                            transaction.commit(media);
                        }
                    }
                    finally
                    {
                    }
                }
                catch (PayException x)
                {
                    // catch all PayExceptions and write to console
                    Console.WriteLine(x.toString());
                }
            });

            t.Start();
            return(true);
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: cbaumgartner/WTMzvt
        static void Main(string[] args)
        {
            try
            {
                // create/read configuration from a configuration file
                PayConfiguration config = createConfigFromFile("../../etc/zvt.cfg");

                // start a new session
                PaySession session = new PaySession();

                // we define a message listener for events (optional)
                session.setListener(new MyMessageListener());

                // get the software version of LUIS ePayment
                Console.WriteLine("Version=" + session.getVersion());

                // login (this is always the first communication to the EFT)
                PayTerminal terminal = session.login(config);

                try
                {
                    // let's have a look at the settings within the EFT
                    PayResult result = terminal.settings();
                    Console.WriteLine(result.toString());

                    // do some selftest
                    result = terminal.selftest();
                    Console.WriteLine(result.toString());


                    // try to connect the network provider and get the limits for a payment
                    result = terminal.diagnose(PayTerminal.__Fields.DIAGNOSE_EXTENDED);
                    Console.WriteLine(result.toString());


                    // Now we start a payment of 1 cent

                    // First we create the result object PayMedia
                    PayMedia media = new PayMedia();

                    // Then we start the authorisation of the card
                    int            cents       = 1;
                    short          payType     = PayTerminal.__Fields.PAY_TYPE_AUTOMATIC;
                    PayTransaction transaction = terminal.payment(cents, payType, media);
                    Console.WriteLine(media.toString());

                    // When we are here, the given card was accepted. We commit the transaction.
                    // If transaction is null, the device doesn't support commit and we are finished.
                    if (transaction != null)
                    {
                        transaction.commit(media);
                        Console.WriteLine(media.toString());
                    }
                }
                finally
                {
                    // logout at last
                    session.logout();
                }
            }
            catch (PayException x)
            {
                // catch all PayExceptions and write to console
                Console.WriteLine(x.toString());
            }
        }