http://dnn922research.envisionbeta.net/donation
This is a sample, if you run through the process (tied to the sandbox account, not live), and hit "Continue to secure payment", it will open the popup, but will return a 404 error when hitting the auth.net page, I've logged the json response from the handshake to the console log, looks fine, just throws a 404. If I remove the customer being added to the transactionRequest it works fine.
See code that is there now:
public static ANetApiResponse Run(decimal amount, string firstName, string lastName, string country, string zip, string address,
string city, string state, string phoneNumber, string email, System.Collections.Hashtable moduleSettings)
{
if (moduleSettings["Environment"].ToString() == "PRODUCTION")
{
ApiOperationBase<ANetApiRequest, ANetApiResponse>.RunEnvironment = AuthorizeNet.Environment.PRODUCTION;
}
else
{
ApiOperationBase<ANetApiRequest, ANetApiResponse>.RunEnvironment = AuthorizeNet.Environment.SANDBOX;
}
ApiOperationBase<ANetApiRequest, ANetApiResponse>.MerchantAuthentication = new merchantAuthenticationType()
{
name = moduleSettings["ApiLoginID"].ToString(),
ItemElementName = ItemChoiceType.transactionKey,
Item = moduleSettings["ApiTransactionKey"].ToString(),
};
ServicePointManager.Expect100Continue = true;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
settingType[] settings = new settingType[10];
settings[0] = new settingType();
settings[0].settingName = settingNameEnum.hostedPaymentButtonOptions.ToString();
settings[0].settingValue = "{\"text\": \"Submit Gift\"}";
settings[1] = new settingType();
settings[1].settingName = settingNameEnum.hostedPaymentOrderOptions.ToString();
settings[1].settingValue = "{\"show\": false}";
settings[2] = new settingType();
settings[2].settingName = settingNameEnum.hostedPaymentBillingAddressOptions.ToString();
settings[2].settingValue = "{\"show\": true}";
settings[3] = new settingType();
settings[3].settingName = settingNameEnum.hostedPaymentReturnOptions.ToString();
settings[3].settingValue = "{\"showReceipt\": false}";
settings[4] = new settingType();
settings[4].settingName = settingNameEnum.hostedPaymentPaymentOptions.ToString();
settings[4].settingValue = "{\"cardCodeRequired\": true, \"showCreditCard\": true, \"showBankAccount\": false}";
settings[5] = new settingType();
settings[5].settingName = settingNameEnum.hostedPaymentSecurityOptions.ToString();
settings[5].settingValue = "{\"captcha\": true}";
settings[6] = new settingType();
settings[6].settingName = settingNameEnum.hostedPaymentStyleOptions.ToString();
settings[6].settingValue = "{\"bgColor\": \"#0f175e\"}";
settings[7] = new settingType();
settings[7].settingName = settingNameEnum.hostedPaymentIFrameCommunicatorUrl.ToString();
settings[7].settingValue = "{\"url\": \"" + System.Web.HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Scheme) + System.Web.HttpContext.Current.Request.Url.Host + "/DesktopModules/Donation_Module/hosted.html\"}";
settings[8] = new settingType();
settings[8].settingName = settingNameEnum.hostedPaymentCustomerOptions.ToString();
settings[8].settingValue = "{\"showEmail\": true}";
var billTo = new customerAddressType();
billTo.firstName = firstName;
billTo.lastName = lastName;
billTo.country = country;
billTo.zip = zip;
billTo.address = address;
billTo.city = city;
billTo.state = state;
billTo.email = email;
if (phoneNumber != "null") billTo.phoneNumber = phoneNumber;
var cust = new customerDataType();
cust.email = email;
var transactionRequest = new transactionRequestType
{
transactionType = transactionTypeEnum.authCaptureTransaction.ToString(), // authorize capture only
amount = amount,
billTo = billTo,
customer = cust
};
var request = new getHostedPaymentPageRequest();
request.transactionRequest = transactionRequest;
request.hostedPaymentSettings = settings;
// instantiate the controller that will call the service
var controller = new getHostedPaymentPageController(request);
controller.Execute();
// get the response from the service (errors contained if any)
var response = controller.GetApiResponse();
// validate response
if (response != null && response.messages.resultCode == messageTypeEnum.Ok)
{
Console.WriteLine("Message code : " + response.messages.message[0].code);
Console.WriteLine("Message text : " + response.messages.message[0].text);
Console.WriteLine("Token : " + response.token);
}
else if (response != null)
{
Console.WriteLine("Error: " + response.messages.message[0].code + " " + response.messages.message[0].text);
Console.WriteLine("Failed to get hosted payment page");
}
return response;
}