public void SampleCodeCreateUnlinkedCredit() { ApiOperationBase <ANetApiRequest, ANetApiResponse> .MerchantAuthentication = CustomMerchantAuthenticationType; ApiOperationBase <ANetApiRequest, ANetApiResponse> .RunEnvironment = TestEnvironment; decimal txnAmount = SetValidTransactionAmount(Counter) / 100; //Set payment info for credit var creditCard = new creditCardType { cardNumber = "4111111111111111", expirationDate = "0622" }; var paymentType = new paymentType { Item = creditCard }; //Create credit request transactionRequestType txnType = new transactionRequestType { amount = txnAmount, transactionType = transactionTypeEnum.refundTransaction.ToString(), payment = paymentType, }; createTransactionRequest creditReq = new createTransactionRequest { transactionRequest = txnType }; createTransactionController creditCont = new createTransactionController(creditReq); creditCont.Execute(); createTransactionResponse creditResp = creditCont.GetApiResponse(); //validate Assert.AreEqual("1", creditResp.transactionResponse.messages[0].code); }
static void Main(string[] args) { Console.WriteLine("Starting"); var apiLogin = "******"; var tk = "24V9zfbeV6M73b88"; //ChargeCreditCard.Run("3C6M9JggD", "24V9zfbeV6M73b88"); Console.WriteLine("Authorize credit card."); AuthorizeCreditCard.Run(apiLogin, tk, 200); Console.WriteLine("Do a ChasePay Transaction...."); createTransactionResponse response = CreateChasePayTransaction.Run(apiLogin, tk) as createTransactionResponse; var transactionId = response != null? response.transactionResponse.transId: string.Empty; if (!string.IsNullOrEmpty(transactionId)) { Console.WriteLine("Do a Refund Transaction...."); RefundTransaction.Run(apiLogin, tk, 133.45m, transactionId); } Console.WriteLine("Done"); Console.ReadLine(); }
public async Task <IActionResult> Checkout([Bind("Number, ExpDate")] CreditCardViewModel ccvm) { Cart cart = await _cart.GetCartAsync(User.Identity.Name); // Get cart total int amount = 0; foreach (Order o in cart.Orders) { amount += o.ExtPrice; } createTransactionResponse response = _payment.RunCard(amount, ccvm.ExpDate, ccvm.Number); if (response.messages.resultCode == messageTypeEnum.Ok) { await _cart.CloseCartAsync(cart); return(RedirectToAction("Receipt", "Cart", cart)); } else { TempData["paymentResponse"] = response.messages.resultCode; return(RedirectToAction("Index", "Cart")); } }
public async Task<ActionResult> RefundOrder(int id) { model.EditOrder = await repository.GetOrderAsync(id); RefundTransactionClient authnetRefundClient = new RefundTransactionClient(); creditCardType creditCard = new creditCardType { cardNumber = model.EditOrder.CardLastFour, expirationDate = "XXXX" }; decimal amount = model.EditOrder.Total; string transactionId = model.EditOrder.TransactionId; createTransactionResponse response = authnetRefundClient.RunRefund(authorizeNetApiLoginID, authorizeNetApiTransactionKey, creditCard, amount, transactionId); model.ResponseCode = response.transactionResponse.responseCode; model.TransactionId = response.transactionResponse.transId; model.AuthorizationCode = response.transactionResponse.authCode; //update the order in the Db model.EditOrder.Refunded = true; model.Orders = await repository.UpdateOrderAsync(model.EditOrder, true); return View("Orders", model); }
public string SubmitOrder(HomeViewModel model) { //submit the order to processor ChargeCreditCardClient authnetChargeClient = new ChargeCreditCardClient(); creditCardType creditCard = new creditCardType { cardNumber = model.CreditCard.CardNumber, expirationDate = String.Format("{0:00}", model.CreditCard.ExpMonth) + String.Format("{0:00}", model.CreditCard.ExpYear), cardCode = model.CreditCard.CardCode }; customerAddressType billingAddress = new customerAddressType { firstName = model.CreditCard.BillFirstName, lastName = model.CreditCard.BillLastName, address = model.CreditCard.BillStreet, city = model.CreditCard.BillCity, state = model.CreditCard.BillState, zip = model.CreditCard.BillZip }; int linecount = model.Order.Items.Count; lineItemType[] lineItems = new lineItemType[linecount + 3]; for (int i = 0; i < linecount; i++) { lineItems[i] = new lineItemType { itemId = i.ToString(), name = model.Order.Items[i].ProductName + ", " + model.Order.Items[i].ProductShortDescr, quantity = model.Order.Items[i].Quantity, unitPrice = model.Order.Items[i].UnitPrice }; } lineItems[linecount] = new lineItemType { itemId = linecount.ToString(), name = "Tax", quantity = 1m, unitPrice = model.Order.Tax }; lineItems[linecount + 1] = new lineItemType { itemId = (linecount + 1).ToString(), name = "Shipping and Handling", quantity = 1m, unitPrice = model.Order.ShipHand }; lineItems[linecount + 2] = new lineItemType { itemId = (linecount + 2).ToString(), name = "Adjustment", quantity = 1m, unitPrice = model.Order.Adjustment }; string authorizeNetApiLoginID = ConfigurationManager.AppSettings["authorizeNetApiLoginID"]; string authorizeNetApiTransactionKey = ConfigurationManager.AppSettings["authorizeNetApiTransactionKey"]; //Debug.WriteLine("If this were real, your charge would be processed HERE"); //return "HI!"; createTransactionResponse response = authnetChargeClient.RunCharge(authorizeNetApiLoginID, authorizeNetApiTransactionKey, creditCard, billingAddress, lineItems, model.Order.Total); model.ResponseCode = response.transactionResponse.responseCode; model.TransactionId = response.transactionResponse.transId; model.AuthorizationCode = response.transactionResponse.authCode; //save the order in the Db model.Order.CardLastFour = model.CreditCard.CardNumber.Substring(model.CreditCard.CardNumber.Length - 4); model.Order.TransactionId = model.TransactionId; model.Order.ResponseCode = model.ResponseCode; model.Order.AuthorizationCode = model.AuthorizationCode; repository.AddOrderAsync(model.Order, false); string subject = "New MagnoVault order"; string content = "<p>A new order was submitted:</p><p>" + model.Order.ShipFirstName + " " + model.Order.ShipLastName + "</p><p> + " + linecount + " line items totalling $" + model.Order.Total + "</p>"; SendEmail(subject, content); //return the response from the gateway return model.ResponseCode; }
public ActionResult AuthorizeNetSandbox(HomeViewModel model) { ChargeCreditCardClient authnetChargeClient = new ChargeCreditCardClient(); creditCardType creditCard = new creditCardType { cardNumber = "4111111111111111", expirationDate = "0718", cardCode = "123" }; customerAddressType billingAddress = new customerAddressType { firstName = "John", lastName = "Doe", address = "123 My St", city = "OurTown", zip = "98004" }; lineItemType[] lineItems = new lineItemType[2]; lineItems[0] = new lineItemType { itemId = "1", name = "t-shirt", quantity = 2, unitPrice = new Decimal(15.00) }; lineItems[1] = new lineItemType { itemId = "2", name = "snowboard", quantity = 1, unitPrice = new Decimal(450.00) }; createTransactionResponse response = authnetChargeClient.RunCharge(authorizeNetApiLoginID, authorizeNetApiTransactionKey, creditCard, billingAddress, lineItems, 99.75m); model.ResponseCode = response.transactionResponse.responseCode; model.TransactionId = response.transactionResponse.transId; model.AuthorizationCode = response.transactionResponse.authCode; return View(model); //RefundTransactionClient authnetRefundClient = new RefundTransactionClient(); //creditCardType creditCard = new creditCardType //{ // cardNumber = "1111", // expirationDate = "XXXX" //}; //decimal amount = 99.75m; //string transactionId = "12345"; //createTransactionResponse response = authnetRefundClient.RunRefund(authorizeNetApiLoginID, authorizeNetApiTransactionKey, creditCard, amount, transactionId); //model.ResponseCode = Int32.Parse(response.transactionResponse.responseCode); //model.TransactionId = response.transactionResponse.transId; //model.AuthorizationCode = response.transactionResponse.authCode; //return View(model); }
private static AuthorizeNetResponse ParseResponse(createTransactionResponse response) { AuthorizeNetResponse finalResponse = new AuthorizeNetResponse(); // validate response if (response != null) { if (response.messages.resultCode == messageTypeEnum.Ok) { if (response.transactionResponse.messages != null) { finalResponse.Result = "Success"; finalResponse.TransactionID = response.transactionResponse.transId; finalResponse.AuthCode = response.transactionResponse.authCode; finalResponse.Message = response.transactionResponse.messages[0].description; } else { finalResponse.Result = "Fail"; finalResponse.TransactionID = "NA"; if (response.transactionResponse.errors != null) { finalResponse.AuthCode = response.transactionResponse.errors[0].errorCode; finalResponse.Message = response.transactionResponse.errors[0].errorText; } } } else { finalResponse.Result = "Fail"; finalResponse.TransactionID = "NA"; if (response.transactionResponse != null && response.transactionResponse.errors != null) { finalResponse.AuthCode = response.transactionResponse.errors[0].errorCode; finalResponse.Message = response.transactionResponse.errors[0].errorText; } else { finalResponse.AuthCode = response.messages.message[0].code; } } } else { finalResponse.Result = "Fail"; finalResponse.TransactionID = "NA"; finalResponse.AuthCode = "NA"; finalResponse.Message = "Null Response."; } return(finalResponse); }
/// <summary> /// Method that outputs to the console various methods based on the /// response /// </summary> /// <param name="response">CreateTransactionResponse</param> public void TransactionLogging(createTransactionResponse response) { if (response != null) { if (response.messages.resultCode == messageTypeEnum.Ok) { if (response.transactionResponse.messages != null) { Console.WriteLine("Created transaction. Transaction ID: " + response.transactionResponse.transId); Console.WriteLine("Response Code: " + response.transactionResponse.responseCode); Console.WriteLine("Message Code: " + response.transactionResponse.messages[0].code); Console.WriteLine("Description: " + response.transactionResponse.messages[0].description); Console.WriteLine("Success, Auth Code : " + response.transactionResponse.authCode); } else { Console.WriteLine("Failed Transaction."); if (response.transactionResponse.errors != null) { Console.WriteLine("Error Code: " + response.transactionResponse.errors[0].errorCode); Console.WriteLine("Error message: " + response.transactionResponse.errors[0].errorText); } } } else { Console.WriteLine("Failed Transaction."); if (response.transactionResponse != null && response.transactionResponse.errors != null) { Console.WriteLine("Error Code: " + response.transactionResponse.errors[0].errorCode); Console.WriteLine("Error message: " + response.transactionResponse.errors[0].errorText); } else { Console.WriteLine("Error Code: " + response.messages.message[0].code); Console.WriteLine("Error message: " + response.messages.message[0].text); } } } else { Console.WriteLine("Null Response."); } }
void SdkListener.transactionCompleted(createTransactionResponse response, bool isSuccess, string customerSignature, ErrorResponse errorResponse) { Debug.Write("\n MainController:transactionCompleted" + "\n" + response + "\n" + isSuccess + "\n" + errorResponse); this.Dispatcher.Invoke(() => { if (isSuccess) { Random random = new Random(); this.amount.Text = (random.Next(1, 1000)).ToString(); this.transactionStatus.Text = string.Format("Transaction Approved \n Transaction ID {0}", response.transactionResponse.transId); } else { this.transactionStatus.Text = string.Format("Transaction Failed \n {0}", errorResponse.errorMessage); } }); }
public async Task<ActionResult> AddOrder(HomeViewModel model) { //submit the order to processor ChargeCreditCardClient authnetChargeClient = new ChargeCreditCardClient(); creditCardType creditCard = new creditCardType { cardNumber = model.CreditCard.CardNumber, expirationDate = String.Format("{0:00}", model.CreditCard.ExpMonth) + String.Format("{0:00}", model.CreditCard.ExpYear), cardCode = model.CreditCard.CardCode }; customerAddressType billingAddress = new customerAddressType { firstName = model.CreditCard.BillFirstName, lastName = model.CreditCard.BillLastName, address = model.CreditCard.BillStreet, city = model.CreditCard.BillCity, zip = model.CreditCard.BillZip }; lineItemType[] lineItems = new lineItemType[model.EditOrder.Items.Count + 3]; for (int i = 0; i < model.EditOrder.Items.Count; i++) { lineItems[i] = new lineItemType { itemId = i.ToString(), name = model.EditOrder.Items[i].ProductName + ", " + model.EditOrder.Items[i].ProductShortDescr, quantity = model.EditOrder.Items[i].Quantity, unitPrice = model.EditOrder.Items[i].UnitPrice }; } lineItems[model.EditOrder.Items.Count] = new lineItemType { itemId = model.EditOrder.Items.Count.ToString(), name = "Tax", quantity = 1m, unitPrice = model.EditOrder.Tax }; lineItems[model.EditOrder.Items.Count + 1] = new lineItemType { itemId = (model.EditOrder.Items.Count + 1).ToString(), name = "Shipping and Handling", quantity = 1m, unitPrice = model.EditOrder.ShipHand }; lineItems[model.EditOrder.Items.Count + 2] = new lineItemType { itemId = (model.EditOrder.Items.Count + 2).ToString(), name = "Adjustment", quantity = 1m, unitPrice = model.EditOrder.Adjustment }; createTransactionResponse response = authnetChargeClient.RunCharge(authorizeNetApiLoginID, authorizeNetApiTransactionKey, creditCard, billingAddress, lineItems, model.EditOrder.Total); model.ResponseCode = response.transactionResponse.responseCode; model.TransactionId = response.transactionResponse.transId; model.AuthorizationCode = response.transactionResponse.authCode; //save the order in the Db model.EditOrder.CardLastFour = model.CreditCard.CardNumber.Substring(model.CreditCard.CardNumber.Length - 4); model.EditOrder.TransactionId = model.TransactionId; model.EditOrder.ResponseCode = model.ResponseCode; model.EditOrder.AuthorizationCode = model.AuthorizationCode; model.Orders = await repository.AddOrderAsync(model.EditOrder, true); return View("Orders", model); }
public ActionResult PaymentInfo(PaymentGatewayVM PaymentGatewayVM) { createTransactionResponse response = PaymentGatewayUtility.Run(ConfigurationManager.AppSettings["ApiLoginID"], ConfigurationManager.AppSettings["ApiTransactionKey"], PaymentGatewayVM); if (response.messages.resultCode == messageTypeEnum.Ok) { bool TransResult = _PaymentGatewayService.SaveTransactionDetails(new CardTransactionDetails { CardHolderName = PaymentGatewayVM.CardHolderName, CardNumber = PaymentGatewayVM.CardNumber, Expiration = PaymentGatewayVM.MonthAndYear, CVV = PaymentGatewayVM.CVV, ResultCode = response.messages.resultCode.ToString(), Message = response.messages.message[0].text, AccountType = response.transactionResponse.accountType, TransId = response.transactionResponse.transId, ResponseCode = Convert.ToInt32(response.transactionResponse.responseCode), CreatedDate = DateTime.Now, //change for user to userloginid CreatedBy = Convert.ToInt32(Session["AdminLoginID"]) }); if (TransResult) { TempData["PaymentStatus"] = true; return(Json(new { result = true, Message = response.messages.message[0].text })); } else { TempData["PaymentStatus"] = true; return(Json(new { result = true, Message = response.messages.message[0].text })); } } else { TempData["PaymentStatus"] = false; return(Json(new { result = false, Message = response.messages.message[0].text })); } }
public void MockcreateTransactionTest() { //define all mocked objects as final var mockController = GetMockController <createTransactionRequest, createTransactionResponse>(); var mockRequest = new createTransactionRequest { merchantAuthentication = new merchantAuthenticationType { name = "mocktest", Item = "mockKey", ItemElementName = ItemChoiceType.transactionKey }, }; var transactionResponse = new transactionResponse() { accountNumber = "1234", }; var mockResponse = new createTransactionResponse { refId = "1234", sessionToken = "sessiontoken", transactionResponse = transactionResponse, }; var errorResponse = new ANetApiResponse(); var results = new List <String>(); const messageTypeEnum messageTypeOk = messageTypeEnum.Ok; SetMockControllerExpectations <createTransactionRequest, createTransactionResponse, createTransactionController>( mockController.MockObject, mockRequest, mockResponse, errorResponse, results, messageTypeOk); mockController.MockObject.Execute(AuthorizeNet.Environment.CUSTOM); //mockController.MockObject.Execute(); // or var controllerResponse = mockController.MockObject.ExecuteWithApiResponse(AuthorizeNet.Environment.CUSTOM); var controllerResponse = mockController.MockObject.GetApiResponse(); Assert.IsNotNull(controllerResponse); Assert.IsNotNull(controllerResponse.transactionResponse); LogHelper.info(Logger, "createTransaction: Details:{0}", controllerResponse.transactionResponse); }
public void SampleCodeCreateCreditRequestForSettledTransaction() { var rnd = new AnetRandom(DateTime.Now.Millisecond); ApiOperationBase <ANetApiRequest, ANetApiResponse> .MerchantAuthentication = CustomMerchantAuthenticationType; ApiOperationBase <ANetApiRequest, ANetApiResponse> .RunEnvironment = TestEnvironment; // Find a settled credit card transaction and set txnToCredit to its transaction ID string txnToCredit = "Not Set"; if (txnToCredit == "Not Set") { Assert.Fail("This test requires that you set txnToCredit to the transaction ID of a settled credit card transaction"); } //get details of the specified transaction decimal txnAmount = 0m; string txnCardNo = string.Empty; var gtdReq = new getTransactionDetailsRequest { transId = txnToCredit }; var gtdCont = new getTransactionDetailsController(gtdReq); gtdCont.Execute(); var gtdResp = gtdCont.GetApiResponse(); //Test the transaction before continuing Assert.AreEqual(messageTypeEnum.Ok, gtdResp.messages.resultCode); txnAmount = gtdResp.transaction.settleAmount; txnCardNo = ((AuthorizeNet.Api.Contracts.V1.creditCardMaskedType)(gtdResp.transaction.payment.Item)).cardNumber; //Create payment type that matches transaction to credit var creditCard = new creditCardType { cardNumber = txnCardNo.TrimStart(new char[] { 'X' }), expirationDate = "XXXX" }; var paymentType = new paymentType { Item = creditCard }; //Create credit request transactionRequestType txnType = new transactionRequestType { amount = txnAmount, refTransId = txnToCredit, transactionType = transactionTypeEnum.refundTransaction.ToString(), payment = paymentType, }; createTransactionRequest creditReq = new createTransactionRequest { transactionRequest = txnType }; createTransactionController creditCont = new createTransactionController(creditReq); creditCont.Execute(); createTransactionResponse creditResp = creditCont.GetApiResponse(); //validate Assert.AreEqual("1", creditResp.transactionResponse.messages[0].code); }
public static PaymentResponseVM Payment(AuthorizeNetAccount authInfo, PaymentVM payment) { if (authInfo.IsTestMode) { ApiOperationBase <ANetApiRequest, ANetApiResponse> .RunEnvironment = AuthorizeNet.Environment.SANDBOX; } else { ApiOperationBase <ANetApiRequest, ANetApiResponse> .RunEnvironment = AuthorizeNet.Environment.PRODUCTION; } PaymentResponseVM paymentResponse = new PaymentResponseVM(); ApiOperationBase <ANetApiRequest, ANetApiResponse> .MerchantAuthentication = new merchantAuthenticationType() { name = authInfo.AuthNetLoginID, ItemElementName = ItemChoiceType.transactionKey, Item = authInfo.AuthNetTransKey, }; var creditCard = new creditCardType { cardNumber = payment.CardNumber.ToString(), expirationDate = payment.ExpirationDate.ToString(), cardCode = payment.SecurityCode.ToString() }; var billingAddress = new customerAddressType { firstName = payment.FirstName, lastName = payment.LastName, company = payment.Company, address = payment.Address, city = payment.City, state = payment.State, zip = payment.Zip.ToString(), email = payment.Email }; var paymentType = new paymentType { Item = creditCard }; var transactionRequest = new transactionRequestType { transactionType = transactionTypeEnum.authOnlyTransaction.ToString(), amount = payment.Amount, payment = paymentType, billTo = billingAddress }; var request = new createTransactionRequest { transactionRequest = transactionRequest }; createTransactionResponse response = new createTransactionResponse(); try { createTransactionController controller = new createTransactionController(request); controller.Execute(); response = controller.GetApiResponse(); } catch (Exception ex) { paymentResponse.ErrorMessage = ex.Message; return(paymentResponse); } if (response != null) { if (response.messages.resultCode == messageTypeEnum.Ok) { if (response.transactionResponse.messages != null) { paymentResponse.TransactionID = response.transactionResponse.transId; paymentResponse.ResponseCode = response.transactionResponse.responseCode; paymentResponse.MessagesCode = response.transactionResponse.messages[0].code; paymentResponse.MessageDescription = response.transactionResponse.messages[0].description; paymentResponse.AuthorizationCode = response.transactionResponse.authCode; } else { if (response.transactionResponse.errors != null) { paymentResponse.ErrorCode = response.transactionResponse.errors[0].errorCode; paymentResponse.ErrorMessage = response.transactionResponse.errors[0].errorText; } } } else { if (response.transactionResponse != null && response.transactionResponse.errors != null) { paymentResponse.ErrorCode = response.transactionResponse.errors[0].errorCode; paymentResponse.ErrorMessage = response.transactionResponse.errors[0].errorText; } else { paymentResponse.ErrorCode = response.transactionResponse.errors[0].errorCode; paymentResponse.ErrorMessage = response.transactionResponse.errors[0].errorText; } } } return(paymentResponse); }
private static bool GetErrors(createTransactionResponse response, IList <string> errors) { var rezult = false; if (response != null && response.messages.resultCode == messageTypeEnum.Ok) { switch (response.transactionResponse.responseCode) { case "1": break; case "2": { errors.Add(string.Format("Declined ({0}: {1})", response.transactionResponse.responseCode, response.transactionResponse.messages[0].description)); rezult = true; } break; case "3": { foreach (var transactionResponseError in response.transactionResponse.errors) { errors.Add(string.Format("Error #{0}: {1}", transactionResponseError.errorCode, transactionResponseError.errorText)); } rezult = true; } break; default: { errors.Add("Authorize.NET unknown error"); rezult = true; } break; } return(rezult); } if (response != null) { foreach (var responseMessage in response.messages.message) { errors.Add(string.Format("Error #{0}: {1}", responseMessage.code, responseMessage.text)); } if (response.transactionResponse != null && response.transactionResponse.errors != null) { foreach (var transactionResponseError in response.transactionResponse.errors) { errors.Add(string.Format("Error #{0}: {1}", transactionResponseError.errorCode, transactionResponseError.errorText)); } } } else { errors.Add("Authorize.NET unknown error"); } return(true); }
public string Run(ApplicationUser user, Order order) { ApiOperationBase <ANetApiRequest, ANetApiResponse> .RunEnvironment = AuthorizeNet.Environment.SANDBOX; ApiOperationBase <ANetApiRequest, ANetApiResponse> .MerchantAuthentication = new merchantAuthenticationType { name = _configuration["AuthorizeNet:LoginID"], ItemElementName = ItemChoiceType.transactionKey, Item = _configuration["AuthorizeNet:TransactionKey"] }; long number = (long)order.CardNumber; creditCardType creditCard = new creditCardType { cardNumber = number.ToString(), expirationDate = "1219" }; customerAddressType address = new customerAddressType { firstName = user.FirstName, lastName = user.LastName, address = order.ShippingAddress, city = order.City, zip = order.Zip }; paymentType payment = new paymentType { Item = creditCard }; transactionRequestType transactionRequest = new transactionRequestType { transactionType = transactionTypeEnum.authCaptureTransaction.ToString(), amount = order.TotalPrice, payment = payment, billTo = address, }; createTransactionRequest request = new createTransactionRequest { transactionRequest = transactionRequest }; createTransactionController controller = new createTransactionController(request); controller.Execute(); createTransactionResponse response = controller.GetApiResponse(); StringBuilder logText = new StringBuilder(); if (response != null) { if (response.messages.resultCode == messageTypeEnum.Ok) { if (response.transactionResponse.messages != null) { logText.AppendLine($"Successfully created transaction (ID: {response.transactionResponse.transId})"); logText.AppendLine($"Response Code: {response.transactionResponse.responseCode}"); logText.AppendLine($"Message Code: {response.transactionResponse.messages[0].code}"); logText.AppendLine($"Description: {response.transactionResponse.messages[0].description}"); logText.AppendLine($"Auth Code: {response.transactionResponse.authCode}"); } else { if (response.transactionResponse.errors != null) { logText.AppendLine("Failed Transaction."); logText.AppendLine($"Error Code: {response.transactionResponse.errors[0].errorCode}"); logText.AppendLine($"Error Message: {response.transactionResponse.errors[0].errorText}"); } } } else { logText.AppendLine("Failed Transaction."); if (response.transactionResponse != null && response.transactionResponse.errors != null) { logText.AppendLine($"Error Code: {response.transactionResponse.errors[0].errorCode}"); logText.AppendLine($"Error Message: {response.transactionResponse.errors[0].errorText}"); } else { logText.AppendLine($"Error Code: {response.messages.message[0].code}"); logText.AppendLine($"Error Message: {response.messages.message[0].text}"); } } } else { logText.AppendLine("Transaction request resulted in null response"); } return(logText.ToString()); }