Example #1
0
        public void Construct(string sql_conn_string)
        {
            mBillsDatabase  database = new mBillsDatabase(sql_conn_string);
            MBillsAPIFacade api      = new MBillsAPIFacade();

            state = new flows.EntrypointState(api, database, this);
        }
Example #2
0
 public EntrypointState(MBillsAPIFacade api, mBillsDatabase database, OnlinePaymentFlow flow)
 {
     this.api            = api;
     this.database       = database;
     current_transaction = null;
     this.flow           = flow;
     LoadLastTransaction(flow);
 }
Example #3
0
        static void ApiWrapperTest()
        {
            // authenticate to the API
            MBillsAPIFacade api      = new MBillsAPIFacade();
            SAuthResponse   response = api.testConnection();

            Console.WriteLine("Response transaction ID: {0}", response.transactionId);

            // upload bill and POS sale
            string docid = api.UploadDocument(File.ReadAllText(GAppSettings.Get("RESOURCES_DIRECTORY") + @"\bill.xml"));

            int amount = 100;

            // start a sale
            SSaleResponse resp = api.Sale(100, docid);

            Console.WriteLine(JsonConvert.SerializeObject(resp));

            // qr code
            api.getQRCode(resp.paymenttokennumber.ToString(), "temp.jpg");

            while (true)
            {
                ETransactionStatus status = api.GetTransactionStatus(resp.transactionid);

                if (status == ETransactionStatus.Authorized)
                {
                    Console.WriteLine("");
                    //status = api.Capture(resp.transactionid, amount, "Thank you for shopping with us!");
                    status = api.Void(resp.transactionid, "Sorry, but you stink so we won't do business with you!");
                }
                if (status == ETransactionStatus.Paid)
                {
                    break;
                }
                if (status == ETransactionStatus.Voided)
                {
                    break;
                }


                Thread.Sleep(3000);
            }

            Console.ReadLine();
        }