diff --git a/buypoints.php b/buypoints.php index eec0fe7..6b4b275 100644 --- a/buypoints.php +++ b/buypoints.php @@ -3,6 +3,7 @@ protect_page(); include 'layout/overall/header.php'; // Import from config: +$pagseguro = $config['pagseguro']; $paypal = $config['paypal']; $prices = $config['paypal_prices']; @@ -54,6 +55,25 @@ if ($paypal['enabled']) { + +

Buy points using Pagseguro:

+
+ + + + + + + + + + +
+
+ + @@ -73,5 +93,5 @@ if ($config['paygol']['enabled'] == true) { Buy Points system disabled.

Sorry, this functionality is disabled.

'; -include 'layout/overall/footer.php'; ?> \ No newline at end of file +if (!$config['paypal']['enabled'] && !$config['paygol']['enabled'] && !$config['pagseguro']['enabled']) echo '

Buy Points system disabled.

Sorry, this functionality is disabled.

'; +include 'layout/overall/footer.php'; ?> diff --git a/config.php b/config.php index 3b7ff5b..426534b 100644 --- a/config.php +++ b/config.php @@ -711,6 +711,32 @@ 30 => 420, // +40% bonus ); + ///////////////// + /// PAGSEGURO /// + ///////////////// + // Write your pagseguro address here, and what currency you want to recieve money in. + $config['pagseguro'] = array( + 'enabled' => true, + 'sandbox' => false, + 'email' => '', // Example: pagseguro@mail.com + 'token' => '', + 'currency' => 'BRL', + 'product_name' => '', + 'price' => 100, // 1 real + 'ipn' => "http://".$_SERVER['HTTP_HOST']."/pagseguro_ipn.php", + 'urls' => array( + 'www' => 'pagseguro.uol.com.br', + 'ws' => 'ws.pagseguro.uol.com.br', + 'stc' => 'stc.pagseguro.uol.com.br' + ) + ); + + if ($config['pagseguro']['sandbox']) { + $config['pagseguro']['urls'] = array_map(function ($item) { + return str_replace('pagseguro', 'sandbox.pagseguro', $item); + }, $config['pagseguro']['urls']); + } + ////////////////// /// PAYGOL SMS /// ////////////////// diff --git a/pagseguro_ipn.php b/pagseguro_ipn.php new file mode 100644 index 0000000..89af36c --- /dev/null +++ b/pagseguro_ipn.php @@ -0,0 +1,114 @@ +reference; + + if ($transaction['completed'] == '1') { + $status = false; + } + + if ($payment->grossAmount == 0.0) $status = false; // Wrong ammount of money + $item = $payment->items->item[0]; + if ($item->amount != ($pagseguro['price'] / 100)) $status = false; + + if ($status) { + // transaction log + mysql_update('UPDATE `znote_pagseguro` SET `completed` = 1 WHERE `transaction` = \'' . $paymentCode . '\''); + + // Process payment + $data = mysql_select_single("SELECT `points` AS `old_points` FROM `znote_accounts` WHERE `account_id`='$custom';"); + + // Give points to user + $new_points = $data['old_points'] + $item->quantity; + mysql_update("UPDATE `znote_accounts` SET `points`='$new_points' WHERE `account_id`='$custom'"); + } + } else if ($paymentStatus == 7) { + mysql_update('UPDATE `znote_pagseguro` SET `completed` = 1 WHERE `transaction` = \'' . $paymentCode . '\' '); + } +?> \ No newline at end of file diff --git a/pagseguro_retorno.php b/pagseguro_retorno.php new file mode 100644 index 0000000..a988915 --- /dev/null +++ b/pagseguro_retorno.php @@ -0,0 +1,108 @@ +status; + $completed = ($transactionStatus != 7) ? 0 : 1; + + $custom = (int) $transaction->reference; + $item = $transaction->items->item[0]; + $points = $item->quantity; + $price = $points * ($pagseguro['price'] / 100); + mysql_insert('INSERT INTO `znote_pagseguro` VALUES (null, \'' . sanitize($transaction->code) . '\', ' . $custom . ', \'' . $price . '\', \'' . $points . '\', ' . $transactionStatus . ', ' . $completed . ')'); + + header('Location: shop.php?callback=processing'); diff --git a/shop.php b/shop.php index e002428..402f803 100644 --- a/shop.php +++ b/shop.php @@ -2,6 +2,10 @@ protect_page(); include 'layout/overall/header.php'; +if (isset($_GET['callback']) && $_GET['callback'] === 'processing') { + echo ''; +} + // Import from config: $shop = $config['shop']; $shop_list = $config['shop_offers'];