Exemplo n.º 1
0
function gateway_pagseguro($seperator, $sessionid)
{
    global $wpdb;
    // Carregando os dados
    $cart = unserialize($_SESSION['wpsc_cart']);
    $options = array('email_cobranca' => get_option('pagseguro_email'), 'ref_transacao' => $_SESSION['order_id'], 'encoding' => 'utf-8', 'item_frete_1' => number_format(($cart->total_tax + $cart->base_shipping) * 100, 0, '', ''));
    // Dados do cliente
    $_cliente = $_POST["collected_data"];
    list($ddd, $telefone) = trataTelefone($_cliente[17]);
    list($end, $num, $compl) = trataEndereco($_cliente[4]);
    $cliente = array('nome' => $_POST["collected_data"][2] . " " . $_cliente[3], 'cep' => preg_replace("/[^0-9]/", "", $_cliente[7]), 'end' => $end, 'num' => $num, 'compl' => $compl, 'bairro' => '', 'cidade' => '', 'uf' => '', 'pais' => 'Brasil', 'ddd' => $ddd, 'tel' => $telefone, 'email' => $_cliente[8]);
    // Usando a session, isso é correto
    $cart = $cart->cart_items;
    $produtos = array();
    foreach ($cart as $item) {
        $produtos[] = array("id" => (string) $item->product_id, "descricao" => $item->product_name, "quantidade" => $item->quantity, "valor" => $item->unit_price);
    }
    $PGS = new pgs($options);
    $PGS->cliente($cliente);
    $PGS->adicionar($produtos);
    $mostra = array("btn_submit" => 0, "print" => false, "open_form" => false, "show_submit" => false);
    $form = $PGS->mostra($mostra);
    $_SESSION["pagseguro_id"] = $sessionid;
    echo '<form id="form_pagseguro" action="https://pagseguro.uol.com.br/security/webpagamentos/webpagto.aspx" method="post">', $form, '<script>window.onload=function(){form_pagseguro.submit();}</script>';
    exit;
}
Exemplo n.º 2
0
function fixedVars()
{
    global $glob, $db, $module, $basket, $ccUserData, $cart_order_id, $config, $GLOBALS, $pgs;
    $curr = $db->select("SELECT * FROM " . $glob['dbprefix'] . "CubeCart_currencies ORDER BY name ASC");
    $fator = 1;
    foreach ($curr as $moeda) {
        if ($moeda["active"] == 1 && $moeda["code"] == $config['defaultCurrency']) {
            $fator = $moeda["value"];
            break;
        }
    }
    $amount = sprintf("%.2f", $basket['subTotal'] * $fator + $basket['tax'] * $fator);
    $pgs = new pgs(array('email_cobranca' => $module['email'], 'ref_transacao' => $cart_order_id));
    $pgs->adicionar(array(array("descricao" => "Cart Order No: " . $cart_order_id, "valor" => $amount, "quantidade" => 1, "id" => base64_encode($cart_order_id), "frete" => intval($basket['shipCost'] * 100 * $fator))));
    $num = null;
    $arrend = split(' ', $ccUserData[0]['add_1']);
    array_reverse(&$arrend);
    foreach ($arrend as $part) {
        if (is_numeric($part)) {
            $num = $part;
            break;
        }
    }
    $ddd = null;
    $tel = $ccUserData[0]['phone'];
    $arrtel = split(' ', str_replace('-', ' ', $ccUserData[0]['phone']));
    if (count($arrtel) > 1) {
        if (strlen($arrtel[0]) == 2) {
            $ddd = array_shift($arrtel);
            $tel = join(' ', $arrtel);
        }
    }
    $pgs->cliente(array('nome' => $ccUserData[0]['firstName'] . ' ' . $ccUserData[0]['lastName'], 'email' => $ccUserData[0]['email'], 'cep' => $ccUserData[0]['postcode'], 'num' => $num, 'compl' => $ccUserData[0]['add_2'], 'ddd' => $ddd, 'tel' => $tel));
    $form = $pgs->mostra(array('print' => false, 'open_form' => false, 'close_form' => false, 'show_submit' => false, 'img_button' => false, 'bnt_submit' => false));
    return $form;
}
Exemplo n.º 3
0
 function testOutputCliente()
 {
     $pgs = new pgs();
     $pgs->cliente($this->cliente());
     foreach ($this->cliente() as $key => $value) {
         $this->assertPattern('/name="cliente_' . $key . '" value="' . $value . '"/', $pgs->mostra(array('print' => false)), "O formulário deve possuir o {$key} do cliente");
     }
 }
