This script is pretty straight forward, easy to configure, future changes and automated payment.
- First go to https://www.paypal.com/cgi-bin/customerprofileweb?cmd=_profile-ipn-notify
- Put there is only link to notofication http://YOUR_DOMAIN/ipn/ipn.php
- Check button to enable.
- Now your system is active
gesior site folder structure
============================
pages folder
paypal.php
ipn folder
ipn.php
custom_scripts folder
paypal
config.php
ipn.php
<?php
if ($_REQUEST['debug']) {
ini_set("display_errors", true);
error_reporting(E_ALL);
}
// GIVE HERE YOUR DB INFO
$mysql_host = 'localhost'; //Leave at localhost
$mysql_user = '-----'; //DB User
$mysql_pass = '-------'; //DB Pass
$mysql_db = '-------'; //DB Name
$file = 'paypal.log'; //Paypal Log Name will be placed in the same location as your ipn.php file
$payer_email = $_REQUEST['payer_email'];
$ip = $_SERVER['REMOTE_ADDR'];
if($ip != "66.211.170.66" && $ip != "216.113.188.202" && $ip != "216.113.188.203" && $ip != "216.113.188.202" && $ip != "173.0.81.1" && $ip != "notify.paypal.com" && $ip != "73.0.81.33" && $ip != "173.0.81.33" ) {
print "Acess restricted";
$hak = fopen("scammer.log", "a");
fwrite($hak, "$ip \r\n");
fclose($hak);
die(0);
}
$time = date("F j, Y, g:i a");
// REMEBER THERE ARE DOTS AND TWO ZEROS
$paylist = array("0.01" => 500, "10.20" => 1000, "20.70" => 2000, "40.80" => 3000);
// connect db
$db = mysql_connect($mysql_host, $mysql_user, $mysql_pass);
$custom = stripslashes(ucwords(strtolower(trim($_REQUEST['custom']))));
$receiver_email = $_REQUEST['receiver_email'];
$payment_status = $_REQUEST['payment_status'];
// currency
$currency = $_REQUEST['mc_currency'];
$mc_gross = $_REQUEST['mc_gross'];
mysql_select_db($mysql_db, $db);
if ($_REQUEST['debug']){
print $payment_status . '\n';
print (isset($paylist[$mc_gross])) ? 1 : 0 . '\n';
print (isset($paylist[$mc_gross])) ? 1 : 0 . '\n';
print $receiver_email . '\n';
print $custom . '\n';
}
// GIVE HERE YOUR MAIL
if ($payment_status == "Completed" && $receiver_email == "PUT YOUR EMAIL" && $currency == "EUR" && isset($paylist[$mc_gross]))
{
$query = "SELECT premium_points FROM accounts WHERE accounts.id = '$custom'";
$result = mysql_query($query);
$prem = mysql_fetch_array($result);
$somecode = "'$time' '$custom' '$payer_email' '$mc_gross' '$ip'\r\n";
// figure out how much to give
$give = $paylist[$mc_gross];
$points = $prem['premium_points'] + $give;
// $points = mysql_query($prem)
$qry2 = "UPDATE accounts SET premium_points = '$points' WHERE accounts.id = '$custom'";
// Log Paypal Transaction
$hak = fopen($file, "a");
fwrite($hak, $somecode);
fclose($hak);
$result2 = mysql_query($qry2);
}
else
{
echo("Error.");
}
?>
config.php
<?php
$paypal_report_url = 'http://pennumbra.ddns.net/ipn/ipn.php'; // <-- url to ipn
$paypal_return_url = 'http://pennumbra.ddns.net/?subtopic=shopsystem'; // shop
$paypal_image = 'https://www.paypalobjects.com/en_US/i/btn/btn_paynow_LG.gif';
$paypal_payment_type = '_xclick'; // '_xclick' (Buy Now) or '_donations'
$paypals[0]['mail'] = 'MAIL'; // your paypal MAIL
$paypals[0]['name'] = '50 Premium points 1,20 EUR';
$paypals[0]['money_amount'] = '1.2';
$paypals[0]['money_currency'] = 'EUR'; // USD, EUR, more codes: https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_api_nvp_currency_codes
$paypals[0]['premium_points'] = 50;
$paypals[1]['mail'] = 'MAIL'; // your paypal MAIL
$paypals[1]['name'] = '100 Premium points 2,40 EUR';
$paypals[1]['money_amount'] = '2.4';
$paypals[1]['money_currency'] = 'EUR'; // USD, EUR, more codes: https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_api_nvp_currency_codes
$paypals[1]['premium_points'] = 100;
$paypals[2]['mail'] = 'MAIL'; // your paypal login
$paypals[2]['name'] = '200 Premium points 4,40 EUR';
$paypals[2]['money_amount'] = '4.4';
$paypals[2]['money_currency'] = 'EUR'; // USD, EUR, more codes: https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_api_nvp_currency_codes
$paypals[2]['premium_points'] = 200;
$paypals[3]['mail'] = 'MAIL'; // your paypal MAIL
$paypals[3]['name'] = '400 Premium points 8,00 EUR';
$paypals[3]['money_amount'] = '8';
$paypals[3]['money_currency'] = 'EUR'; // USD, EUR, more codes: https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_api_nvp_currency_codes
$paypals[3]['premium_points'] = 400;
paypal.php
<?php
if(!defined('INITIALIZED'))
exit;
if($logged)
{
require_once('./custom_scripts/paypal/config.php');
echo '<style>
table
{
border-collapse:collapse;
}
table, td, th
{
border:1px solid black;
}
</style>';
echo '<table class="tabelapaypal" text-align="center" cellpadding="15" >
<tr><td colspan="2"><h2>Automatic PayPal shop system</h2><br><b>Here are the steps you need to make:</b><br>
1. You need a valid creditcard <b>or</b> a PayPal <a href="https://www.paypal.com/signup/account">Create Paypal account</a>account with a required amount of money.<br>
2. Choose how many points you want buy.<br />
3. Click on the donate/buy button.<br>
4. Make a transaction on PayPal.<br>
5. After the transaction points will be automatically added to your account.<br>
6. Go to Item shop Shop and use your points.</b><br /><br /><br /><br /></td></tr>
<tr><td style="width:100%; table-layout: fixed; height: 50px;" colspan="2" ><b>Select offer:</b></td></tr>
';
foreach($paypals as $paypal)
{
echo '<tr "><td>Buy ' . $paypal['premium_points'] . ' premium points for ' . $paypal['money_amount'] . ' ' . $paypal['money_currency'] . '</td><td style="text-align:center"><form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="' . $paypal_payment_type . '">
<input type="hidden" name="business" value="' . $paypal['mail'] . '">
<input type="hidden" name="item_name" value="' . htmlspecialchars($paypal['name']) . '">
<input type="hidden" name="custom" value="' . $account_logged->getID() . '">
<input type="hidden" name="amount" value="' . htmlspecialchars($paypal['money_amount']) . '">
<input type="hidden" name="currency_code" value="' . htmlspecialchars($paypal['money_currency']) . '">
<input type="hidden" name="no_note" value="0">
<input type="hidden" name="no_shipping" value="1">
<input type="hidden" name="notify_url" value="' . $paypal_report_url . '">
<input type="hidden" name="return" value="' . $paypal_return_url . '">
<input type="hidden" name="rm" value="0">
<input type="image" src="' . $paypal_image . '" border="0" name="submit" alt="PayPal - The safer, easier way to pay online.">
</form></td></tr> ';
}
echo '</table> <br><br><br><br>';
}
else
echo 'You are not logged in. Login first to buy points.';
Now login on page. goto
This script is pretty straight forward, easy to configure, future changes and automated payment.
- First go to https://www.paypal.com/cgi-bin/customerprofileweb?cmd=_profile-ipn-notify
- Put there is only link to notofication
http://YOUR_DOMAIN/ipn/ipn.php
- Check button to enable.
- Now your system is active
````
gesior site folder structure
============================
pages folder
paypal.php
ipn folder
ipn.php
custom_scripts folder
paypal
config.php
````
ipn.php
````
<?php
if ($_REQUEST['debug']) {
ini_set("display_errors", true);
error_reporting(E_ALL);
}
// GIVE HERE YOUR DB INFO
$mysql_host = 'localhost'; //Leave at localhost
$mysql_user = '-----'; //DB User
$mysql_pass = '-------'; //DB Pass
$mysql_db = '-------'; //DB Name
$file = 'paypal.log'; //Paypal Log Name will be placed in the same location as your ipn.php file
$payer_email = $_REQUEST['payer_email'];
$ip = $_SERVER['REMOTE_ADDR'];
if($ip != "66.211.170.66" && $ip != "216.113.188.202" && $ip != "216.113.188.203" && $ip != "216.113.188.202" && $ip != "173.0.81.1" && $ip != "notify.paypal.com" && $ip != "73.0.81.33" && $ip != "173.0.81.33" ) {
print "Acess restricted";
$hak = fopen("scammer.log", "a");
fwrite($hak, "$ip \r\n");
fclose($hak);
die(0);
}
$time = date("F j, Y, g:i a");
// REMEBER THERE ARE DOTS AND TWO ZEROS
$paylist = array("0.01" => 500, "10.20" => 1000, "20.70" => 2000, "40.80" => 3000);
// connect db
$db = mysql_connect($mysql_host, $mysql_user, $mysql_pass);
$custom = stripslashes(ucwords(strtolower(trim($_REQUEST['custom']))));
$receiver_email = $_REQUEST['receiver_email'];
$payment_status = $_REQUEST['payment_status'];
// currency
$currency = $_REQUEST['mc_currency'];
$mc_gross = $_REQUEST['mc_gross'];
mysql_select_db($mysql_db, $db);
if ($_REQUEST['debug']){
print $payment_status . '\n';
print (isset($paylist[$mc_gross])) ? 1 : 0 . '\n';
print (isset($paylist[$mc_gross])) ? 1 : 0 . '\n';
print $receiver_email . '\n';
print $custom . '\n';
}
// GIVE HERE YOUR MAIL
if ($payment_status == "Completed" && $receiver_email == "PUT YOUR EMAIL" && $currency == "EUR" && isset($paylist[$mc_gross]))
{
$query = "SELECT premium_points FROM accounts WHERE accounts.id = '$custom'";
$result = mysql_query($query);
$prem = mysql_fetch_array($result);
$somecode = "'$time' '$custom' '$payer_email' '$mc_gross' '$ip'\r\n";
// figure out how much to give
$give = $paylist[$mc_gross];
$points = $prem['premium_points'] + $give;
// $points = mysql_query($prem)
$qry2 = "UPDATE accounts SET premium_points = '$points' WHERE accounts.id = '$custom'";
// Log Paypal Transaction
$hak = fopen($file, "a");
fwrite($hak, $somecode);
fclose($hak);
$result2 = mysql_query($qry2);
}
else
{
echo("Error.");
}
?>
````
config.php
````
<?php
$paypal_report_url = 'http://pennumbra.ddns.net/ipn/ipn.php'; // <-- url to ipn
$paypal_return_url = 'http://pennumbra.ddns.net/?subtopic=shopsystem'; // shop
$paypal_image = 'https://www.paypalobjects.com/en_US/i/btn/btn_paynow_LG.gif';
$paypal_payment_type = '_xclick'; // '_xclick' (Buy Now) or '_donations'
$paypals[0]['mail'] = 'MAIL'; // your paypal MAIL
$paypals[0]['name'] = '50 Premium points 1,20 EUR';
$paypals[0]['money_amount'] = '1.2';
$paypals[0]['money_currency'] = 'EUR'; // USD, EUR, more codes: https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_api_nvp_currency_codes
$paypals[0]['premium_points'] = 50;
$paypals[1]['mail'] = 'MAIL'; // your paypal MAIL
$paypals[1]['name'] = '100 Premium points 2,40 EUR';
$paypals[1]['money_amount'] = '2.4';
$paypals[1]['money_currency'] = 'EUR'; // USD, EUR, more codes: https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_api_nvp_currency_codes
$paypals[1]['premium_points'] = 100;
$paypals[2]['mail'] = 'MAIL'; // your paypal login
$paypals[2]['name'] = '200 Premium points 4,40 EUR';
$paypals[2]['money_amount'] = '4.4';
$paypals[2]['money_currency'] = 'EUR'; // USD, EUR, more codes: https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_api_nvp_currency_codes
$paypals[2]['premium_points'] = 200;
$paypals[3]['mail'] = 'MAIL'; // your paypal MAIL
$paypals[3]['name'] = '400 Premium points 8,00 EUR';
$paypals[3]['money_amount'] = '8';
$paypals[3]['money_currency'] = 'EUR'; // USD, EUR, more codes: https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_api_nvp_currency_codes
$paypals[3]['premium_points'] = 400;
````
paypal.php
````
<?php
if(!defined('INITIALIZED'))
exit;
if($logged)
{
require_once('./custom_scripts/paypal/config.php');
echo '<style>
table
{
border-collapse:collapse;
}
table, td, th
{
border:1px solid black;
}
</style>';
echo '<table class="tabelapaypal" text-align="center" cellpadding="15" >
<tr><td colspan="2"><h2>Automatic PayPal shop system</h2><br><b>Here are the steps you need to make:</b><br>
1. You need a valid creditcard <b>or</b> a PayPal <a href="https://www.paypal.com/signup/account">Create Paypal account</a>account with a required amount of money.<br>
2. Choose how many points you want buy.<br />
3. Click on the donate/buy button.<br>
4. Make a transaction on PayPal.<br>
5. After the transaction points will be automatically added to your account.<br>
6. Go to Item shop Shop and use your points.</b><br /><br /><br /><br /></td></tr>
<tr><td style="width:100%; table-layout: fixed; height: 50px;" colspan="2" ><b>Select offer:</b></td></tr>
';
foreach($paypals as $paypal)
{
echo '<tr "><td>Buy ' . $paypal['premium_points'] . ' premium points for ' . $paypal['money_amount'] . ' ' . $paypal['money_currency'] . '</td><td style="text-align:center"><form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="' . $paypal_payment_type . '">
<input type="hidden" name="business" value="' . $paypal['mail'] . '">
<input type="hidden" name="item_name" value="' . htmlspecialchars($paypal['name']) . '">
<input type="hidden" name="custom" value="' . $account_logged->getID() . '">
<input type="hidden" name="amount" value="' . htmlspecialchars($paypal['money_amount']) . '">
<input type="hidden" name="currency_code" value="' . htmlspecialchars($paypal['money_currency']) . '">
<input type="hidden" name="no_note" value="0">
<input type="hidden" name="no_shipping" value="1">
<input type="hidden" name="notify_url" value="' . $paypal_report_url . '">
<input type="hidden" name="return" value="' . $paypal_return_url . '">
<input type="hidden" name="rm" value="0">
<input type="image" src="' . $paypal_image . '" border="0" name="submit" alt="PayPal - The safer, easier way to pay online.">
</form></td></tr> ';
}
echo '</table> <br><br><br><br>';
}
else
echo 'You are not logged in. Login first to buy points.';
````
Now login on page. goto
http://YOUR_DOMAIN/?subtopic=paypal