PHP Classes

File: Checkout.php

Recommend this page to a friend!
  Packages of Julio Cezar Kronbauer   Integração PHP PagSeguro   Checkout.php   Download  
File: Checkout.php
Role: Example script
Content type: text/plain
Description: Exemplo de checkout
Class: Integração PHP PagSeguro
Process payments with PagSeguro API
Author: By
Last change: Changed some bugged characters
Date: 13 years ago
Size: 1,448 bytes
 

 

Contents

Class file image Download
<?php

include $_SERVER['DOCUMENT_ROOT'] . '/PagSeguro/PagSeguro.Class.php';

$pedido_id = 813542;

/*    Cria o formulário para direcionar o usuário ao PagSeguro para efetuar o pagamento    */
$url_pagseguro = $PagSeguro->getCheckoutURL('email-vendedor@provedor.com.br',
                                            'TOKEN_DE_SEGURANCA_CRIADO_NO_PAINEL_DO_PAGSEGURO',
                                            'PEDIDO-' . $pedido_id,
                                            'Julio Cezar Kronbauer', 'meuemail@meuprovedor.com.br',
                                            '88', '8888-8888',
                                            PAGSEGURO_SHIPPING_TYPE_SEDEX,
                                            'Endereço do Cliente', '15321', NULL, 'Bairro do Endereço', '88888-888',
                                            'Cidade do Endereço', 'UF', 'Brasil',
                                            array(0 => array('description' => 'Camisa',
                                                             'amount' => 19.90,
                                                             'quantity' => 2,
                                                             'weight' => 150 /* Peso (em gramas) de um item, NÃO É a soma do peso dos itens */),
                                                  1 => array('description' => 'Calça',
                                                             'amount' => 89.90,
                                                             'quantity' => 1,
                                                             'weight' => 490)),
                                            'http://www.seusite.com.br/finalizar-compra/pedido/' . $pedido_id);

if ($url_pagseguro['error_code'] == 0) {
    @header("location: " . $url_pagseguro['checkout_URL']);

    echo '<script type="text/javascript">
        <!--
            location.href = "' . $url_pagseguro['checkout_URL'] . '";
        -->
        </script>';
}
/*    =================================================================================    */

?>