/// <summary> /// Performs the logon transaction. /// </summary> /// <exception cref="System.Exception">Error during logon transaction. Response Code [{response.ResponseCode}] Response Message [{response.ResponseMessage}]</exception> /// <exception cref="Exception">Error during logon transaction</exception> private async Task PerformLogonTransaction() { this.AnalysisLogger.TrackEvent(DebugInformationEvent.Create("About to Do Logon Transaction")); LogonTransactionRequestMessage logonTransactionRequestMessage = new LogonTransactionRequestMessage { DeviceIdentifier = this.Device.GetDeviceIdentifier(), RequireConfigurationInResponse = false, TransactionDateTime = DateTime.Now, TransactionNumber = "1" // TODO: Need to hold txn number somewhere }; String requestJson = JsonConvert.SerializeObject(logonTransactionRequestMessage); this.AnalysisLogger.TrackEvent(MessageSentToHostEvent.Create(App.Configuration.TransactionProcessorACL, requestJson, DateTime.Now)); LogonTransactionResponseMessage response = await this.TransactionProcessorAclClient.PerformLogonTransaction(App.TokenResponse.AccessToken, logonTransactionRequestMessage, CancellationToken.None); String responseJson = JsonConvert.SerializeObject(response); this.AnalysisLogger.TrackEvent(MessageReceivedFromHostEvent.Create(responseJson, DateTime.Now)); if (response.ResponseCode != "0000") { throw new Exception($"Error during logon transaction. Response Code [{response.ResponseCode}] Response Message [{response.ResponseMessage}]"); } }
/// <summary> /// Starts this instance. /// </summary> public async Task Start() { this.AnalysisLogger.TrackEvent(DebugInformationEvent.Create("In Start")); this.LoginPage.LoginButtonClick += this.LoginPage_LoginButtonClick; this.LoginPage.Init(this.LoginViewModel); Application.Current.MainPage = new NavigationPage((Page)this.LoginPage); }
/// <summary> /// Handles the LoginButtonClick event of the LoginPage control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param> private async void LoginPage_LoginButtonClick(Object sender, EventArgs e) { try { //this.LoginViewModel.EmailAddress = "*****@*****.**"; //this.LoginViewModel.Password = "******"; this.AnalysisLogger.TrackEvent(DebugInformationEvent.Create("About to Get Configuration")); await this.GetConfiguration(); this.AnalysisLogger.TrackEvent(DebugInformationEvent.Create("About to Get Token")); // Attempt to login with the user details TokenResponse tokenResponse = await this.SecurityServiceClient.GetToken(this.LoginViewModel.EmailAddress, this.LoginViewModel.Password, App.Configuration.ClientId, App.Configuration.ClientSecret, CancellationToken.None); this.AnalysisLogger.TrackEvent(DebugInformationEvent.Create($"About to Cache Token {tokenResponse.AccessToken}")); this.AnalysisLogger.SetUserName(this.LoginViewModel.EmailAddress); // Cache the user token App.TokenResponse = tokenResponse; // Do the initial logon transaction await this.PerformLogonTransaction(); this.AnalysisLogger.TrackEvent(DebugInformationEvent.Create("Logon Completed")); // Go to signed in page this.MainPage.Init(); this.MainPage.TransactionsButtonClicked += this.MainPage_TransactionsButtonClicked; this.MainPage.ReportsButtonClicked += this.MainPage_ReportsButtonClicked; this.MainPage.SupportButtonClicked += this.MainPage_SupportButtonClicked; this.MainPage.ProfileButtonClicked += this.MainPage_ProfileButtonClicked; Application.Current.MainPage = new NavigationPage((Page)this.MainPage); } catch (Exception ex) { this.AnalysisLogger.TrackEvent(DebugInformationEvent.Create(ex.Message)); if (ex.InnerException != null) { this.AnalysisLogger.TrackEvent(DebugInformationEvent.Create(ex.InnerException.Message)); } CrossToastPopUp.Current.ShowToastWarning("Incorrect username or password entered, please try again!"); } }
/// <summary> /// Gets the configuration. /// </summary> private async Task GetConfiguration() { // TODO: this may well make a server call of some kind in future.... if (App.Configuration == null) { App.Configuration = new DevelopmentConfiguration(); } this.AnalysisLogger.TrackEvent(DebugInformationEvent.Create($"Client Id is {App.Configuration.ClientId}")); this.AnalysisLogger.TrackEvent(DebugInformationEvent.Create($"Client Secret is {App.Configuration.ClientSecret}")); this.AnalysisLogger.TrackEvent(DebugInformationEvent.Create($"SecurityService Url is {App.Configuration.SecurityService}")); this.AnalysisLogger.TrackEvent(DebugInformationEvent.Create($"TransactionProcessorACL Url is {App.Configuration.TransactionProcessorACL}")); }
/// <summary> /// Handles the PerformTopupButtonClicked event of the MobileTopupPerformTopupPage control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param> private async void MobileTopupPerformTopupPage_PerformTopupButtonClicked(Object sender, EventArgs e) { Boolean mobileTopupResult = await this.PerformMobileTopup(); this.AnalysisLogger.TrackEvent(DebugInformationEvent.Create($"Mobile Topup Result is [{mobileTopupResult}]")); if (mobileTopupResult) { this.MobileTopupPaymentSuccessPage.Init(); this.MobileTopupPaymentSuccessPage.CompleteButtonClicked += this.MobileTopupPaymentSuccessPage_CompleteButtonClicked; await Application.Current.MainPage.Navigation.PushAsync((Page)this.MobileTopupPaymentSuccessPage); } else { this.MobileTopupPaymentFailedPage.Init(); this.MobileTopupPaymentFailedPage.CancelButtonClicked += this.MobileTopupPaymentFailedPage_CancelButtonClicked; await Application.Current.MainPage.Navigation.PushAsync((Page)this.MobileTopupPaymentFailedPage); } }