473,785 Members | 2,746 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

POST data to external site

I'm working on a shopping cart webapp and I need to perform a form POST of
data to a 3rd party site (a payment processor, StormPay).

I seem to be having problems doing this. I have an image button which when
clicked performs the data validation. After successful validation, I need
the browser to redirect to the payment processer with a form post. How can
I do this?

I have tried a few things, failed. Below were my most 'reasonable
attempts'.

1) Based on the example found at
http://authors.aspalliance.com/steve...netscrape2.asp, I used a
System.Net.WebR equest object, and did successfully POST the data to the
other site, however because the browser does not redirect here, the output
was not seen (other than in my result variable). This of course is not
usable behavior becuase the user needs to see and respond to the output from
the resulting posted data. If I can get the broser to move with the
request, then this is okay - but how?

2) Going back to basics, I thought maybe a response.write would work. Using
the following code failed, as all it did was write the raw code back to the
top of my aspx page.

Response.Write( "<form name='StormPay'
action='https://www.stormpay.co m/stormpay/handle_gen.php' method='POST'
>")
Response.Write( "<input type='hidden' name='test_mode ' value='1' >")
'Testing Flag
Response.Write( "<input type='hidden' name='generic' value='1' >")
Response.Write( "<input type='hidden' name='payee_ema il' value='" &
System.Configur ation.Configura tionSettings.Ap pSettings.Get(" StormPayAccount E
mail") & "' >")
Response.Write( "<input type='hidden' name='product_n ame' value='" &
strProduct_name & "' >")
Response.Write( "<input type='hidden' name='return_UR L' value='" &
System.Configur ation.Configura tionSettings.Ap pSettings.Get(" ReturnURL") & "'
>")
Response.Write( "<input type='hidden' name='cancel_UR L' value='" &
System.Configur ation.Configura tionSettings.Ap pSettings.Get(" CancelURL") & "'
>")
Response.Write( "</form>")
Response.Write( "<script> ")
Response.Write( "document.Storm Pay.submit();")
Response.Write( "</script>")

Thanks for the insight,

Wayne P.
Nov 19 '05 #1
4 2602
The second method is the approach you should take. However, when you are
calling Response.Write, you are writing out a >.

That will show up in the browser as >, so it will be displayed as a '>'
on the screen. You should have something like this:

Response.Write( "<form name='StormPay' action=....>" );

See if that helps you out any. If that doesn't work, post your view source
of the page to make sure the form is rendered properly, etc.

HTH,

bill

"Wayne P." <in******@nospa m-totalink.net> wrote in message
news:el******** ******@TK2MSFTN GP12.phx.gbl...
I'm working on a shopping cart webapp and I need to perform a form POST of
data to a 3rd party site (a payment processor, StormPay).

I seem to be having problems doing this. I have an image button which when clicked performs the data validation. After successful validation, I need
the browser to redirect to the payment processer with a form post. How can I do this?

I have tried a few things, failed. Below were my most 'reasonable
attempts'.

1) Based on the example found at
http://authors.aspalliance.com/steve...netscrape2.asp, I used a System.Net.WebR equest object, and did successfully POST the data to the
other site, however because the browser does not redirect here, the output
was not seen (other than in my result variable). This of course is not
usable behavior becuase the user needs to see and respond to the output from the resulting posted data. If I can get the broser to move with the
request, then this is okay - but how?

2) Going back to basics, I thought maybe a response.write would work. Using the following code failed, as all it did was write the raw code back to the top of my aspx page.

Response.Write( "&lt;form name='StormPay'
action='https://www.stormpay.co m/stormpay/handle_gen.php' method='POST'
&gt;")
Response.Write( "&lt;input type='hidden' name='test_mode ' value='1' &gt;")
'Testing Flag
Response.Write( "&lt;input type='hidden' name='generic' value='1' &gt;")
Response.Write( "&lt;input type='hidden' name='payee_ema il' value='" &
System.Configur ation.Configura tionSettings.Ap pSettings.Get(" StormPayAccount E mail") & "' &gt;")
Response.Write( "&lt;input type='hidden' name='product_n ame' value='" &
strProduct_name & "' &gt;")
Response.Write( "&lt;input type='hidden' name='return_UR L' value='" &
System.Configur ation.Configura tionSettings.Ap pSettings.Get(" ReturnURL") & "' &gt;")
Response.Write( "&lt;input type='hidden' name='cancel_UR L' value='" &
System.Configur ation.Configura tionSettings.Ap pSettings.Get(" CancelURL") & "' &gt;")
Response.Write( "&lt;/form&gt;")
Response.Write( "&lt;script&gt; ")
Response.Write( "document.Storm Pay.submit();")
Response.Write( "&lt;/script&gt;")

Thanks for the insight,

Wayne P.

Nov 19 '05 #2
William F. Robertson, Jr. wrote:
The second method is the approach you should take. However, when you
are calling Response.Write, you are writing out a &gt;.


Hardly. It's an ugly hack that relies on client-side scripting. Why not
simply stream the response received by WebClient to the page's reponse
stream?

Cheers,

--
Joerg Jooss
www.joergjooss.de
ne**@joergjooss .de

Nov 19 '05 #3
But atleast his second solution would work. You solution does not meet his
requirements. He wants the user to be able to respond from the externally
posted site. Using the response from the webclient will not work in this
situation.

You have the server post and get the response from the remote server. The
remote server sends this:

<form action="main.as px" method="post">
....
</form>

Since the user is on http://server.com/order.aspx the form action is set to
"main.aspx" . Since the user's browser will not see the domain change. When
the user responds to the page, it will try to post it to
http://server.com/main.aspx instead of
https://www.stormpay.com/stormpay/main.aspx.

He could, of course, read through the WebClient response stream and manually
adjust the form action attribute, but "simply streaming" the response from
the WebClient will not work.

It might be a "hack", but it is the only method that has been posted on this
thread that will work.

bill

"Joerg Jooss" <jo*********@gm x.net> wrote in message
news:uL******** ******@TK2MSFTN GP11.phx.gbl...
William F. Robertson, Jr. wrote:
The second method is the approach you should take. However, when you
are calling Response.Write, you are writing out a &gt;.


Hardly. It's an ugly hack that relies on client-side scripting. Why not
simply stream the response received by WebClient to the page's reponse
stream?

Cheers,

--
Joerg Jooss
www.joergjooss.de
ne**@joergjooss .de

Nov 19 '05 #4
William F. Robertson, Jr. wrote:
But atleast his second solution would work. You solution does not
meet his requirements. He wants the user to be able to respond from
the externally posted site. Using the response from the webclient
will not work in this situation.
I didn't read that from the original post. I read it again and still think
he just didn't know what to do with the response received by the 3rd party's
site.
You have the server post and get the response from the remote server.
The remote server sends this:

<form action="main.as px" method="post">
...
</form>

Since the user is on http://server.com/order.aspx the form action is
set to "main.aspx" . Since the user's browser will not see the domain
change. When the user responds to the page, it will try to post it to
http://server.com/main.aspx instead of
https://www.stormpay.com/stormpay/main.aspx.

He could, of course, read through the WebClient response stream and
manually adjust the form action attribute, but "simply streaming" the
response from the WebClient will not work.


It does work, but may breaks web forms as you've shown, *if* the site
doesn't use fully qualified URLs. Yet all that hardly matters if the
response just says "Thanks for your transaction".

Of course streaming the full response back is hardly ever going to happen.
It's more likely that you just search for a certain text block in the
original response and insert that text block ("Thanks for your
transaction..." ) on your own page. At the end of the day, this is a poor
man's application integration sceneario using HTML instead of SOAP or some
other web friendly remoting protocol.

Cheers,

--
Joerg Jooss
www.joergjooss.de
ne**@joergjooss .de
Nov 19 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
1789
by: Max M | last post by:
I am using ClientCookie for login on to servers and browsing them as authenticated users. I kept getting "HTTP Error 400: Bad Request" errors when submitting my forms. So I boiled it down to a simple example. When I try to use ClientCookie.urlopen() on my private network with ip numbers like "http://localhost:8081/test_site/logged_in", it works fine. If I try to call the same site through the Internet, with a url like:
2
3124
by: Robert Oschler | last post by:
I am working on a PHP 4 app that interacts with an external authorization server. The external server does "third-party" authorization of users. So I do the following: 1) Each of my PHP scripts has an include file (require_once) that checks to see if the current user has recently been authorized. 2) If not, the user is "handed off" to the external server. I do this by building the necessary URL for authorization and using refresh to...
10
1854
by: Mark | last post by:
Hi All, I could do with some assistance... I am working on an ecommerce site in vb.net (aspx) I have built all my pages that perform the checkout process and gets to a summary screen where you check your data prior to making payment. The problem I have is that the external payment provider requires that I POST (GET is not allowed) the data to them where there site takes over and when complete returns back to the my site.
5
2439
by: Tyler | last post by:
I am developing an application which will allow me to automatically sign into an external website. I can currently do a screen scrape using HTTPWEBREQUEST. However I want to just redirect to the external site. No need to pull back any data. Here is the code I am using. Dim encoding As ASCIIEncoding = New ASCIIEncoding Dim myParams As String = "AccessID=" & sUserID & "&Password=" & sPassword
3
1233
by: Øystein Olsen | last post by:
Hi, I'm in need of help. My web page is built up from nested masterpages. In the page containing the main content i have a form that I want to post to a external site (isapi dll). I want to use serverside scripting to be able to use the validation controls. Using GET to send the data is out of the question, because the data contains username and password that I don't want the browser to store in it's history stack.
0
1343
by: bertkuiken | last post by:
I'm new to .net and c# but have done this before at j2ee and php. All i want is to post a xml file as a string from an external website and retrieve it from the postdata at my c# programming code. Most of the examples online describe the posting of data at an external website, without the code for the external website or examples where the data was posted from an asp page to an asp page. This is the code I used, but reading out of the...
3
8040
by: Yourself | last post by:
Hi, I'm trying to post data to PayPal for a shopping cart, basically I want to replicate a form like the following, but create the variables dynamically from code behind: <form action="https://www.paypal.com/cgi-bin/webscr" method="post"> <input type="hidden" name="cmd" value="_cart"> <input type="hidden" name="upload" value="1"> <input type="hidden" name="business" value="seller@designerfotos.com"> <input type="hidden" name="item_name"
0
965
by: Brad | last post by:
Hi There I have a small ASP (C#) site (.net 2.0). In it, I have a page with some text forms on it. I can post them in the straight HTML, but am having difficulty in posting those fields to an external, 3rd party site. I need to do the work within the C# code as the final data needs to be manipulated before sending to the external site. I've been trying to play with the HttpWebRequest class, but I don't think I am using it correctly. ...
2
2354
by: =?Utf-8?B?YzY3NjIyOA==?= | last post by:
Hi all, When an external resouce programmatically post the XML document as content of http post request, and at server-side, I can read the XML data from http request's body. Just like this example provided by Steven Chen: #Happy Days Are Here Again: Posting XML to the Server http://msdn2.microsoft.com/en-us/library/ms950790.aspx
0
9643
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9480
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8971
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7496
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5380
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4046
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3645
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2877
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.