Exemplo n.º 1
0
 /// <summary>
 ///  Closes a connection to the payment terminal.
 /// </summary>
 /// <returns>A task that can be awaited until the connection is closed.</returns>
 public virtual async Task CloseAsync()
 {
     try
     {
         await this.paymentDevice.CloseAsync();
     }
     finally
     {
         this.paymentDevice = null;
         this.executionLock.Dispose();
     }
 }
Exemplo n.º 2
0
            /// <summary>
            /// Construct the Payment Device class and open the connection from it.
            /// </summary>
            /// <param name="peripheralName">Name of peripheral device.</param>
            /// <param name="terminalSettings">The terminal settings for the peripheral device.</param>
            /// <param name="peripheralConfig">Configuration parameters of the peripheral.</param>
            /// <returns>A task that can be awaited until the connection is opened.</returns>
            public virtual async Task OpenAsync(string peripheralName, SettingsInfo terminalSettings, PeripheralConfiguration peripheralConfig)
            {
                this.executionLock = new SemaphoreSlim(1, 1);
                this.paymentDevice = CompositionManager.Instance.GetComponent <IPaymentDevice>(peripheralName);

                if (this.paymentDevice == null)
                {
                    throw new PeripheralException(PeripheralException.PaymentTerminalError, "Payment terminal '{0}' is not available.\n\nPossible issues:\n1. Payment terminal device assembly not installed in DLLHost or IIS Hardware Station bin directory.\n2. Payment terminal device assembly not in hardwareStation->composition of the configuration file in above directory.", peripheralName);
                }

                IDictionary <string, string> peripheralConfigDictionary = new Dictionary <string, string>();

                if (peripheralConfig != null && peripheralConfig.ExtensionProperties != null)
                {
                    peripheralConfigDictionary = peripheralConfig.ExtensionProperties.ToStringDictionary();
                }

                await this.paymentDevice.OpenAsync(peripheralName, terminalSettings, peripheralConfigDictionary);
            }
 public void plugPaymentDevice(IPaymentDevice device)
 {
     Console.WriteLine(this.GetType() + "_" + this.GetHashCode() + ": " + System.Reflection.MethodBase.GetCurrentMethod().Name + "()");
     paymentDevice = device;
     //device.plugToController();
 }
 public TerminalProxy()
 {
     Console.WriteLine(this.GetType() + "_" + this.GetHashCode() + ": " + System.Reflection.MethodBase.GetCurrentMethod().Name + "()");
     terminal = new Terminal();
 }