• 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!

Shop system PAYPAL Option doesn't work!?

Tyson12302

New Member
Joined
Aug 6, 2014
Messages
264
Reaction score
4
I've been trying to make this Shop System work but i had no good luck since. I've tried the PayPal Option with a friends PayPal account. Everything went well i clicked on Purchase on the Website it send me to the PayPal page where you send the money. I accepted it on MY account. And i checked if my points arrived and they didnt. Here are some of my codes i have.
shop.php
PHP:
<?php require_once 'engine/init.php';
protect_page();
include 'layout/overall/header.php'; 

// Import from config:
$shop = $config['shop'];
$shop_list = $config['shop_offers'];

if (!empty($_POST['buy'])) {
    $time = time();
    $player_points = (int)$user_znote_data['points'];
    $cid = (int)$user_data['id'];
    // Sanitizing post, setting default buy value
    $buy = false;
    $post = (int)$_POST['buy'];
   
    foreach ($shop_list as $key => $value) {
        if ($key === $post) {
            $buy = $value;
        }
    }
    if ($buy === false) die("Error: Shop offer ID mismatch.");
   
    // Verify that user can afford this offer.
    if ($player_points >= $buy['points']) {
        $data = mysql_select_single("SELECT `points` FROM `znote_accounts` WHERE `account_id`='$cid';");
        if (!$data) die("0: Account is not converted to work with Znote AAC");
        $old_points = $data['points'];
        if ((int)$old_points != (int)$player_points) die("1: Failed to equalize your points.");
        // Remove points if they can afford
        // Give points to user
        $expense_points = $buy['points'];
        $new_points = $old_points - $expense_points;
        $update_account = mysql_update("UPDATE `znote_accounts` SET `points`='$new_points' WHERE `account_id`='$cid'");
       
        $data = mysql_select_single("SELECT `points` FROM `znote_accounts` WHERE `account_id`='$cid';");
        $verify = $data['points'];
        if ((int)$old_points == (int)$verify) die("2: Failed to equalize your points.". var_dump((int)$old_points, (int)$verify, $new_points, $expense_points));
       
        // Do the magic (insert into db, or change sex etc)
        // If type is 2 or 3
        if ($buy['type'] == 2) {
            // Add premium days to account
            user_account_add_premdays($cid, $buy['count']);
            echo '<font color="green" size="4">You now have '.$buy['count'].' additional days of premium membership.</font>';
        } else if ($buy['type'] == 3) {
            // Character Gender
            mysql_insert("INSERT INTO `znote_shop_orders` (`account_id`, `type`, `itemid`, `count`, `time`) VALUES ('$cid', '". $buy['type'] ."', '". $buy['itemid'] ."', '". $buy['count'] ."', '$time')");
            echo '<font color="green" size="4">You now have access to change character gender on your characters. Visit <a href="myaccount.php">My Account</a> to select character and change the gender.</font>';
        } else if ($buy['type'] == 4) {
            // Character Name
            mysql_insert("INSERT INTO `znote_shop_orders` (`account_id`, `type`, `itemid`, `count`, `time`) VALUES ('$cid', '". $buy['type'] ."', '". $buy['itemid'] ."', '". $buy['count'] ."', '$time')");
            echo '<font color="green" size="4">You now have access to change character name on your characters. Visit <a href="myaccount.php">My Account</a> to select character and change the name.</font>';
        } else {
            mysql_insert("INSERT INTO `znote_shop_orders` (`account_id`, `type`, `itemid`, `count`, `time`) VALUES ('$cid', '". $buy['type'] ."', '". $buy['itemid'] ."', '". $buy['count'] ."', '$time')");
            echo '<font color="green" size="4">Your order is ready to be delivered. Write this command in-game to get it: [!shop].<br>Make sure you are in depot and can carry it before executing the command!</font>';
        }
       
        // No matter which type, we will always log it.
        mysql_insert("INSERT INTO `znote_shop_logs` (`account_id`, `player_id`, `type`, `itemid`, `count`, `points`, `time`) VALUES ('$cid', '0', '". $buy['type'] ."', '". $buy['itemid'] ."', '". $buy['count'] ."', '". $buy['points'] ."', '$time')");
       
    } else echo '<font color="red" size="4">You need more points, this offer cost '.$buy['points'].' points.</font>';
    //var_dump($buy);
    //echo '<font color="red" size="4">'. $_POST['buy'] .'</font>';
}

