<?php /* Template Name: [ Pagueseguro Atualiza ] */ require "includes/config.php"; require "includes/dPagSeguro-master/dPagSeguro.inc.php"; $ps = new dPagSeguro($pgemail, $token); $notificInfo = $ps->getNotification($_POST['notificationType'], $_POST['notificationCode']); $acc = array(':transaction_id' => $notificInfo['code']); $account_query = $con->prepare("SELECT `transaction_id`, `account_id`, `Rops` FROM `doacao` WHERE transaction_id = :transaction_id"); $account_query->execute($acc); $account_info = $account_query->fetch(PDO::FETCH_OBJ); if (!empty($account_info)) { $acc = array(':transaction_id' => $notificInfo['code'], ':status' => $notificInfo['status']); $update = array(':Rops' => $account_info->Rops, ':account_id' => $account_info->account_id); $add_compra_query = $con->prepare("UPDATE `doacao`SET `estado` = :status WHERE transaction_id = :transaction_id"); $add_compra_query->execute($acc); $cash_update = $con->prepare("UPDATE `acc_reg_num_db` SET value = value + :Rops WHERE `account_id` = :account_id AND str = '#CASHPOINTS'"); $cash_update->execute($update); }
<?php /* Template Name: [ Pagueseguro Retorno ] */ require "includes/config.php"; require "includes/dPagSeguro-master/dPagSeguro.inc.php"; $ps = new dPagSeguro($pgemail, $token); $transactionInfo = $ps->getTransaction($_GET['transaction_id']); $acc = array(':transaction_id' => $_GET['transaction_id']); $account_query = $con->prepare("SELECT `account_id` FROM `doacao` WHERE transaction_id = :transaction_id"); $account_query->execute($acc); $account_info = $account_query->fetchAll(PDO::FETCH_OBJ); $valores = array(':account_id' => $transactionInfo['reference'], ':valor' => $transactionInfo['grossAmount'], ':Rops' => $transactionInfo['grossAmount'] * $rops_por_real, ':estado' => $transactionInfo['status'], ':transaction_id' => $transactionInfo['code'], ':email' => $transactionInfo['sender']['email']); if (empty($account_info)) { $add_compra_query = $con->prepare("INSERT INTO `doacao`(account_id,valor,Rops,estado,transaction_id,email) VALUES(:account_id, :valor, :Rops, :estado, :transaction_id, :email) "); $add_compra_query->execute($valores); $dados = "Obrigado pela compra!"; } else { $dados = "Verifique suas compras."; } include_once 'includes/functions.php'; $resumo = get_the_excerpt(); get_header(); ?> <section class="conteudo limit"> <aside class="left"> <?php include get_template_directory() . '/includes/menu-left.php'; ?> </aside>
/* Template Name: [ Pagueseguro ] */ include_once 'includes/functions.php'; require "includes/config.php"; require "includes/dPagSeguro-master/dPagSeguro.inc.php"; if (!empty($_POST) and isset($_POST["valor"])) { $acc_id = str_replace($letters, "", $_SESSION['usuario']->account_id); $valor = str_replace($letters, "", $_POST["valor"]); $sendername = str_replace($letters, "", $_POST["senderName"]); $total = $rops_por_real * $valor; $Email = $pgemail; $Token = $token; $pedido = array('reference' => $_SESSION['usuario']->account_id, 'senderEmail' => $Email, 'senderName' => $sendername, 'shippingType' => 3, 'shippingCost' => 0.0, 'redirectUrl' => $site . '/pagseguro_retorno.php'); $produtos = array(); $produtos[] = array('id' => $id_do_item, 'description' => "R\$ " . $valor . " em " . $desc_do_item . " Total " . $total . " de " . $desc_do_item, 'amount' => $valor, 'quantity' => $qtd); $ps = new dPagSeguro($Email, $Token); $goURL = $ps->newPagamento($pedido, $produtos); if ($goURL) { header("Location: {$goURL}"); die; } else { echo "O PagSeguro não aceitou o pedido de compra:\r\n"; foreach ($ps->listErrors() as $errorCode => $errorStr) { echo "{$errorStr} (código {$errorCode})\r\n"; } } } $resumo = get_the_excerpt(); get_header(); ?>