public void DiscoverReaders(StripeDiscoveryConfiguration config, Action <IList <StripeTerminalReader> > readers, Action scanTimeoutCallback)
        {
            // this assures the discovery succeeds on Android. Old code, ignores this, leading to lack of success in finding other types of readers except for Chipper2x
            var deviceType = DeviceType.Chipper2x;

            switch (config.DeviceType)
            {
            case "Chipper2X":
                deviceType = DeviceType.Chipper2x;
                break;

            case "VerifoneP400":
                deviceType = DeviceType.VerifoneP400;
                break;

            case "WisePad3":
                deviceType = DeviceType.Wisepad3;
                break;
            }


            var configuration = new DiscoveryConfiguration(config.TimeOut, deviceType, isSimulated: config.IsSimulated);


            _onReadersDiscoveredAction = readers;
            _discoveryCancelable?.Cancel(new GenericCallback((ex) =>
            {
                // Do Nothing...
            }));
            _discoveryCancelable = StripeTerminal.Instance.DiscoverReaders(configuration, this, new GenericCallback((ex) =>
            {
                // Do Nothing...
                scanTimeoutCallback();
            }));
        }
        public void DiscoverReaders(StripeDiscoveryConfiguration config, Action <IList <StripeTerminalReader> > readers, Action scanTimeoutCallback)
        {
            try
            {
                var deviceType = SCPDeviceType.Chipper2X;
                switch (config.DeviceType)
                {
                case "Chipper2X":
                    deviceType = SCPDeviceType.Chipper2X;
                    break;

                case "VerifoneP400":
                    deviceType = SCPDeviceType.VerifoneP400;
                    break;

                case "WisePad3":
                    deviceType = SCPDeviceType.WisePad3;
                    break;
                }

                var disocveryMethod = SCPDiscoveryMethod.BluetoothScan;
                switch (config.DiscoveyMethod)
                {
                case "BluetoothScan":
                    disocveryMethod = SCPDiscoveryMethod.BluetoothScan;
                    break;

                case "BluetoothProximity":
                    disocveryMethod = SCPDiscoveryMethod.BluetoothProximity;
                    break;

                case "Internet":
                    disocveryMethod = SCPDiscoveryMethod.BluetoothProximity;
                    break;
                }

                var configuration = new SCPDiscoveryConfiguration(deviceType, disocveryMethod, config.IsSimulated)
                {
                    Timeout = (nuint)config.TimeOut,
                };

                _onReadersDiscoveredAction = readers;
                _discoveryCancelable?.Cancel((NSError e) =>
                {
                    // Notify Something
                });
                _discoveryCancelable = SCPTerminal.Shared?.DiscoverReaders(configuration, this, (NSError e) =>
                {
                    // Do Nothing...
                    scanTimeoutCallback?.Invoke();
                });
            }
            catch (Exception e)
            {
                throw e;
            }
        }
示例#3
0
 public void DiscoverReaders(StripeDiscoveryConfiguration config, Action <IList <StripeTerminalReader> > readers, Action scanTimeoutCallback)
 {
     _onReadersDiscoveredAction = readers;
     _discoveryCancelable?.Cancel(new GenericCallback((ex) =>
     {
         // Do Nothing...
     }));
     _discoveryCancelable = StripeTerminal.Instance.DiscoverReaders(new DiscoveryConfiguration(config.TimeOut, DeviceType.Chipper2x, isSimulated: config.IsSimulated), this, new GenericCallback((ex) =>
     {
         // Do Nothing...
         scanTimeoutCallback();
     }));
 }