Runkpapper123
New Member
Yo.
I'm sorry to bother all u fuzzy pandas!
But i'm having a really annoying problem, that I would love to solve asap.. Rep++ for any tries!
The problem:
I am using ModernAAC and having Zaypay v0.2.11 & Paypal as donation options.
Both are having the same problem, they work fine untill a payment are made.. When the payment is made, no points are given to their accounts.
I thought that it would have something to do with the database, but as for Paypal, the payment get loged as Prepared.
So it might not be the database. As for Zaypay, they have approved my website. And I am able to select country and so on.
I have also enabled IPN on my Paypal account.
Notification URL http://araniaot.no-ip.org/paypal/ipn.php
Message delivery Enabled
The database is set correctly,
Zaypay
Paypal:
Paypal IPN.php
Paypal.php
Zaypay Pay.php
I have tried to figure this problem out for days now, havn't made any progress at all.
Thank you for any response!
Regards
Runkpapper
I'm sorry to bother all u fuzzy pandas!
But i'm having a really annoying problem, that I would love to solve asap.. Rep++ for any tries!
The problem:
I am using ModernAAC and having Zaypay v0.2.11 & Paypal as donation options.
Both are having the same problem, they work fine untill a payment are made.. When the payment is made, no points are given to their accounts.
I thought that it would have something to do with the database, but as for Paypal, the payment get loged as Prepared.
So it might not be the database. As for Zaypay, they have approved my website. And I am able to select country and so on.
I have also enabled IPN on my Paypal account.
Notification URL http://araniaot.no-ip.org/paypal/ipn.php
Message delivery Enabled
The database is set correctly,
Zaypay
Code:
$sqlUsername = "Runkpapper";
$sqlPassword = "password";
$sqlHost = "localhost";
$sqlDB = "otserver";
Paypal:
Code:
$mysql_host = 'localhost'; //Leave at localhost
$mysql_user = 'Runkpapper'; //DB User
$mysql_pass = 'password'; //DB Pass
$mysql_db = 'otserver'; //DB Name
$file = '../../paypal.log'; //Paypal Log Name will be placed in the same location as your ipn.php file
Paypal IPN.php
Code:
<?php
if ($_REQUEST['debug']) {
ini_set("display_errors", True);
error_reporting(E_ALL);
}
$mysql_host = 'localhost'; //Leave at localhost
$mysql_user = 'Runkpapper'; //DB User
$mysql_pass = 'password'; //DB Pass
$mysql_db = 'otserver'; //DB Name
$file = '../../paypal.log'; //Paypal Log Name will be placed in the same location as your ipn.php file
// Anti-Scam
$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.204") {
print "Scammer...";
$hak = fopen("scammer.log", "a");
fwrite($hak, "$ip \r\n");
fclose($hak);
die(0);
}
$time = date("F j, Y, g:i a");
$paylist = array("4.00" => 4, "6.00" => 6, "9.00" => 9, "12.00" => 14, "15.00" => 28);
// 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'];
$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 $receiver_email . '\n';
print $custom . '\n';
}
if ($payment_status == "Completed" && $receiver_email == "[email protected]" && isset($paylist[$mc_gross])) {
$query = "SELECT premium_points FROM accounts WHERE accounts.name = '$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.name = '$custom'";
// Log Paypal Transaction
$hak = fopen($file, "a");
fwrite($hak, $somecode);
fclose($hak);
//Everything looks fine, add points and log them.
$result2 = mysql_query($qry2);
$log_data = mysql_query($executepaypallog);
}
else
{
echo("Error.");
}
?>
Paypal.php
Code:
<div class='message'>
<div class='title'>Paypal Donation</div>
<div class='content'>
<?PHP
require("config.php");
$ots = POT::getInstance();
$ots->connect(POT::DB_MYSQL, connection());
$SQL = $ots->getDBHandle();
$light = '#151515';
$dark = '#070707';
{
ECHO '
<h1>Donation Rules</h1>
<textarea rows="5" cols="60" readonly="true">When you donate to Arania Open Tibia, you understand that you cannot demand us to refund your money.
The money we receive will be used to improve our server/services.
*We provide a 100% trustable and automatic service and we personally check every single transaction.</textarea><br>
<font color="red"><i>If you, for any reason, would refund your money, we reserve the rights to ban or delete your account without any further notice.</i></font>
<br>
<h1>Donation Packages (incl. VAT).</h1>
- <b>4 Premium Points</b><br />
[Price: 0.1 EUR]<br />
- <b>9 Premium Points</b><br />
[Price: 9 EUR]<br />
- <b>14 Premium Points</b><br />
[Price: 12 EUR]<br />
- <b>28 Premium Points</b> <b><font color="green">+50% More, Recommended Offer!</font></b><br />
[Price: 15 EUR]<br />
<div align="center">
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_donations">
<input type="hidden" name="business" value="[email protected]">
<input type="hidden" name="lc" value="GB">
<input type="hidden" name="item_name" value="Arania Open Tibia Donation">
<br>
<font color="red"><i>*Put your account number here! or you won\'t get your points</i></font><br>
<b>Account number:</b> <input type="text" name="custom" value="">
<select name="amount">
<option value="0.10">4 EUR</option>
<option value="9.00">9 EUR</option>
<option value="12.00">12 EUR</option>
<option value="15.00">15 EUR</option>
</select>
<input type="hidden" name="currency_code" value="EUR">
<input type="hidden" name="no_note" value="0">
<input type="hidden" name="no_shipping" value="0">
<input type="hidden" name="currency_code" value="EUR">
<input type="hidden" name="notify_url" value="http://araniaot.no-ip.org/paypal/ipn.php">
<input type="hidden" name="return" value="http://araniaot.no-ip.org//index.php/p/v/shop">
<input type="hidden" name="rm" value="0">
<input type="hidden" name="bn" value="PP-DonationsBF:btn_donateCC_LG_global.gif:NonHosted">
<br />
<input type="image" src="https://www.paypal.com/en_US/i/btn/btn_donate_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online.">
<img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form>
<br>
</div>
';
}
?>
</div></div>
Zaypay Pay.php
Code:
<?php
require_once('includes/config.php');
require_once('includes/Zaypay.class.php');
$mysqlConn = $db = mysql_connect($sqlHost, $sqlUsername, $sqlPassword);
mysql_select_db($sqlDB, $mysqlConn);
// Fix ModernAAC support
$sessionAID = ($modernAAC)?'account_id':'account';
// Start session engine
session_start();
// Makesure this is not a guest
if(!isset($_SESSION[$sessionAID]) || !$_SESSION[$sessionAID]) {
die($message_to_guests);
}
// No zaypay object in the first round
if(isset($_GET['option']) || isset($_SESSION['option'])) {
$reset = 0;
if(!isset($_SESSION['option']) || (isset($_SESSION['option']) && isset($GET['option']) && $_SESSION['option'] != $_GET['option'])) {
$_SESSION['option'] = (int)$_GET['option'];
$option = (int)$_SESSION['option'];
$reset = 1;
}
else
$option = (int)$_SESSION['option'];
if(isset($_SESSION['payto']) && !$reset) {
$pay = (int)$_SESSION['payto'];
} else {
$result = mysql_query("SELECT value FROM vapus_payment_storage WHERE name='paid_".$option."_t'");
// doesn't exist, create
if(!mysql_num_rows($result)) {
$total = 0;
mysql_query("INSERT INTO vapus_payment_storage VALUES('paid_".$option."_t', 0)");
} else {
$data = mysql_fetch_assoc($result);
$total = $data["value"];
}
$pay = 0;
for($i=0;$i<sizeof($options[$option]["keys"]); $i++) {
$result = mysql_query("SELECT value FROM vapus_payment_storage WHERE name='paid_".$option."_".$i."'");
// doesn't exist, create
if(!mysql_num_rows($result)) {
$key_total = 0;
mysql_query("INSERT INTO vapus_payment_storage VALUES('paid_".$option."_".$i."', 0)");
} else {
$data = mysql_fetch_assoc($result);
$key_total = $data["value"];
}
if ( $key_total == 0 || ($key_total / $total) * 100 < $options[$option]["split"][$i] ) {
$pay = $i;
// match found, break loop
break;
}
}
$_SESSION['payto'] = $pay;
}
$Zaypay = New Zaypay($options[$option]["keys"][$pay][0], $options[$option]["keys"][$pay][1]);
}
// Fourth step: check payment
if (isset($_POST['action']) && $_POST['action'] == 'paid' && isset($_POST['paymentid'])) {
$zaypay_info = $Zaypay->show_payment($_POST['paymentid']);
$status = $zaypay_info['payment']['status'];
if (isset($zaypay_info['payment']['verification-needed']) and $zaypay_info['payment']['verification-needed'] == 'true' and isset($_POST['verification_code'])) {
if ($zaypay_info = $Zaypay->verification_code($_POST['paymentid'], $_POST['verification_code'])) {
$status = $zaypay_info['payment']['status'];
}
}
if ($status == 'paid') {
include ('./pages/3-paid.php');
$Zaypay->mark_payload_provided($_POST['paymentid']);
}
elseif ($status == 'prepared' or $status == 'in_progress' or $status == 'paused') {
include ('./pages/2-pay.php');
}
else {
echo "An error has occured [{$status}]";
}
}
// Third step: Let consumer pay
elseif (isset($_POST['action']) && $_POST['action'] == 'pay' && isset($_POST['locale']) && isset($_POST['paymentmethod'])) {
if(!($zaypay_info = $Zaypay->create_payment($_POST['locale'], $_POST['paymentmethod']))){
die ($Zaypay->getError());
}
// Here you could insert the payment information into your database. For Example:
$st = mysql_query("INSERT INTO vapus_payment (payID, account_id, status, payer_ip, payto, payopt) VALUES ('{$Zaypay->getPaymentId()}', '".((int)$_SESSION[$sessionAID])."', 'prepared', '{$_SERVER['REMOTE_ADDR']}','{$pay}', '{$option}')");
if(!$st) die(mysql_error());
// drop cookied
setcookie("option", "", time() - 3600);
include ('./pages/2-pay.php');
}
// First step: Let consumer choose country and language
elseif(isset($_GET['option'])) {
if(!($locales = $Zaypay->list_locales())) {
die($Zaypay->getError());
}
if (isset($_POST['locale_country']) and isset($_POST['locale_language'])) {
$Zaypay->setLocale($_POST['locale_language'] . '-' . $_POST['locale_country']);
}
else {
if($noIPCheck || !$Zaypay->locale_for_ip($_SERVER['REMOTE_ADDR']))
$Zaypay->setLocale($defaultCountry);
}
if(!($payment_methods = $Zaypay->list_payment_methods($Zaypay->getLocale()))){
$error = $Zaypay->getError();
include('./pages/1-error.php');
die();
}
include('./pages/1-choosemethod.php');
}
else {
include('./pages/0-option.php');
if(isset($_SESSION['option']))
unset($_SESSION['option']);
if(isset($_SESSION['payto']))
unset($_SESSION['payto']);
}
?>
I have tried to figure this problem out for days now, havn't made any progress at all.
Thank you for any response!
Regards
Runkpapper
Last edited: