//async void TokenTxn() //{// Get an auth token // try // { // await RefreshTokenAsync(); // // ShowNotification("TRANSACTION IN PROGRESS", "", "CHECK PIN PAD FOR STATUS", NotificationType.Normal, false); // // // TxnType is required // //string txnType = GetTxnType().ToString(); // string txnType = cboType.Text[0].ToString(); //Hacky thing i'll fix later // // Set ReferenceNumber to something unique // string txnRef = DateTime.Now.ToString("YYMMddHHmmssfff"); // // Set AmountCash for cash out, and AmountPurchase for purchase/refund // int amtPurchase = (txnType == "C") ? 0 : (int)(decimal.Parse(txtAmount.Text) * 100); // int amtCash = (txnType == "C") ? (int)(decimal.Parse(txtAmount.Text) * 100) : 0; // // var requestContent = new { Request = new { txnType, amtPurchase, amtCash, txnRef } }; // var currentSessionId = Guid.NewGuid().ToString(); // // // var request = new HttpRequestMessage(HttpMethod.Post, $"{basePosApiUri}/sessions/{currentSessionId}/transaction?async=false") // { // Content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(requestContent), System.Text.Encoding.UTF8, "application/json") // }; // request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", token); // HttpResponseMessage httpResponse = await client.SendAsync(request); // httpResponse.EnsureSuccessStatusCode(); // // var apiResponse = Newtonsoft.Json.JsonConvert.DeserializeObject<ApiResponse<TransactionResponse>>(await httpResponse.Content.ReadAsStringAsync()); // var r = apiResponse.Response; // // HideDialog(); // // ShowNotification( // $"TRANSACTION {(r.Success ? "OK" : "FAILED")}", // $"{r.ResponseCode} {r.ResponseText}", // "", // r.Success ? NotificationType.Success : NotificationType.Error, // true // ); // } // catch (Exception ex) // { // ShowNotification("TRANSACTION FAILURE", "", ex.Message, NotificationType.Error, true); // } //} async void Window_Loaded(object sender, RoutedEventArgs e) { txtToken.Text = _settings.Token; txtPairingCode.Text = _settings.PairingCode; txtUsername.Text = _settings.Username; txtPassword.Text = _settings.Password; cboEnableCloud.IsChecked = _settings.EnableCloud; txtEFTClientAddress.Text = _settings.EFTClientAddress; // Set up PC-EFTPOS connection _eft = new EFTClientIPAsync(); var connected = false; //If we already have the token, we can do a token auth if (!string.IsNullOrEmpty(_settings?.Token) && _settings.EnableCloud) { connected = await ConnectAsync(); } // Try to connect if we have an address. Either navigate to the main // page (if we are connected) or the settings page (if we aren't) else if (_settings?.EFTClientAddress.Length > 0 && connected == false) { connected = await ConnectAsync(); } if (connected) { NavigateToMainPage(); } else { NavigateToSettingsPage(); } }
async void Window_Loaded(object sender, RoutedEventArgs e) { // Set up PC-EFTPOS connection _eft = new EFTClientIPAsync(); // Try to connect if we have an address. Either navigate to the main // page (if we are connected) or the settings page (if we aren't) var connected = false; if (_settings?.EFTClientAddress.Length > 0) { connected = await ConnectAsync(); } if (connected) { NavigateToMainPage(); } else { NavigateToSettingsPage(); } }