// Get transaction by the by the request Id set by the user public async Task <TransactionDetailsResponse> GetTransactionDetailsByRequestId(string requestId) { TransactionDetailsResponse transactionDetailsResponse = await this.HttpRequestClient.ExecuteTransactionDetailsRequest2(requestId); return(transactionDetailsResponse); }
// Get transaction Details by the their respective Transaction IDs public async Task <TransactionDetailsResponse> ExecuteTransactionDetailsRequest(string transactionId, bool executeWithANewToken = false) { // Check if the token is present in the global variable or when executeWithANewToken is true if (this.BearerToken == null || executeWithANewToken == true) { this.BearerToken = await ExecuteBearerTokenRequest(); } try { // Set the Http Request parameters SetRequestHeaders(); // Make an Http requets to get the transaction details HttpResponseMessage response = await HttpClient.GetAsync($"{this.Constant.BaseUrl}/transactions/{transactionId}"); // Throw an exception in case of any errors response.EnsureSuccessStatusCode(); // Cast the Json response to our custom type TransactionDetailsResponse transactionDetailsResponse = await response.Content.ReadAsAsync <TransactionDetailsResponse>(); return(transactionDetailsResponse); } catch (Exception ex) { if (ex.Message.Contains("401")) { // Repeat the execution but with a new bearer token TransactionDetailsResponse transactionDetailsResultsWithNewToken = await ExecuteTransactionDetailsRequest(transactionId, true); return(transactionDetailsResultsWithNewToken); } else if (ex.Message.Contains("400")) { // Incorrect Transaction ID is provided (400) throw new XenteIncorrectRequestException("Incorrect Transaction ID provided"); } else { throw new XenteConnectionException(ex.Message); } } }