How to process IPN using Pearl

You just need to add following code into your IPN processing script:

 
$req->uri("https://yoursite.com/affiliate/plugins/PayPal/paypal.php");

$ua->request($req);

Here is the full context of the script:
#!/usr/bin/perl

# 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 data

use LWP::UserAgent; 
use Property;
use CartPayProcess;
use MailSender;

$prop = Property->new();
$prop->load("property.txt");
$pp = CartPayProcess->new( { prop => $prop } ); 

$ua = new LWP::UserAgent;
$req = new HTTP::Request POST, $prop->getProperty("url");
$req->content_type(application/x-www-form-urlencoded);
 $req->content($query);
$res = $ua->request($req);

print "content-type: text/plainnn";
srand (time ^ $$ ^ unpack "%L*", `ps axww | gzip -f`); 

# split posted variables into pairs
@pairs = split( /
$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=();
@item_number=();
@quantity=();
@ind_price=();

$payment_status = $variable{payment_status}; 
$payment_amount = $variable{mc_gross};
$payment_fee = $variable{mc_fee}; 
$payment_currency = $variable{mc_currency};
$txn_id = $variable{txn_id}; 
$receiver_email = $variable{receiver_email};
$payer_email = $variable{payer_email}; 
$first_name = $variable{first_name};
$last_name = $variable{last_name}; 
$payment_type = $variable{payment_type};
$txn_type = $variable{txn_type}; 
$state_name = $variable{address_state};

if($txn_type eq "cart"){
 @item_name = getDataArray("item_name", %variable); 
 @item_number = getDataArray("item_number", %variable);
 @quantity = getDataArray("quantity", %variable); 
 @ind_price = getDataArray("mc_gross_", %variable);

} 

if($txn_type eq "web_accept"){
 push(@item_name, $variable{item_name});
 push(@item_number, $variable{item_number}); 
 push(@quantity, $variable{quantity});
 push(@ind_price, $variable{mc_gross}); 
}

#Validate arrays

if((scalar(@item_name)+scalar(@item_number)+scalar(@quantity)+scalar(@ind_price))/4!=scalar(@ind_price)){
 $pp->processError("The input arrays do not have the same size.

".$query."
"); 
 exit;
}

$receiver_email =~ s/%40/@/g;
$payer_email    =~ s/%40/@/g;

 if ( $res->is_error ) {

 $pp->processError(
 "The IPN script reported a Transaction Network Error " .
$res->error_as_HTML . "
" ); 
}

elsif ( $res->content eq VERIFIED ) {

 # 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 
 if ($pp->testTxnID($txn_id) == 0
 && $receiver_email eq $prop->getProperty("receiveremail") 
 &
}

 if($txn_type eq "web_accept"){
 useBuyButton();
}

# PAP referral integration code
$req->uri("https://www.yoursite.com/Affiliate/plugins/PayPal/paypal.php");
$ua->request($req); 
×