if ($shop['enabled']) {
?>

<h1>Shop Offers</h1>
<?php
if (!empty($_POST['buy'])) {
    if ($user_znote_data['points'] >= $buy['points']) {
        ?><td>You have <?php echo (int)($user_znote_data['points'] - $buy['points']); ?> points. (<a href="buypoints.php">Buy points</a>).</td><?php
    } else {
        ?><td>You have <?php echo $user_znote_data['points']; ?> points. (<a href="buypoints.php">Buy points</a>).</td><?php
    }
} else {
    ?><td>You have <?php echo $user_znote_data['points']; ?> points. (<a href="buypoints.php">Buy points</a>).</td><?php
}
if ($config['shop_auction']['characterAuction']) {
    ?>
    <?php
}
?>
<table>
    <tr class="yellow">
        <td>Description:</td>
        <?php if ($config['shop']['showImage']) { ?><td>Image:</td><?php } ?>
        <td>Count/duration:</td>
        <td>Points:</td>
        <td>Action:</td>
    </tr>
        <?php
        foreach ($shop_list as $key => $offers) {
        echo '<tr class="special">';
        echo '<td>'. $offers['description'] .'</td>';
        if ($config['shop']['showImage']) echo '<td><img src="http://'. $config['shop']['imageServer'] .'/'. $offers['itemid'] .'.'. $config['shop']['imageType'] .'" alt="img"></td>';
        if ($offers['type'] == 2) echo '<td>'. $offers['count'] .' Days</td>';
        else if ($offers['type'] == 3 && $offers['count'] == 0) echo '<td>Unlimited</td>';
        else echo '<td>'. $offers['count'] .'x</td>';
        echo '<td>'. $offers['points'] .'</td>';
        echo '<td>';
        ?>
        <form action="" method="POST">
            <input type="hidden" name="buy" value="<?php echo (int)$key; ?>">
            <input type="submit" value="  PURCHASE  "  class="needconfirmation" data-item-name="<?php echo $offers['description']; ?>" data-item-cost="<?php echo $offers['points']; ?>">
        </form>
        <?php
        echo '</td>';
        echo '</tr>';
        }
        ?>
</table>

<?php if ($shop['enableShopConfirmation']) { ?>
<script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script>
<script>
    $(document).ready(function(){
        $(".needconfirmation").each(function(e){
            $(this).click(function(e){
                var itemname = $(this).attr("data-item-name");
                var itemcost = $(this).attr("data-item-cost");
                var r = confirm("Do you really want to purchase "+itemname+" for "+itemcost+" points?")
                if(r == false){
                    e.preventDefault();
                }           
            });
        });
    });
</script>
<?php }
} else echo '<h1>Buy Points system disabled.</h1><p>Sorry, this functionality is disabled.</p>';
include 'layout/overall/footer.php'; ?>

config.php
DslSIIU.png
 
buypoints.php
PHP:
<?php require_once 'engine/init.php';
protect_page();
include 'layout/overall/header.php'; 

// Import from config:
$paypal = $config['paypal'];
$prices = $config['paypal_prices'];

