/* Decoded by unphp.net */ setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); if (!isset($config['MercadoPago']) || !count($config['MercadoPago']) || !count($config['MercadoPago']['options'])) { echo "Mercado Pago is disabled. If you're an admin please configure this script in config.local.php."; return; } if (!extension_loaded('curl')) { error("cURL php extension is not loaded, please install it with following command (on linux):" . " " . "sudo apt-get install php5-curl" . " " . "sudo service apache2 restart" . " " . "for XAMPP (Windows) you need to uncomment (Remove selicolon - ;) this line in your php.ini:" . " " . ";extension=php_curl.dll"); return; } $is_localhost = strpos(BASE_URL, 'localhost') !== false || strpos(BASE_URL, '127.0.0.1') !== false; if ($is_localhost) { warning("Mercado Pago is not supported on localhost (" . BASE_URL . "). Please change your domain to public one and visit this site again later. This site is visible, but you can't donate."); } if (empty($action)) { if (!$logged) { $was_before = $config['friendly_urls']; $config['friendly_urls'] = true; echo 'To buy points you need to be logged. ' . generateLink(getLink('?subtopic=accountmanagement') . '&redirect=' . urlencode(BASE_URL . '?subtopic=pointsmp'), 'Login') . ' first to make a donate.'; $config['friendly_urls'] = $was_before; } else { echo $twig->render('donatemp_2.html.twig', array('is_localhost' => $is_localhost)); } } elseif ($action == 'final') { if ($_REQUEST["merchant_order_id"] != 'null') { // Busca pagamento e verifica status $payment = MercadoPago\MerchantOrder::find_by_id($_REQUEST["merchant_order_id"]); // Verifica a tabela que está sendo utilizada pelo banco de dados para depositar os pontos. $field = 'premium_points'; if (strtolower($config['MercadoPago']['donationType']) == 'coins') { $field = 'coins'; } foreach ($payment->payments as $pay) { // Verifica se está ativado o double points. if ($config['MercadoPago']['doublePoints']) { $quantidade_pontos = $config['MercadoPago']['options'][$pay->transaction_amount] * 2; } else { $quantidade_pontos = $config['MercadoPago']['options'][$pay->transaction_amount]; } $conn->query("UPDATE `mercado_pago_transactions` SET `status` = '" . $pay->status . "' WHERE `mercado_pago_transactions`.`transaction_code` = '" . $_REQUEST['preference_id'] . "'"); if ($pay->status == 'approved') { $stmt = $conn->query('UPDATE accounts SET ' . $field . ' = ' . $field . ' + "' . $quantidade_pontos . '", backup_' . $field . ' = backup_' . $field . ' + "' . $quantidade_pontos . '" WHERE ' . (USE_ACCOUNT_NAME ? 'name' : 'id') . ' = "' . $payment->external_reference . '"'); $conn->query("UPDATE `mercado_pago_transactions` SET `status` = 'ENTREGUE' WHERE `mercado_pago_transactions`.`transaction_code` = '" . $_REQUEST['preference_id'] . "'"); } } } else { $conn->query("UPDATE `mercado_pago_transactions` SET `status` = 'cancelled' WHERE `mercado_pago_transactions`.`transaction_code` = '" . $_REQUEST['preference_id'] . "'"); } // Busca pagamento e verifica status echo $twig->render('donate-finalmp.html.twig'); }',TRUE)); ?>