Advertisement
Advertisement
| 11.22.2007 at 06:28AM PST, ID: 22977560 |
|
[x]
Attachment Details
|
||
|
[x]
The Solution Rating System
|
||
With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.
Your Input Matters If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support. Thank you! |
||
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: |
#!/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
use LWP::UserAgent;
$ua = new LWP::UserAgent;
$req = new HTTP::Request 'POST','https://www.sandbox.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
$name_first = $variable('first_name');
$name_last = $variable('last_name');
$address_street = $variable('address_street');
$address_city = $variable('address_city');
$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'};
#assign variables for email
$status = $res->content;
if ($res->is_error) {
# HTTP error
}
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
# process payment
open (MAIL, "|/usr/sbin/sendmail -t -oeq") || die("Could not send
email.\n");
print MAIL "To: payment\@mydomain.co.nz \n";
print MAIL "From: paypal\@mydomain.co.nz \n";
print MAIL "Subject: Payment Verification\n\n";
print MAIL "$name_first \n";
print MAIL "$name_last \n";
print MAIL "$address_street \n";
print MAIL "$address_city \n";
print MAIL "$payment_status \n";
print MAIL "$payment_amount \n";
print MAIL "$payment_currency \n";
print MAIL "$txn_id \n";
print MAIL "$receiver_email \n";
print MAIL "$payer_email \n";
close (MAIL);
}
elsif ($res->content eq 'INVALID') {
# log for manual investigation
open (MAIL, "|/usr/sbin/sendmail -t -oeq") || die("Could not send
email.\n");
print MAIL "To: payment\@mydomain.co.nz \n";
print MAIL "From: paypal\@mydomain.co.nz \n";
print MAIL "Subject: INVALID IPN Notification\n\n";
print MAIL "IPN returned: $status\n\n";
print MAIL "Here is the raw IPN string:\n";
print MAIL "$query\n";
close (MAIL);
}
else {
# error
}
print "content-type: text/plain\n\n";
|