Пример #1
0
        protected override void OnCreate(Bundle bundle)
        {
            try
            {
                base.OnCreate(bundle);
                SetContentView(Resource.Layout.Main);
                SetupViewComponents();

                //Since the only way to connect to a terminal/pinpad from an Android Phone/Tablet is over Bluetooth, we use the BluetoothDeviceConnectionChannel.
                //It has the same implementation as SerialDeviceConnectionChannel(both implement IBCDeviceConnectionChannel) from the console sample but uses only Bluetooth to connect to the device.
                _channel = new BluetoothDeviceConnectionChannel(_deviceAddress);
                //The BCDeviceManager is the same as in the console sample
                _device = new BCDeviceManager(_channel);
                //You can listen to errors form the device only, just wire up this event
                _device.OnError += DeviceManagerOnError;

                //The same platform initialization as in console
                PlatformContext.Initialize(this, _customerId, _appId, _appSecret, _device, PIEnvironment.Dev);

                _progressDialog = ProgressDialog.Show(this, "PI", "Logging in...", true);

                //Login works the same way as console sample
                _token = PlatformContext.GetService<IAuthService>().Login();

                //Wire up the transaction flow events
                _transactionOrchestrator = PlatformContext.GetService<ITransactionOrchestrator>();
                _transactionOrchestrator.OnError += TransactionOrchestratorOnError;
                _transactionOrchestrator.OnProgressChanged += TransactionOrchestratorOnProgressChanged;
                _transactionOrchestrator.OnTransactionFinished += TransactionOrchestratorOnTransactionFinished;
                _transactionOrchestrator.OnDataRequested += TransactionOrchestratorOnDataRequested;
            }
            catch (Exception ex)
            {
                Helpers.Alert(this, "PI - OnCreate - Error", ex.Message, false);
            }
            finally
            {
                if (_progressDialog.IsShowing)
                {
                    _progressDialog.Dismiss();
                }
            }
        }
Пример #2
0
        protected override void OnCreate(Bundle bundle)
        {
            try
            {
                base.OnCreate(bundle);
                SetContentView(Resource.Layout.Main);
                SetupViewComponents();

                //Since the only way to connect to a terminal/pinpad from an Android Phone/Tablet is over Bluetooth, we use the BluetoothDeviceConnectionChannel.
                //It has the same implementation as SerialDeviceConnectionChannel(both implement IBCDeviceConnectionChannel) from the console sample but uses only Bluetooth to connect to the device.
                _channel = new BluetoothDeviceConnectionChannel(_deviceAddress);
                //The BCDeviceManager is the same as in the console sample
                _device = new BCDeviceManager(_channel);
                //You can listen to errors form the device only, just wire up this event
                _device.OnError += DeviceManagerOnError;

                //The same platform initialization as in console
                PlatformContext.Initialize(this, _customerId, _appId, _appSecret, _device, PIEnvironment.Dev);

                _progressDialog = ProgressDialog.Show(this, "PI", "Logging in...", true);

                //Login works the same way as console sample
                _token = PlatformContext.GetService <IAuthService>().Login();

                //Wire up the transaction flow events
                _transactionOrchestrator                        = PlatformContext.GetService <ITransactionOrchestrator>();
                _transactionOrchestrator.OnError               += TransactionOrchestratorOnError;
                _transactionOrchestrator.OnProgressChanged     += TransactionOrchestratorOnProgressChanged;
                _transactionOrchestrator.OnTransactionFinished += TransactionOrchestratorOnTransactionFinished;
                _transactionOrchestrator.OnDataRequested       += TransactionOrchestratorOnDataRequested;
            }
            catch (Exception ex)
            {
                Helpers.Alert(this, "PI - OnCreate - Error", ex.Message, false);
            }
            finally
            {
                if (_progressDialog.IsShowing)
                {
                    _progressDialog.Dismiss();
                }
            }
        }