Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Perl and PayPal

by tekniko (Deacon)
on Jul 12, 2001 at 20:04 UTC ( [id://96086]=perlquestion: print w/replies, xml ) Need Help??

tekniko has asked for the wisdom of the Perl Monks concerning the following question:

This program allows one to integrate those generous and recurring (in deference to vroom and his efforts) PayPal payments with a website's back-end operations in order to get immediate notification and authentication of the PayPal payments one receives.

As always, does anyone see a better way?

#!/usr/local/bin/perl # read the 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','https://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 $receiver_email = $variable{'receiver_email'}; $item_name = $variable{'item_name'}; $item_number = $variable{'item_number'}; $custom = $variable{'custom'}; $payment_status = $variable{'payment_status'}; $payment_date = $variable{'payment_date'}; $payment_gross = $variable{'payment_gross'}; $payment_fee = $variable{'payment_fee'}; $txn_id = $variable{'txn_id'}; $first_name = $variable{'first_name'}; $last_name = $variable{'last_name'}; $address_street = $variable{'address_street'}; $address_city = $variable{'address_city'}; $address_state = $variable{'address_state'}; $address_zip = $variable{'address_zip'}; $address_country = $variable{'address_country'}; $payer_email = $variable{'payer_email'}; if ($res->content eq 'VERIFIED') { # check transaction for uniqueness # process payment } elsif ($res->content eq 'INVALID') { # possible fraud } else { # error }

Replies are listed 'Best First'.
Re: Perl and PayPal
by footpad (Abbot) on Jul 13, 2001 at 06:02 UTC

    At the very least, it doesn't use warnings, taint mode, or CGI.pm. Personally, I worry about anything that submits prices via hidden variables.

    I recently discussed this bit of code, largely provided by PayPal in their user's manual, in this node. This discussion included a few of my ideas and some thoughts of the others.

    FWIW, searching for "PayPal" would have located the thread in short order.

    --f

Re: Perl and PayPal
by suaveant (Parson) on Jul 12, 2001 at 20:47 UTC
    yeah... and lets you rack up the amount if you so choose... I don't know about the rest of you... but this code worries me, not that I think tekniko is trying to be anything but helpful, but putting a local interface between paypal and me makes me not want to enter my info...

    at least, thats what it looks like this is doing... am I wrong?

                    - Ant

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://96086]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (5)
As of 2024-04-26 08:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found