[pm-h] Problem Communicating with PayPal

B. Estrade estrabd at gmail.com
Sat Aug 13 09:44:20 PDT 2011


I am not sure if this is what you're looking for, but I've played
around with IPN before have settled on this snippet to simulate
payment processing through the sandbox. I've never used it in
production. You can't use any module that hijacks STDIN with this,
like CGI.pm or the like. The validation postback to PayPal also serves
as a way to tell PayPal to stop sending the IPN.
 
## PayPal verification URL (note, sandbox)
my $PP_WEBSCR = 'https://www.sandbox.paypal.com/cgi-bin/webscr';

my $query  = '';
my $status = '';

read( STDIN, $query, $ENV{'CONTENT_LENGTH'} );
$query .= '&cmd=_notify-validate';

## Verify IPN with PayPal
# post back to PayPal system to validate
my $ua = new LWP::UserAgent;
my $req = new HTTP::Request 'POST', $PP_WEBSCR;
$req->content_type('application/x-www-form-urlencoded');
$req->content($query);
my $result = $ua->request($req);

#-- handle unverified transaction and
$status = $result->content;

if ( $status ne 'VERIFIED' ) {
  # handle failed verification
}

Hope that helps.

Brett

On Sat, Aug 13, 2011 at 10:45:58AM -0500, Fraser Baker wrote:
> Hi Y'all:
> 
> Wish I had brought up this issue at the last meeting.
> 
> I am accepting payment via PayPal. When payment is received, PayPal sends a response (IPN) to me which I use to initialize a new client's account. PayPal expects a successful result, otherwise PayPal keeps sending the IPN, which I can't have.
> 
> So, how do I execute the Perl code that initializes the account and then closes properly, sending a successful execution?
> 
> I have used a .pl without any response ... not good. Works but PayPal keeps sending the IPN.
> I have used a .cgi that opens and closes an empty window. Somehow this screws up the initialization but PayPal is happy with that.
> 
> And there could be something else going on that I am totally unaware of.
> 
> Any comments?
> 
> Fraser
> _______________________________________________
> Houston mailing list
> Houston at pm.org
> http://mail.pm.org/mailman/listinfo/houston
> Website: http://houston.pm.org/

-- 
B. Estrade <estrabd at gmail.com>


More information about the Houston mailing list