public async Task Test_GetTransactionDetailsById() { // Initialize Xente class XentePayment xenteGateWay = TestHelper.InitializeXenteGateWay(); // Create the transaction credentials TransactionRequest transactionRequest = new TransactionRequest { PaymentProvider = "MTNMOBILEMONEYUG", Amount = "800", Message = "Loan payment", CustomerId = "256778418592", CustomerPhone = "256778418592", CustomerEmail = "*****@*****.**", CustomerReference = "256778418592", BatchId = "Batch001", RequestId = DateTime.Now.ToString(), Metadata = "extra information about transaction" }; try { TransactionProcessingResponse transactionProcessingResponse = await xenteGateWay.Transactions.CreateTransaction(transactionRequest); Assert.IsNotNull(transactionProcessingResponse.Message); } catch (Exception ex) { Console.WriteLine(ex.Message); } }
public async Task Test_GetPaymentProviders() { // Initialize Xente class XentePayment xenteGateWay = TestHelper.InitializeXenteGateWay(); PaymentProvidersResponse paymentProvidersResponse = await xenteGateWay.PaymentProviders.GetPaymentProviders(); // The length of the payment providers should be greater than zero Assert.IsTrue(paymentProvidersResponse.Data.Collection.Count > 0); }
public async Task Test_GetTransactionDetailsById() { // Initialize Xente class XentePayment xenteGateWay = TestHelper.InitializeXenteGateWay(); // A valid Account ID const string transactionId = "46149FE350254038BC40C7091F9F5AF1-256784378515"; TransactionDetailsResponse transactionDetailsResults = await xenteGateWay.Transactions.GetTransactionDetailsById(transactionId); // The message should exist and not be null Assert.IsNotNull(transactionDetailsResults.Message); }
public async Task Test_GetAccountDetailsById_Method() { // Initialize Xente class XentePayment xenteGateWay = TestHelper.InitializeXenteGateWay(); // A valid Account ID const string accountId = "256784378515"; AccountResponse accountResponse = await xenteGateWay.Accounts.GetAccountDetailsById(accountId); // The message should exist and not be null Assert.IsNotNull(accountResponse.Message); }
public static XentePayment InitializeXenteGateWay() { //Authenication Credentias const string apikey = "6A19EA2A706041A599375CC95FF08809"; const string password = "******"; const Mode mode = Mode.Sandbox; // Initialize the Xente class XentePayment xenteGateWay = new XentePayment(apikey, password, mode); return(xenteGateWay); }
public async Task <IActionResult> CreateTransaction(BuyViewModel model) { //Authenication Credentias string apikey = config["ApiKey"]; string password = config["Password"]; const string mode = "sandbox"; // "live" // Initialize the Xente class XentePayment xenteGateWay = new XentePayment(apikey, password, mode); // Create the transaction request // Decide which payment provider to select string paymentProvider = "MTNMOBILEMONEYUG"; string amount = model.Price; string message = $"Payment for {model.ProductName}"; string customerId = GetCurrentUserAsync().GetAwaiter().GetResult().Id; string customerPhone = model.PhoneNumber; string customerEmail = model.Email; string customerReference = model.PhoneNumber; string batchId = "Batch001"; string requestId = Guid.NewGuid().ToString(); // This is optional parameter string metadata = "extra information about transaction"; try { TransactionProcessingResponse transactionProcessingResponse = await xenteGateWay.Transaction.CreateTransaction( paymentProvider, amount, message, customerId, customerPhone, customerEmail, customerReference, batchId, requestId, metadata ); logger.LogInformation($"Message = {transactionProcessingResponse.Message}"); logger.LogInformation($"Code = {transactionProcessingResponse.Code}"); logger.LogInformation($"CorrelationId = {transactionProcessingResponse.CorrelationId}"); logger.LogInformation($"Data Message = {transactionProcessingResponse.Data.Message}"); logger.LogInformation($"BatchId = {transactionProcessingResponse.Data.BatchId}"); logger.LogInformation($"TransactionId = {transactionProcessingResponse.Data.TransactionId}"); logger.LogInformation($"Created On = {transactionProcessingResponse.Data.CreatedOn}"); logger.LogInformation($"Request ID = {transactionProcessingResponse.Data.RequestId}"); logger.LogInformation("{@TransactionProcesingResponse}", transactionProcessingResponse); return(View("Processing", transactionProcessingResponse)); } catch (Exception ex) { logger.LogError(ex.Message); logger.LogError(ex.StackTrace); return(View("Error", new { Message = ex.Message })); } }