Question

I need to send an HTTPS request without using LWP::UserAgent or HTTP::request? What is another method of doing so? This is the request I need to send:

POST https://payflowpro.paypal.com/
Connection: close
Host: payflowpro.paypal.com
Content-Length: 181
Content-Type: text/namevalue
X-VPS-CLIENT-TIMEOUT: 30
X-VPS-REQUEST-ID: 1249403513SNOID
X-VPS-VIT-INTEGRATION-PRODUCT: Product
X-VPS-VIT-INTEGRATION-VERSION: 4.0
X-VPS-VIT-OS-NAME: linux
X-VPS-VIT-OS-VERSION: 2.6.16-gentoo-r13
X-VPS-VIT-RUNTIME-VERSION: 5.008007

EXPDATE[4]=1011&AMT[6]=100.01&ACCT[16]=4111111111111111&TENDER[1]=C&TAXAMT[4]=0.00&PARTNER[8]=******&PWD[9]=******&VENDOR[6]=******&USER[6]=******&TRXTYPE[1]=S&VERBOSITY=MEDIUM
Was it helpful?

Solution 3

Thanks to package reference by Sinan Ünür I was able to accomplish what I needed:

my $host = 'pilot-payflowpro.paypal.com';
my $port = 443;
my $sock = IO::Socket::SSL->new("$host:$port") || die $!;

my $req = 'EXPDATE[4]=1011&AMT[6]=100.01&ACCT[16]=4111111111111111&TENDER[1]=C&TAXAMT[4]=0.00&PARTNER[8]=*****&PWD[9]=******&VENDOR[6]=*****&USER[6]=******&TRXTYPE[1]=S&VERBOSITY=MEDIUM';

print $sock "POST https://$host/ HTTPS/1.1\r\n";
print $sock "Connection: close", "\r\n";
print $sock "Host: ", $host, "\r\n";
print $sock "Content-length: ", length $req, "\r\n";
print $sock "Content-type: text/namevalue\r\n";
print $sock "X-VPS-CLIENT-TIMEOUT: 30", "\r\n";
print $sock "X-VPS-REQUEST-ID: 1249403513SNOID", "\r\n";
print $sock "X-VPS-VIT-INTEGRATION-PRODUCT: Product", "\r\n";
print $sock "X-VPS-VIT-INTEGRATION-VERSION: 4.0", "\r\n";
print $sock "X-VPS-VIT-OS-NAME: linux", "\r\n";
print $sock "X-VPS-VIT-OS-VERSION: 2.6.16-gentoo-r13", "\r\n";
print $sock "X-VPS-VIT-RUNTIME-VERSION: 5.008007", "\r\n\r\n";
print $sock $req, "\r\n\r\n";

print while <$sock>;

close $sock;

OTHER TIPS

Are you looking for README.SSL?

Encryption support is obtained through the use of Crypt::SSLeay or IO::Socket::SSL, which can both be found from CPAN. While libwww-perl has "plug-and-play" support for both of these modules (as of v5.45), the recommended module to use is Crypt::SSLeay.

Look up an SSL library and open the socket yourself, then send the data in.

I'd recommend against that though. Much better to do it properly via one of the modules you mentioned by feeding the module the correct parameters so it will do the request you want.

I'm not sure it's smart to be giving us your paypal request id and other data... The exact data being sent to the server isn't really relevant here; what matters more is the type of error you are getting when you use LWP::UserAgent. You indicated in a previous question that you were getting HTTP 500 errors, which suggests there is something wrong with the recipient, or you are sending data which is being rejected.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top