if ($paypal['enabled']) {
?>

<h1>Buy Points</h1>
<h2>Buy points using Paypal:</h2>
<table id="buypointsTable" class="table table-striped table-hover">
    <tr class="yellow">
        <th>Price:</th>
        <th>Points:</th>
        <?php if ($paypal['showBonus']) { ?>
            <th>Bonus:</th>
        <?php } ?>
        <th>Action:</th>
    </tr>
        <?php
        foreach ($prices as $price => $points) {
        echo '<tr class="special">';
        echo '<td>'. $price .'('. $paypal['currency'] .')</td>';
        echo '<td>'. $points .'</td>';
        if ($paypal['showBonus']) echo '<td>'. calculate_discount(($paypal['points_per_currency'] * $price), $points) .' bonus</td>';
        ?>
        <td>
            <form action="https://www.paypal.com/cgi-bin/webscr" method="POST">
                <input type="hidden" name="cmd" value="_xclick">
                <input type="hidden" name="business" value="<?php echo $paypal['email']; ?>">
                <input type="hidden" name="item_name" value="<?php echo $points .' shop points on '. $config['site_title']; ?>">
                <input type="hidden" name="item_number" value="1">
                <input type="hidden" name="amount" value="<?php echo $price; ?>">
                <input type="hidden" name="no_shipping" value="1">
                <input type="hidden" name="no_note" value="1">
                <input type="hidden" name="currency_code" value="<?php echo $paypal['currency']; ?>">
                <input type="hidden" name="lc" value="GB">
                <input type="hidden" name="bn" value="PP-BuyNowBF">
                <input type="hidden" name="return" value="<?php echo $paypal['success']; ?>">
                <input type="hidden" name="cancel_return" value="<?php echo $paypal['failed']; ?>">
                <input type="hidden" name="rm" value="2">
                <input type="hidden" name="notify_url" value="<?php echo $paypal['ipn']; ?>" />
                <input type="hidden" name="custom" value="<?php echo (int)$session_user_id; ?>">
                <input type="submit" value="  PURCHASE  ">
            </form>
        </td>
        <?php
        echo '</tr>';
        }
        ?>
</table>
<?php } ?>

<?php
if ($config['paygol']['enabled'] == true) {
?>
<!-- PayGol Form using Post method -->
<h2>Buy points using Paygol:</h2>
<?php $paygol = $config['paygol']; ?>
<p><?php echo $paygol['price'] ." ". $paygol['currency'] ."~ for ". $paygol['points'] ." points:"; ?></p>
<form name="pg_frm" method="post" action="http://www.paygol.com/micropayment/paynow" >
    <input type="hidden" name="pg_serviceid" value="<?php echo $paygol['serviceID']; ?>">
    <input type="hidden" name="pg_currency" value="<?php echo $paygol['currency']; ?>">
    <input type="hidden" name="pg_name" value="<?php echo $paygol['name']; ?>">
    <input type="hidden" name="pg_custom" value="<?php echo $session_user_id; ?>">
    <input type="hidden" name="pg_price" value="<?php echo $paygol['price']; ?>">
    <input type="hidden" name="pg_return_url" value="<?php echo $paygol['returnURL']; ?>">
    <input type="hidden" name="pg_cancel_url" value="<?php echo $paygol['cancelURL']; ?>">
    <input type="image" name="pg_button" src="http://www.paygol.com/micropayment/img/buttons/150/black_en_pbm.png" border="0" alt="Make payments with PayGol: the easiest way!" title="Make payments with PayGol: the easiest way!">
</form>
<?php }

if (!$config['paypal']['enabled'] && !$config['paygol']['enabled']) echo '<h1>Buy Points system disabled.</h1><p>Sorry, this functionality is disabled.</p>';
include 'layout/overall/footer.php'; ?>
 
Any good YouTube videos on how to do it? Never mind i set up my IPN on my Paypal anything else i should do?

Just tried again and when ever i recivce a payment i have to accept it and when i do accept it, the account doesn't get the point please help asap.
 
Last edited by a moderator:
You have to get approved by paypal, serach on the forum to find out more.
There have been alot of threads like this.
 
I've already got a Business account and i activated my IPN on Paypal.

But are you approved? Contact paypal in that case.
A business account should require approval since they in most cases have to send the item / check stock etc.
 
Back
Top