I am having a problem getting a check string to validate.
I am interfacing with PayPal's Instant Payment Notification (IPN) system where the IPN sends a string to me, I append a var to the end and send it back. The original and the new string are compared and the only difference should be the appended bit at the end.
The transaction is being rejected as the two strings are different in some way.
Could the problem lie with the type of encoding?
Is there a better test I could carry out to determine the problem?
Keith
I am interfacing with PayPal's Instant Payment Notification (IPN) system where the IPN sends a string to me, I append a var to the end and send it back. The original and the new string are compared and the only difference should be the appended bit at the end.
The transaction is being rejected as the two strings are different in some way.
Could the problem lie with the type of encoding?
Is there a better test I could carry out to determine the problem?
Code:
The following code receives and returns the string to IPN. The in and out strings are written to a log file here and then compared later in the script and they are identical apart from the appended cmd string.
#Receive form PP
read (STDIN, $query, $ENV{'CONTENT_LENGTH'});
# Log in string
open (LOG, ">quer.txt") || &errormess;
print LOG "$query\n";
close (LOG);
# Append cmd item
$query .= '&cmd=_notify-validate';
#write out string to log
open (LOG, ">>quer.txt") || &errormess;
print LOG "$query\n";
close (LOG);
# post back to PayPal system to validate
use LWP::UserAgent;
$ua = new LWP::UserAgent;
$req = new HTTP::Request 'POST','[URL unfurl="true"]http://www.paypal.com/cgi-bin/webscr';[/URL]
$req->content_type('application/x-[URL unfurl="true"]www-form-urlencoded');[/URL]
$req->content($query);
$res = $ua->request($req);
Keith