Quote:
Originally Posted by joeroberts
you would need something like this and you need to setup IPN in your paypal
this is a code from my phpMyBitTorrent
PHP Code:
<?php // read the post from PayPal system and add 'cmd' $req = 'cmd=_notify-validate';
foreach ($_POST as $key => $value) { $value = urlencode(stripslashes($value)); $req .= "&$key=$value"; }
// post back to PayPal system to validate $header .= "POST /cgi-bin/webscr HTTP/1.0\r\n"; $header .= "Content-Type: application/x-www-form-urlencoded\r\n"; $header .= "Content-Length: " . strlen($req) . "\r\n\r\n"; $fp = fsockopen ('www.paypal.com', 80, $errno, $errstr, 30);
// assign posted variables to local variables $item_name = $_POST['item_name']; $item_number = $_POST['item_number']; $payment_status = $_POST['payment_status']; $payment_amount = $_POST['mc_gross']; $payment_currency = $_POST['mc_currency']; $txn_id = $_POST['txn_id']; $receiver_email = $_POST['receiver_email']; $payer_email = $_POST['payer_email'];
if (!$fp) { // HTTP ERROR } else { fputs ($fp, $header . $req); while (!feof($fp)) { $res = fgets ($fp, 1024); if (strcmp ($res, "VERIFIED") == 0) { if ($receiver_email == $paypal_email){ # $query = "UPDATE ".$db_prefix."_users SET donated = donated + '$payment_amount' where id='$clid'"; # $result = mysql_query($query); $query = "UPDATE ".$db_prefix."_paypal SET reseaved_donations = reseaved_donations + '$payment_amount' "; $result = mysql_query($query); }
header("Location: ".$siteurl.""); } else if (strcmp ($res, "INVALID") == 0) { } } fclose ($fp); } ?>
|
PHP Code:
<?
require "backend/functions.php";
dbconn(true);
// read the post from PayPal system and add 'cmd'
$req = 'cmd=_notify-validate';
foreach ($_POST as $key => $value) {
$value = urlencode(stripslashes($value));
$req .= "&$key=$value";
}
// post back to PayPal system to validate
$header .= "POST /cgi-bin/webscr HTTP/1.0\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= "Content-Length: " . strlen($req) . "\r\n\r\n";
$fp = fsockopen ('www.paypal.com', 80, $errno, $errstr, 30);
// assign posted variables to local variables
$item_name = $_POST['item_name'];
$item_number = $_POST['item_number'];
$payment_status = $_POST['payment_status'];
$payment_amount = $_POST['mc_gross'];
$payment_currency = $_POST['mc_currency'];
$txn_id = $_POST['txn_id'];
$receiver_email = $_POST['receiver_email'];
$payer_email = $_POST['payer_email'];
$paypal_email = $site_config['PAYPALEMAIL'];
$clid = $_POST['custom'];
if (!$fp) {
// HTTP ERROR
} else {
fputs ($fp, $header . $req);
while (!feof($fp)) {
$res = fgets ($fp, 1024);
if (strcmp ($res, "VERIFIED") == 0) {
if ($receiver_email == $paypal_email && $payment_status == "Completed"){
if ($payment_amount == 5)
{$donb = 5368709120; }
elseif ($payment_amount == 10)
{$donb = 10737418240; }
elseif ($payment_amount == 20)
{$donb = 21474836480; }
elseif ($payment_amount == 30)
{$donb = 32212254720; }
elseif ($payment_amount == 40)
{$donb = 42949672960; }
elseif ($payment_amount == 50)
{$donb = 53687091200; }
elseif ($payment_amount == 100)
{$donb = 161061273600; }
else {
$donb = 1073741824*$payment_amount;}
//Set User Invites
if ($payment_amount == 5){
$invites = 1;
}
elseif ($payment_amount == 10){
$invites = 1;
}
elseif ($payment_amount == 20){
$invites = 2;
}
elseif ($payment_amount == 30){
$invites = 3;
}
elseif ($payment_amount == 40){
$invites = 4;
}
elseif ($payment_amount == 50){
$invites = 5;
}
elseif ($payment_amount == 100){
$invites = 10;
}
else {
$invites = 0;
}
if ($payment_amount == 5 || $payment_amount == 10 || $payment_amount == 20 || $payment_amount == 30 || $payment_amount == 40 || $payment_amount == 50 ) {
if ($class <= 4){
$class = 4;
}
$query = "UPDATE users SET donated = donated + '$payment_amount', class=$class, warned ='no', invites = invites + $invites, uploaded = uploaded + $donb where id='$clid'";
$result = mysql_query($query);
}
}
}
else if (strcmp ($res, "INVALID") == 0) {
header("Refresh: 4;url=account-details.php?id=$clid");
}
}
fclose ($fp);
}
?>
this $db_prefix i do not have joe