cancel
Showing results for 
Search instead for 
Did you mean: 

Hosted Payment for C# MVC response problem

Hi,

I am using the following code

ServicePointManager.Expect100Continue = true;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
ApiOperationBase<ANetApiRequest, ANetApiResponse>.RunEnvironment = AuthorizeNet.Environment.SANDBOX;
ApiOperationBase<ANetApiRequest, ANetApiResponse>.MerchantAuthentication = new merchantAuthenticationType()
{
name = "9b992WaGzQ4",
ItemElementName = ItemChoiceType.transactionKey,
Item = "69E3bAQ7CH2b2m9Z",
};
settingType[] settings = new settingType[3];
settings[0] = new settingType();
settings[0].settingName = settingNameEnum.hostedPaymentButtonOptions.ToString();
settings[0].settingValue = "{\"text\": \"Pay\"}";
settings[1] = new settingType();
settings[1].settingName = settingNameEnum.hostedPaymentOrderOptions.ToString();
settings[1].settingValue = "{\"show\": true}";
settings[2] = new settingType();
settings[2].settingName = settingNameEnum.hostedPaymentReturnOptions.ToString();
settings[2].settingValue = "{\"url\": \"http://localhost:61833/Home/Success\"}";
var transactionRequest = new transactionRequestType
{
transactionType = transactionTypeEnum.authCaptureTransaction.ToString(), // authorize capture only
amount = 1
};
var request = new getHostedPaymentPageRequest();
request.transactionRequest = transactionRequest;
request.hostedPaymentSettings = settings;
// instantiate the contoller 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
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);
String content = "";
content += "<form id=\"send_hptoken\" action=\"https://test.authorize.net/payment/payment\" method=\"post\" target=\"load_payment\">";
content += "<input type='hidden' name='token' value='" + response.token + "' />";
content += "<input type='submit' value='Buy'>";
content += "</form>";
return Content(content);
}



I will pass hostedPaymentReturnOptions as http://localhost:61833/Home/Success

And i am login sandbox and in setting tab and response/receipt url using get or post method

But i am not getting any response in success page.

Peachit2017
Member
0 REPLIES 0