Bug
New Member
- Joined
- Jan 7, 2011
- Messages
- 111
- Reaction score
- 1
My paypal script is not automatic, can someone can help me please?
I hide some values for security
I hide some values for security
Code:
<b>PayPal Shop System.</b><br><br>
The shop costs:<ul><li> 5 EUR (for 80 points)</li><li> 10 EUR (for 160 points)</li><li> 20 EUR (for 350 points)</li><br>
<b>Here are the steps you need to make:</b> <br>
1. A PayPal account with a required balance [5, 10 or 20 EUR] or a creditcard. <br>
2. Fill in your account number. <br>
3. Click on the Buy Now button or your creditcard brand. <br>
4. Make a transaction. <br>
5. After the transaction 6, 14 or 31 points will be automatically added to your account. <br>
6. Go to Item shop and use your points <br> <br> <br> </b>
<span style="color:red">If you recall the money, and your premiumpoints can't be recalled your account will be deleted</span>
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="mail">
<input type="hidden" name="lc" value="US">
<input type="hidden" name="item_name" value="Premium points">
<b>Account name/login:</b> <input type="text" name="custom" value="">
<select name="amount">
<option value="5.00">5 EUR</option>
<option value="10.00">10 EUR</option>
<option value="20.00">20 EUR</option>
</select>
<input type="hidden" name="button_subtype" value="products">
<input type="hidden" name="currency_code" value="EUR">
<input type="hidden" name="no_shipping" value="1">
<input type="hidden" name="currency_code" value="EUR">
<input type="hidden" name="notify_url" value="http://server.net/paypal/ipn/ipn.php">
<input type="hidden" name="return" value="http://server.net/">
<input type="hidden" name="rm" value="0">
<input type="hidden" name="bn" value="PP-BuyNowBF:btn_buynowCC_LG.gif:NonHostedGuest">
<input type="image" src="https://www.paypal.com/en_US/i/btn/btn_buynowCC_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>
Code:
<?php
if(gethostbyaddr($_SERVER['REMOTE_ADDR']) != 'notify.paypal.com')
{
exit();
}
if($_REQUEST['debug'])
{
ini_set('display_errors', true);
error_reporting(E_ALL);
}
// MySQLi connection
$mysql = new mysqli('localhost', 'root', 'pass', 'database');
// Variables, don't touch!
$payer_email = $_REQUEST['payer_email'];
$receiverEmail = $_REQUEST['receiver_email'];
$paymentStatus = $_REQUEST['payment_status'];
$mcGross = $_REQUEST['mc_gross'];
$mcCurrency = $_REQUEST['mc_currency'];
$customValue = stripslashes(ucwords(strtolower(trim($_REQUEST['custom']))));
// Prices
$prices = array('5.00' => 80, '10.00' => 160, '20.00' => 350);
// Setup
$receiver = 'mail';
$currency = 'EUR';
$whatToDo = 1; // 1 - delete, 2 - custom
if($paymentStatus == 'Completed' && $receiverEmail == $receiver && isset($prices[$mcGross]) && $mcCurrency == $currency)
{
$accountId = $mysql->query('SELECT id, premium_points FROM accounts WHERE accounts.name = '.$customValue.'');
$mysql->query('UPDATE `accounts` SET `premium_points` = `premium_points` + ' . $prices[$mc_gross] . ' WHERE `name` = '.$customValue.'');
$mysql->query('INSERT INTO `z_shop_points_bought` (`id`, `amount`, `type`, `accountid`, `code`, `paypalmail`, `date`) VALUES (NULL , '.$prices[$mc_gross].', Paypal, '.$accountId['id'].', '.$mc_gross.', '.$payer_email.', CURRENT_TIMESTAMP);');
}
elseif($paymentStatus == 'Reversed' && $receiverEmail == $receiver)
{
if($whatToDo == 1)
{
$mysql->query('DELETE FROM `accounts` WHERE `name` = "' . $customValue . '"');
}
elseif($whatToDo == 2)
{
// if not deleting, what to do?
}
}
else
{
exit();
}
?>