// Methods /// <summary> /// Create all instances needed to perform MicroPos operations, called on form loading. /// </summary> /// <param name="sender">Form loading parameters.</param> /// <param name="e">Loading event arguments.</param> private void Setup(object sender, RoutedEventArgs e) { // Inicializa a plataforma desktop: CrossPlatformUniversalApp.CrossPlatformUniversalAppInitializer.Initialize(); // Constrói as mensagens que serão apresentadas na tela do pinpad: DisplayableMessages pinpadMessages = new DisplayableMessages(); pinpadMessages.ApprovedMessage = ":-)"; pinpadMessages.DeclinedMessage = ":-("; pinpadMessages.InitializationMessage = "Ola"; pinpadMessages.MainLabel = "Stone Pagamentos"; pinpadMessages.ProcessingMessage = "Processando..."; this.approvedTransactions = new Collection <TransactionModel>(); this.authorizers = new Dictionary <string, CardPaymentAuthorizer>(); // Inicializa o autorizador //this.authorizer = new CardPaymentAuthorizer(this.sak, this.authorizationUri, this.tmsUri, null, pinpadMessages); CardPaymentAuthorizer.GetAllDevices(this.sak, this.authorizationUri, this.tmsUri, pinpadMessages).ToList() .ForEach(x => this.authorizers.Add(x.PinpadController.Infos.ManufacturerName + x.PinpadController.Infos.Model, x)); this.authorizer = this.authorizers.FirstOrDefault().Value; Debug.WriteLine("Command OPN"); this.authorizer.OnStateChanged += this.OnTransactionStateChange; this.uxBtnCancelTransaction.IsEnabled = false; this.uxCbbxPinpads.ItemsSource = this.authorizers.Keys; this.uxCbbxPinpads.SelectedValue = this.authorizer.PinpadController.Infos.ManufacturerName + this.authorizer.PinpadController.Infos.Model; }
/// <summary> /// Creates all pinpad messages. /// Establishes connection with the pinpad. /// </summary> public PizzaAuthorizer() { this.BoughtPizzas = new Collection <TransactionModel>(); // Creates all pinpad messages: this.PizzaMachineMessages = new DisplayableMessages(); this.PizzaMachineMessages.ApprovedMessage = "Aprovado, nham!"; this.PizzaMachineMessages.DeclinedMessage = "Nao autorizada"; this.PizzaMachineMessages.InitializationMessage = "olá..."; this.PizzaMachineMessages.MainLabel = "pizza machine"; this.PizzaMachineMessages.ProcessingMessage = "assando pizza..."; // Establishes connection with the pinpad. CrossPlatformUniversalApp.CrossPlatformUniversalAppInitializer.Initialize(); this.authorizer = new CardPaymentAuthorizer(this.SaleAffiliationKey, this.AuthorizationUri, this.ManagementUri, null, this.PizzaMachineMessages); // Attach event to read all transaction status: this.authorizer.OnStateChanged += this.OnStatusChange; }