Web Scripts
[Gesior] Paypal API | OTS Payments script

This script is pretty straight forward, easy to configure, future changes and automated payment.

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

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