• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

[Gesior] Paypal API | fast&easy working script

Szmycu

Tibiaservers.net
Joined
Sep 2, 2008
Messages
65
Reaction score
5
Location
Poland
This script is pretty straight forward, easy to configure, future changes and automated payment.
  1. First go to https://www.paypal.com/cgi-bin/customerprofileweb?cmd=_profile-ipn-notify
  2. Put there is only link to notofication
    Code:
    http://YOUR_DOMAIN/ipn/ipn.php
  3. Check button to enable.
  4. 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
Code:
<?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
Code:
<?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
Code:
<?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
Code:
http://YOUR_DOMAIN/?subtopic=paypal
 
If it works the payment is received but does not give the player points. Can help me and Thanks
 
I cant make it work =/

I tried changing the ips but they were logged as scammer then i changed them again but nothing happens (yes i have ipn notifications enabled in my paypal settings)
 
Check firewall ports.

I consulted my host and ports are okay, also if they werent i think it wouldnt log the notification as a scammer when i change the ips in the config for non paypal ones, however the problem is that when the payment is made i think some of the info doesnt match the ipn...

When i was checking my ipn messages i saw that &custom = 10, i think that should be the account number?
 
anyone help ?? i have this fully written right, but people dont seem to be getting there points :/ no errors or anything it's say something about a "paypal.log" will appear in my IPN folder i dont have that only ipn.php do i need to make a paypal.log?
 
why don't use gesior's default? its almost the same and doesn't use ipn.
 
I cant make it work =/

I tried changing the ips but they were logged as scammer then i changed them again but nothing happens (yes i have ipn notifications enabled in my paypal settings)
Then Check Ur apypal.html and check the ipn down the script and check it will be fix and fix it to you ip and try make it 0.01 eur and try donate and show and fix the ipn.php fix the point and the amount!.
 
Any updates for gesior 2012, working with ipn 2020? Not add premium points automatically
 
The payment worked, but he didn't add the points automatically, I tried to change it but I couldn't. I use it on my server as tibia coins. How do I add the coins automatically to the table (accounts - coins).
 
Back
Top