Hi,
I am using the C# - SDK sample code with few adjust to integrate in a customer's website. Code works very well in Sandbox, using my developer credentials. Then, when I turn the environment to Production put my Customer's credentials and live customer's portal set to Test Mode, the code does not work and returns a error message saying there was some error trying to process the transaction. Message comes without any error number.
I spent several hours on internet trying to get an answer but unfortunatly I did not find answer.
Also I called Authorize.net but they could not offere me any help without a error number.
Code below shows where in the code I made changes to production server.
I wonder if someone could help with this issue.
Thank you in advance.
JS
03-29-2016 09:27 PM
Hi,
Production Gateway is still in Test Mode. and All sensitive credential are in the webconfig file.
I am using the GitHub Sample code for C# ( biblioteca .NET) with few changes to send a TransactioRequest this way:
var request = new createTransactionRequest { transactionRequest = transactionRequest };
Below is the full code I am using:
AuthorizeNetHelper.cs
using AuthorizeNet.Api.Contracts.V1; using AuthorizeNet.Api.Controllers; using AuthorizeNet.Api.Controllers.Bases; using System; using System.Collections.Generic; using System.Linq; using System.Web; namespace Booking.Infrastructure.Helpers { public static class AuthorizeNetHelper { static AuthorizeNetHelper() { ApiOperationBase<ANetApiRequest, ANetApiResponse>.RunEnvironment = Properties.Settings.Default.RunningInProductionEnvironment ? AuthorizeNet.Environment.PRODUCTION : AuthorizeNet.Environment.SANDBOX; } public static createTransactionResponse ChargeCreditCard(creditCardType creditCard, customerAddressType billingAddress, string description, decimal amount) { ApiOperationBase<ANetApiRequest, ANetApiResponse>.RunEnvironment = AuthorizeNet.Environment.SANDBOX; ApiOperationBase<ANetApiRequest, ANetApiResponse>.MerchantAuthentication = new merchantAuthenticationType { name = Properties.Settings.Default.AuthorizeNetApiLoginId, ItemElementName = ItemChoiceType.transactionKey, Item = Properties.Settings.Default.AuthorizeNetApiTransactionKey }; var transactionRequest = new transactionRequestType { transactionType = transactionTypeEnum.authCaptureTransaction.ToString(), amount = amount, payment = new paymentType { Item = creditCard }, billTo = billingAddress, lineItems = new lineItemType[] { new lineItemType { itemId = "1", name = description.Substring(0, description.Length > 31 ? 31 : description.Length), quantity = 1, unitPrice = amount } } }; var request = new createTransactionRequest { transactionRequest = transactionRequest }; var controller = new createTransactionController(request); controller.Execute(); var response = controller.GetApiResponse(); return response;//.messages.resultCode == messageTypeEnum.Ok; } public static string GenerateExp(int month, int year) { return (new DateTime(year, month, 1)).ToString("MMyy"); } } }
case PaymentMethod.CreditCard: { var creditCard = new AuthorizeNet.Api.Contracts.V1.creditCardType { cardNumber = viewModel.CCNumber, expirationDate = AuthorizeNetHelper.GenerateExp(viewModel.CCExpMonth, viewModel.CCExpYear), cardCode = viewModel.CCCode }; var billingAddress = new AuthorizeNet.Api.Contracts.V1.customerAddressType(); if (!string.IsNullOrEmpty(viewModel.CCFirstName)) billingAddress.firstName = viewModel.CCFirstName; if (!string.IsNullOrEmpty(viewModel.CCLastName)) billingAddress.lastName = viewModel.CCLastName; if (!string.IsNullOrEmpty(viewModel.CCAddress)) billingAddress.address = viewModel.CCAddress; if (!string.IsNullOrEmpty(viewModel.CCCity)) billingAddress.city = viewModel.CCCity; if (!string.IsNullOrEmpty(viewModel.CCState)) billingAddress.state = viewModel.CCState; if (!string.IsNullOrEmpty(viewModel.CCZipCode)) billingAddress.zip = viewModel.CCZipCode; if (!string.IsNullOrEmpty(viewModel.CCCountry)) billingAddress.country = viewModel.CCCountry; var description = string.Format("Reservation {0}", reservation.ReservationNr); var response = AuthorizeNetHelper.ChargeCreditCard(creditCard, billingAddress, description, paymentTotal);
In my sandbox account everything works fine. In production with customer's real credentials does not.
The only change I made was replace this line
ApiOperationBase<ANetApiRequest, ANetApiResponse>.RunEnvironment = AuthorizeNet.Environment.SANDBOX;
with that
ApiOperationBase<ANetApiRequest, ANetApiResponse>.RunEnvironment = AuthorizeNet.Environment.PRODUCTION;
Thank you for your help,
JS
04-05-2016 01:34 PM
@jsw32821 could you please try again. There was some fine-tuning done to our production servers today that may improve your results.
Richard
04-05-2016 03:59 PM
Tested and... worked fine in Production server.
Thank you very much.
Have a great evening.
JS
04-05-2016 06:17 PM