I’m proficient at C++ programming. I can look usually at code in other languages and figure out what it’s doing. I don’t know much Perl, but now I’m forced to use it to help some friends implement their merchant account. I spent a good deal of time last night researching a problem that I have with this implementation. I found similar questions asked in many places, but never really answered. It’s beginning to make me think that what I (and others) want to do is not easy if at all possible, even though I think it should be.
The problem seems like a very simple thing on the surface. Here is an example. A user hits an “order” button on a HTML page. This form POSTs to a Perl script that adds in some login information, a verification key, and an invoice number. This Perl script then needs to POST this data to an off site page belonging to the gateway provider.
So the flow looks like this:
HTML order page (friend’s site) --> Perl script (friend’s site) --> gateway (off site)
I know how to do a simple redirection from the Perl script, but the only way I could include form data would be to use the GET style with the form data appended to the URL. There is some sensitive information that I really don’t want appearing on a browser’s address bar. Besides, the gateway provider specifies POSTed data.
So, my first question is:
1) How do I POST form data from a Perl script to an off site web page?
The typical answer that I see on other boards is, “look up lwpcook.” I did that. Here is the closest thing that I could find in the lwpcook man page:
use LWP::UserAgent;
$ua = LWP::UserAgent->new;
my $req = HTTP::Request->new(POST => ‘http://www.perl.com/cgi-bin/BugGlimpse’);
$req->content_type(‘application/x-www-form-urlencoded’);
$req->content(‘match=www&errors=0’);
my $res = $ua->request($req);
print $res->as_string;
The problem is this leaves the client’s browser at my web site. I need to have the client’s browser actually go to the payment gateway site.
My second question deals with secure servers. The data sent between a secure server and a browser is encrypted, right? Correct me if I’m wrong, but I think it should be secure from the prying eyes of a packet sniffer.
2) Looking at the above example, if the HTML order page and the Perl script are both on a secure server and the gateway server is secure, will the data sent from the Perl script to the gateway server also be encrypted?