$o_individual = new IndividualDAO();
$o_inscricao = new InscricaoDAO();
$o_tipo_inscricao = new TipoInscricaoDAO();
if (!$o_individual->busca($_REQUEST['id'])) {
    die($mensagem_erro);
}
if (!$o_inscricao->busca($o_individual->id_inscricao)) {
    die($mensagem_erro);
}
if (!$o_tipo_inscricao->busca($o_inscricao->id_tipo_inscricao)) {
    die($mensagem_erro);
}
// Criando um novo carrinho no pagseguro
// OBS.: na referencia da transacao sera colocado I(ndividual) e E(mpresa) antes do cpf
$pgs = new pgs(array('email_cobranca' => EMAIL_COBRANCA, 'tipo' => 'CP', 'moeda' => 'BRL', 'ref_transacao' => "I" . $o_individual->id));
$pgs->cliente(array('nome' => Funcoes::remove_acentos(utf8_encode($o_individual->nome)), 'cep' => $o_individual->cep, 'pais' => 'BRA', 'email' => $o_individual->email));
// Adicionando um produto
$pgs->adicionar(array(array("descricao" => "Inscricao " . Funcoes::remove_acentos(NOME_EVENTO), "valor" => $o_tipo_inscricao->valor, "peso" => 0, "quantidade" => 1, "id" => $o_tipo_inscricao->id)));
?>
<!DOCTYPE html>
<html lang="pt-br">
<head>
<meta charset="utf-8">
<link href="css/estilo.css" rel="stylesheet" />
    <style type="text/css">
        body { color:#596b3a; }
    </style>
</head>
<body>
    <b>Inscrição Individual</b>
    <br>
Exemplo n.º 5
0
<?php

include 'pagseguro/pgs.php';
include 'pagseguro/tratadados.php';
// Criando um novo carrinho
$pgs = new pgs(array('email_cobranca' => $processor_data['params']['email'], 'tipo' => 'CP', 'tipo_frete' => $processor_data['params']['tipo_frete'], 'ref_transacao' => $order_info['order_id']));
list($telefone_ddd, $telefone) = trataTelefone($order_info['phone']);
$pgs->cliente(array('nome' => $order_info['s_firstname'] . " " . $order_info['s_lastname'], 'cep' => $order_info['s_zipcode'], 'end' => $order_info['s_address'], 'num' => $order_info[''], 'compl' => $order_info['s_address_2'], 'cidade' => $order_info['s_city'], 'uf' => $order_info[''], 'pais' => $order_info[''], 'ddd' => $telefone_ddd, 'tel' => $telefone, 'email' => $order_info['email']));
$pedido = array();
foreach ($order_info['items'] as $item) {
    $pedido[] = array('id' => $item['item_id'], 'quantidade' => $item['amount'], 'valor' => $item['subtotal'], 'descricao' => strip_tags($item['product']));
}
$extra = array('Frete' => $order_info['shipping_cost'], 'Outras taxas' => $order_info['tax_value']);
foreach ($extra as $k => $v) {
    if (!$v) {
        continue;
    }
    $pedido[] = array('id' => $order_info['order_id'], 'quantidade' => 1, 'valor' => $v, 'descricao' => $k);
}
$pgs->adicionar($pedido);
echo <<<EOT
    <html><head><title></title></head>
    <body onLoad="document.forms[0].submit();">
    {$pgs->mostra(array('show_submit' => false, 'print' => false))}
    </body></html>
EOT
;