Showing results for 
Search instead for 
Did you mean: 

sample using iframe and lightbox for

i am trying to find a good sample of using the payment form in an iframe and also sample of lightbox. I am doing this so that the customer can see which one they want. I can get the payment form to show on website page. but can not seem to find an good exaple on the other ways

There is a very basic example of each method at :
Powered by -
Certified developers
Trusted Contributor

This is the finshed product but not the code. The simple code how to use iframe in to use the post in a form is what i need.

Actually that one is in Java, this one is in C#, but the code you use to get the token is arbitrary. You say are able to get the payment form to show on The only difference would be to target an iframe or modal with your form, as the case may be.

Powered by -
Certified developers

Do you have the source for that C# sample that can be shared? I am having a heck of a time getting it to work in my project.

Getting an Accept Hosted payment page is even simpler using .NetCore:

    public IActionResult Index()

			HttpClient client = new HttpClient();
			client.BaseAddress = new Uri(@"");
			client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/xml"));
			HttpContent content = new StringContent(@"<getHostedPaymentPageRequest xmlns=""AnetApi/xml/v1/schema/AnetApiSchema.xsd"">
            <settingValue>{""show"": true, ""required"":true}</settingValue>
            <settingValue>{""text"": ""Pay""}</settingValue>
</getHostedPaymentPageRequest>", System.Text.Encoding.UTF8, "application/xml"); 

			HttpResponseMessage result = client.PostAsync("xml/v1/request.api", content).Result;
			var resultContent = result.Content.ReadAsStreamAsync().Result;
			XDocument incomingXml = XDocument.Load(resultContent);

			var token = incomingXml.Descendants()
				.Where(a => a.Name.LocalName == "token")
		ViewData["Message"] = token;
            return View();


Powered by -
Certified developers

 My issue that I am having isn't getting the token and payment page, it is after that. I understand I am supposed to have a listener page and then that processes the response back on my end, but that is where I am getting lost in what needs to be done.

The response is conveyed to your parent page via your specified hostedPaymentIFrameCommunicatorUrl. 

<settingName>hostedPaymentIFrameCommunicatorUrl</settingName> <settingValue>{"url":""}</settingValue> </setting>

In your parent page you could have something like the following: 

    window.CommunicationHandler = {};
    function parseQueryString(str) {
        var vars = [];
        var arr = str.split('&');
        var pair;
        for (var i = 0; i < arr.length; i++) {
            pair = arr[i].split('=');
            vars[pair[0]] = unescape(pair[1]);
        return vars;
    window.CommunicationHandler.onReceiveCommunication = function (argument) {
        params = parseQueryString(argument.qstr)
        parentFrame = argument.parent.split('/')[4];
        switch (params['action']) {
            case "transactResponse":
                var transResponse = JSON.parse(params['response']);
                $('#demo').html("Thank you. Your Transaction Id is: "+transResponse.transId);



 What you do with the response is going to depend on what information you require and how you have your application set up.

Powered by -
Certified developers

Hi Nexussoftware,

Thanks for updating on .net core support.

Can you please share link of any walkthrough for implementing same or link of source code you shared.

Hi Nexussoftware,


I am able to make the payment as you shown the example using iframe but unable to get response which shown on the iframe like transaaction id and details to our controller so i can use these data. So may you guide what should i do? Even i am getting error in console when i am using iframe.