Hey all,
I just started using IPN yesterday and been trying to get my perl script working eversince. After a few hours and no luck, I decided to post this message for additional help/suggestions.
Details:
My paypal settings: I'm a verified user, I have IPN activated, I have auto-return option set to 'OFF', my IPN url is correct.
When doing a debug test on the $res, I do end up getting a HTTP1.1/200 status.
Perl Coding: (basically straight from the sample)
#!C:\\Perl\\bin\\perl.exe -w
# read post from PayPal system and add 'cmd'
read (STDIN, $query, $ENV{'CONTENT_LENGTH'});
$query .= '&cmd=_notify-validate';
# post back to PayPal system to validate
use LWP::UserAgent;
$ua = new LWP::UserAgent;
$req = new HTTP::Request 'POST','http://www.paypal.com/cgi-bin/webscr';
$req->content_type('application/x-www-form-urlencoded');
$req->content($query);
$res = $ua->request($req);
# split posted variables into pairs
@pairs = split(/&/, $query);
$count = 0;
foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$variable{$name} = $value;
$count++;
}
# assign posted variables to local variables
$item_name = $variable{'item_name'};
$item_number = $variable{'item_number'};
$payment_status = $variable{'payment_status'};
$payment_amount = $variable{'mc_gross'};
$payment_currency = $variable{'mc_currency'};
$txn_id = $variable{'txn_id'};
$receiver_email = $variable{'receiver_email'};
$payer_email = $variable{'payer_email'};
print "content-type: text/plain\n\n";
if ($res->is_error) {
# HTTP error
}
elsif ($res->content eq 'VERIFIED') {
print "PLEASE work";
# check the $payment_status=Completed
# check that $txn_id has not been previously processed
# check that $receiver_email is your Primary PayPal email
# check that $payment_amount/$payment_currency are correct
# process payment
}
elsif ($res->content eq 'INVALID') {
# log for manual investigation
print "INVALID";
}
else {
print "unknown error";
# error
}
---------------
Debug results:
Original Post from PayPal:
&cmd=_notify-validate
Length of Post From PayPal = 0
------- E N D O F P O S T ----------
PayPal Post Back Response:
Post Back Query = HTTP::Request=HASH(0x1915624)
----------------- HTTP::Response=HASH(0x1bd9ba8) --------------------------
HTTP/1.1 200 OK
Connection: close
Date: Wed, 14 Apr 2004 07:32:46 GMT
Server: Apache/1.3.27 (Unix) mod_ssl/2.8.12 OpenSSL/0.9.7a
Content-Type: text/html; charset=windows-1252
Client-Date: Wed, 14 Apr 2004 07:32:58 GMT
Client-Peer: 64.4.241.33:443
Client-Response-Num: 1
Client-SSL-Cert-Issuer: /O=VeriSign Trust Network/OU=VeriSign, Inc./OU=VeriSign International Server CA - Class 3/OU=www.verisign.com/CPS Incorp.by Ref. LIABILITY LTD.(c)97 VeriSign
Client-SSL-Cert-Subject: /C=US/ST=California/L=Palo Alto/O=Paypal, Inc./OU=Information Systems/OU=Terms of use at
www.verisign.com/rpa (c)00/CN=www.paypal.com
Client-SSL-Cipher: DHE-RSA-AES256-SHA
Client-SSL-Warning: Peer certificate not verified
Client-Transfer-Encoding: chunked
Set-Cookie: cookie_check=yes; expires=Sat, 12-Apr-2014 07:32:46 GMT; path=/; domain=.paypal.com
Set-Cookie: Apache=24.128.79.135.15051081927966453; path=/; expires=Fri, 07-Apr-34 07:32:46 GMT
INVALID
------- E N D O F P O S T B A C K --------
----------------
After a successful transaction, I get an e-mail with the purchase info-including the transaction ID. All seems to go well until it prints "INVALID". aahh
It seems as if Paypal is not posting any variables or my script is not reading the variables being posted. As you can see it is " Length of Post From PayPal = 0"
Can anyone give me suggestions on what I can do to debug ?? What can I be doing wrong?
Thank you,
Anthony