cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

blank page when calling getHostedPaymentPageRequest from asp.net page

Hi! 

 

I have this c# code in asp.net web forms page: 

 

ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
ApiOperationBase<ANetApiRequest, ANetApiResponse>.RunEnvironment = AuthorizeNet.Environment.SANDBOX;
ApiOperationBase<ANetApiRequest, ANetApiResponse>.MerchantAuthentication = new merchantAuthenticationType()
{
name = "3XU3ASDASDSA6hm",
ItemElementName = ItemChoiceType.transactionKey,
Item = "42dasdas2GPDASDSDASQPR997k",
};

settingType[] settings = new settingType[]{
new settingType()
// More settings can be added here as and when required
};

settings[0] = new settingType();
settings[0].settingName = settingNameEnum.hostedPaymentButtonOptions.ToString();
settings[0].settingValue = "{\"text\": \"Pay\"}";

var transactionRequest = new transactionRequestType
{
transactionType = transactionTypeEnum.authCaptureTransaction.ToString(), // authorize capture only
amount = 10
};

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);
}
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");
}

 

hfToken.Value = response.token;

 

 

Also in the html I have this: 

 

<iframe src="https://test.authorize.net/payment/payment"></iframe>
<asp:HiddenField runat="server" ID="hfToken" />

 

 

I'm expecting to either get redirected to a.net hosted page or display the iframe accordingly, but for the iframe I have this:

 

 

Either way will work for us but I want to know if I need to do anything else in order to get the iframe properly displayed or to be properly redirected to the a.net hosted form.

 

Prompt replies greatly appreciated since we really need this to be working very soon.

 

Thanks!

arnaudov
Member
2 REPLIES 2
Hello, You need to target your iframe with your form post to https://test.authorize.net/payment/payment including the hidden token input. See an html example at : https://nexwebsites.com/authorizenet/token-tester.html
Powered by NexWebSites.com -
Certified Authorize.net developers
NexusSoftware
Trusted Contributor

Hey NexusSoftware,

 

I am facing same issue blank page after embedded toke to the url have also included target.

i am dont understand why its not working. 

 

<form action="https://test.authorize.net/payment/payment" method="post" target="loadPayment">
<input id="token" name="token" value={{hostedPaymentPageToken}} />
<input id="validate" type="submit" (click)="callHostedPage()" value="Pay Now" class="btn btn-primary btn-lg">
</form>
<iframe #loadPayment id="loadPayment" width="100%" height="650px" frameborder="1" scrolling="no"></iframe>

 

Thanks,