You need to Register for free and Login to post a message in the forum.

Forum

"POST" to another site passing hidden fields
Last Post 2010-04-23 02:09 AM by Joseph Craig. 4 Replies.
Printer Friendly
  •  
  •  
  •  
  •  
  •  
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
KyleUser is Offline
Nuker
Nuker
Posts:12

--
2010-04-19 07:37 PM
    I'm having problems getting something to work that really doesn't appear it should be so hard to do.... it's driving me crazy!

    I'm trying to make my site PCI Compliant. Well, that is changing it to connect to a page that is hosted on my gateway that is PCI Compliant for the user to input their credit card information.

    The gateway needs for me to send the parameters as "HIDDEN" fields using a "POST".  Here is the sample they provided:

    [html]
    [head]
    [ le]XYZ Corporation -- Sample Checkout Page[/ le]
    [/head]
    [body]
    [form name="Form_01" method="POST" action="https://test1.XYZ.com/main.aspx"]
    Transaction Amount:[br]
    [input type="TEXT" name="TransactionAmount" value="1.00"]
    [input type="HIDDEN" name="ECOMRequestID" value="{00000000-0000-0000-0000-000000000000}"]
    [input type="HIDDEN" name="PurchaseIdentifier1" value="ORDER-0001"]
    [input type="HIDDEN" name="PurchaseIdentifier2" value="123456789"]
    [input type="submit" value="Go to Payment Page"]
    [/form]
    [/body]
    [/html]



    I created the following code.... It works but only if the "Supports Partial Rendering" is turned off for the module.


    Protected Sub btnSubmit_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnSubmit.Click

    Dim FormHTML As StringBuilder = New StringBuilder
    Dim HTML As StringBuilder = New StringBuilder

    HTML.Append("[script type=""text/javascript""]")
    HTML.Append("var newWin = window.open("""", ""NewWin"", ""width=675,height=600,scrollbars=1,resizable=1"");")
    HTML.Append(ControlChars.CrLf)
    HTML.Append("newWin.document.open();")
    HTML.Append(ControlChars.CrLf)
    HTML.Append("newWin.document.write('")

    FormHTML.Append("[html][head][ le]Test[/ le][/head][body]")
    FormHTML.Append("[form name=""AutoForm"" method=""post"" action=""https://test1.xxxxx.com/xxxxx/main.aspx""]")
    FormHTML.Append("[input type=""hidden"" name=""TransactionAmount"" value=""1.00"" \/]")
    FormHTML.Append("[input type=""hidden"" name=""ECOMRequestID"" value=""{xxxxx-xxx-xxxx-xxxx-xxxxxxxxxxxx}"" \/]")
    FormHTML.Append("[input type=""hidden"" name=""PurchaseIdentifier1"" value=""ORDER-0006"" \/]")
    FormHTML.Append("[input type=""hidden"" name=""PurchaseIdentifier2"" value=""Customer #6"" \/]")

    FormHTML.Append("[\/form]")
    FormHTML.Append("[SCRIPT type=""text/javascript""]document.AutoForm.submit();[\/SCRIPT]")
    FormHTML.Append("[\/body][\/html]")

    HTML.Append(FormHTML.ToString)
    HTML.Append("');")
    HTML.Append(ControlChars.CrLf)
    HTML.Append("newWin.document.close();")
    HTML.Append(ControlChars.CrLf)
    HTML.Append("[/SCRIPT]")

    Response.Write(HTML.ToString)

    End Sub



    I have asked a few others and they have said that "best option for you is to render your script to the client within your module.  Add a click handler in the javascript, that executes the script."  I'm really not sure how to do this.


    I found this article on CodeProject (http://www.codeproject.com/KB/aspne...ost.aspx). This appears to be a nice solution, however, when the "page.Controls.Add(new LiteralControl(strForm))" line is run, I get an error: "The Controls collection cannot be modified because the control contains code blocks (i.e. [% ... %])."

    I'm guessing that I'm making this harder than it really should be..... Thanks for any help!

    ** Note: changed < > to [ ]
    KyleUser is Offline
    Nuker
    Nuker
    Posts:12

    --
    2010-04-20 07:22 PM
    I'm really not having much luck getting this to work.

    The gateway requires that I "POST" the form to them passing the "HIDDEN" fields. I've done a lot of searching and trying things out, but just can't seem to get it to work. It can't be that hard to do.

    Can some one help me ?
    Joseph CraigUser is Offline
    DNN Creative Support
    Nuke Master VI
    Nuke Master VI
    Posts:9008
    Avatar

    --
    2010-04-20 09:42 PM
    I deleted my two replies which, frankly, made no sense.  I'll try to take a better look at this.

    Joe Craig, DNN Creative Support

    Subscribe to DNNCreative
    I recommend PowerDNN for DotNetNuke Hosting.
    KyleUser is Offline
    Nuker
    Nuker
    Posts:12

    --
    2010-04-20 10:31 PM
    Thanks for looking into it for me Joe.

    The important thing is that it's got to "POST" a form with hidden fields and redirect to the gateway's page.  The DNN page already has a form and I can't seem to get a second form added outside the page's main form.  I tried replacing the form's action with a new action and it almost works, but because the page also has additional hidden fields the gateway get's an error.

    Here's what I've gotten working, but I'm not sure if it's the "best" method to do this.

    Private Sub PostToETS()
        Dim FormHTML As StringBuilder = New StringBuilder
        Dim HTML As StringBuilder = New StringBuilder

        FormHTML.Append("[html>< le>Test")
        FormHTML.Append("[form name=""AutoForm"" method=""post"" action=""https://test1.xxxxxxx.com/ecomh/main.aspx"">")
        FormHTML.Append("[input type=""hidden"" name=""TransactionAmount"" value=""1.00"" />")
        FormHTML.Append("[input type=""hidden"" name=""RequestID"" value=""{xxxxxxx-xxxx-xxxx-xxxx-xxxxx}"" />")
        FormHTML.Append("[input type=""hidden"" name=""PurchaseIdentifier1"" value=""ORDER-0006"" />")
        FormHTML.Append("[input type=""hidden"" name=""PurchaseIdentifier2"" value=""Customer #6"" />")

        FormHTML.Append("[/form>")
        FormHTML.Append("[SCRIPT type=""text/javascript"">document.AutoForm.submit();")
        FormHTML.Append("[\/body><\/html>")

        HTML.Append(FormHTML.ToString)

        Response.Write(HTML.ToString)
    End Sub
    Joseph CraigUser is Offline
    DNN Creative Support
    Nuke Master VI
    Nuke Master VI
    Posts:9008
    Avatar

    --
    2010-04-23 02:09 AM
    While I haven't had a lot of time to dig into this, the short answer is that you can use some javascript (or jQuery) to do the Post. If you google "javascript post" or something similar, you'll find a lot of helpful information. Basically, you want to use an onclick property to call the javascript to emulate the post.

    Joe Craig, DNN Creative Support

    Subscribe to DNNCreative
    I recommend PowerDNN for DotNetNuke Hosting.
    You are not authorized to post a reply.


    Active Forums 4.3

    Latest Forum Posts

    RE: "Good" hosting providers by ejcullen rene
    informative!!!
    RE: URL Master Module doesn't work on IHostASP hosting by ejcullen rene
    informative!!!
    RE: shared web hosting by ejcullen rene
    informative!!. i got hosting service from http://www.thewebpole.com/ my hosting company offers you
    RE: iPhone website logo in DNN root directory by JohnnieD
    I'm supposed to add this link to make my custom logo show up on iPhones. Where in DNN would I a
    iPhone website logo in DNN root directory by JohnnieD
    I'm trying to put an iPhone logo that I made into my site so when someone saves the website on their
    RE: Fixed size container by Joseph Craig
    Use an HTML module and style the container to have a fixed height and width. Set the overflow attr
    Fixed size container by Aggiedan97
    I am looking for advice or an actual container that has a fixed height (and width). An HTML module w
    RE: DNN 6.1 app_offline.htm by Joseph Craig
    If the site "works" in Chrome, Firefox and Safari, but not in IE8 look to IE8 as the problem. It is
    RE: DNN site automatically redirects to a different domain name. by Joseph Craig
    Make a copy what is in the portalalias table and then remove all but the localhost entry. Verify th
    DNN 6.1 app_offline.htm by Dave Hassall
    Hi As recommended I have successfully been using the app_offline.htm whilst performing upgrades t
    RE: DNN site automatically redirects to a different domain name. by imran shaikh
    Hi i have done same as mention in this post my dnn folder name is Trademaxomanupg with
    Enforce Terms Tutorial Update by Vistalogix Corporation
    I tried configuring my DNN 6.1.2 install to have a required "accept terms" checkbox as described in
    RE: Best Practices for Modifying a Custom Module by Joseph Craig
    Start up the development website, then install the module using the package that you have. Then, yo
    Best Practices for Modifying a Custom Module by schilders
    Good Morning, I'm needing to modify a custom built module created by another developer targeted f
    RE: Admin menu problem by alireza arabiyan
    hi in localhost i have http://localhost/senf/خانه.aspx and http://localhost/senf/Admi
    RE: Admin menu problem by Joseph Craig
    Yes, that is what you should have done. What is the URL for your home page? What is the URL for
    RE: Admin menu problem by alireza arabiyan
    hi first in localhost i add my domain.com as portal alias. then copy all files to host , restore my
    RE: Admin menu problem by Joseph Craig
    How did you move it? Have you added an entry in the portalalias table for the site's domain name?
    RE: Re: SQL SERVER 2008 R2 Remote connection by Joseph Craig
    Set up a user with dbo privileges and set the connection string for that user, rather than using Win
    Re: SQL SERVER 2008 R2 Remote connection by Prakasam Srinivasan
    I have successfully configured MSSQL Server 2008 r2 remote connection. I am using windows 7 and it h
    You are not logged in.
    You must log in to access all 
    650+ videos, tutorials, podcasts, and more.
    RSS Feeds