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; }
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; }
function testOutputProdutos() { $pgs = new pgs(); $pgs->adicionar($this->produto()); $pgs->adicionar($this->produto()); $pgs->adicionar($this->produto() + array('peso' => 120)); $this->assertPattern('/name="item_id_1" value="abc"/', $pgs->mostra(array('print' => false)), "Deve possuir o id"); $this->assertPattern('/name="item_descr_1" value="descr"/', $pgs->mostra(array('print' => false)), "Deve possuir uma descrição"); $this->assertPattern('/name="item_quant_1" value="10"/', $pgs->mostra(array('print' => false)), "Deve possuir a quantidade"); $this->assertPattern('/name="item_valor_1" value="10000"/', $pgs->mostra(array('print' => false)), "Deve possuir o valor formatado"); $this->assertPattern('/name="item_id_2" value="abc"/', $pgs->mostra(array('print' => false)), "Deve possuir o id"); $this->assertPattern('/name="item_descr_2" value="descr"/', $pgs->mostra(array('print' => false)), "Deve possuir uma descrição"); $this->assertPattern('/name="item_quant_2" value="10"/', $pgs->mostra(array('print' => false)), "Deve possuir a quantidade"); $this->assertPattern('/name="item_valor_2" value="10000"/', $pgs->mostra(array('print' => false)), "Deve possuir o valor formatado"); $this->assertPattern('/name="item_peso_3" value="120"/', $pgs->mostra(array('print' => false)), "Deve possuir o peso"); $this->assertPattern('/type="submit"/', $pgs->mostra(array('print' => false)), 'Deve mostrar o submit'); ob_start(); $pgs->mostra(); $print = ob_get_contents(); ob_end_clean(); $this->assertPattern('/form/', $print, 'Deve imprimir por padrão'); $this->assertNoPattern('/<form/', $pgs->mostra(array('print' => false, 'open_form' => false)), 'Não deve mostrar o abre form'); $this->assertNoPattern('@</form@', $pgs->mostra(array('print' => false, 'close_form' => false)), 'Não deve mostrar o fecha form'); $this->assertNoPattern('/type="submit"/', $pgs->mostra(array('print' => false, 'show_submit' => false)), 'Não deve mostrar o submit'); $this->assertPattern('/type="image" src="imagem.jpg"/', $pgs->mostra(array('print' => false, 'img_button' => 'imagem.jpg')), 'Deve implementar a url da imagem'); $this->assertPattern('/type="image" src="https:/', $pgs->mostra(array('print' => false, 'btn_submit' => 1)), 'Deve mostrar um dos submits do PagSeguro'); }
$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> <br> <b>Olá <?php
// Adicionando os funcionarios no carrinho do PagSeguro $a_carrinho = array(); if (count($a_funcionarios_inscritos) > 25) { $total_inscritos = 0; $valor_total_pagamento_unico = 0; foreach ($a_funcionarios_inscritos as $inscrito) { $valor_total_pagamento_unico += $inscrito->valor; $total_inscritos++; } $a_carrinho[] = array("descricao" => "Inscricao " . Funcoes::remove_acentos(NOME_EVENTO) . " - Pagamento Unico ({$total_inscritos} inscricoes tipo Instituicao)", "valor" => $valor_total_pagamento_unico, "peso" => 0, "quantidade" => 1, "id" => $o_empresa->id); } else { foreach ($a_funcionarios_inscritos as $inscrito) { $a_carrinho[] = array("descricao" => "Inscricao " . Funcoes::remove_acentos(NOME_EVENTO) . " - " . trim(Funcoes::remove_acentos(utf8_encode($inscrito->nome))), "valor" => $inscrito->valor, "peso" => 0, "quantidade" => 1, "id" => $inscrito->id); } } $pgs->adicionar($a_carrinho); ?> <!DOCTYPE html> <html lang="pt-br"> <head> <meta charset="utf-8"> <link href="css/estilo.css" rel="stylesheet" /> <style type="text/css"> body { color:#89383f; } </style> </head> <body> <b>Inscrição por Empresa</b> <br><br> <b><?php echo utf8_encode($o_empresa->nome);
<?php # $sql = new PDO('sqlite2:file.sqlite'); # $sql->query('CREATE TABLE "carrinho" ("id" INTEGER PRIMARY KEY NOT NULL, "cod" VARCHAR NOT NULL, "desc" VARCHAR NOT NULL, "qtd" FLOAT NOT NULL, "valor" FLOAT NOT NULL)'); #$sql->query("INSERT INTO /"carrinho/" VALUES(1,'A27','Mapa da cidade',1,'27.9');"); #$sql->query("INSERT INTO /"carrinho/" VALUES(2,'B720','Bala Freegells',12,'.8');"); #$sql->query("INSERT INTO /"carrinho/" VALUES(3,'A90','Caderno decorado',5,'16.30');"); #$sql->query("INSERT INTO /"carrinho/" VALUES(4,'C230','Tomada simples',16,'1.7');"); include 'pgs.php'; $pgs = new pgs(array('email_cobranca' => '*****@*****.**', 'tipo_frete' => 'EN', 'ref_transacao' => 'AFB-580')); $sql = new PDO('sqlite2:file.sqlite'); $carrinho = $sql->query('SELECT * FROM "carrinho"'); foreach ($carrinho as $item) { $item = array('id' => $item['cod'], 'descricao' => $item['desc'], 'quantidade' => $item['qtd'], 'valor' => $item['valor']); $pgs->adicionar($item); } $pgs->mostra(array('btn_submit' => 2));
<?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 ;