PHP Classes

Integração PHP PagSeguro: Process payments with PagSeguro API

Recommend this page to a friend!
  Info   View files Example   View files View files (3)   DownloadInstall with Composer Download .zip   Reputation   Support forum (1)   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 193 All time: 8,534 This week: 54Up
Version License PHP version Categories
pagseguro 1.0BSD License5.0.0PHP 5, E-Commerce, Web services
Description 

Author

This package is specific mainly for applications used in Brazil Brazil .

This class can process payments with PagSeguro API.

It can take the details of a payment to be sent by a customer of store like the name, email, address, etc.. and sends a HTTP request to PagSeguro API Web servers.

The class generates a URL with the information from PagSeguro API response to redirect the user to the checkout payment page.

The class can also send another HTTP request to the PagSeguro API to retrieve the status of a given payment transaction.

In Portuguese:

Por enquanto, esta classe pode executar as seguintes operações:

- Gerar URL para redirecionar o usuário para a página de checkout para fazer o pagamento por uma dada compra
- Capturar o estado de uma dada transação de pagamento

Picture of Julio Cezar Kronbauer
  Performance   Level  
Name: Julio Cezar Kronbauer <contact>
Classes: 11 packages by
Country: Brazil Brazil
Age: 42
All time rank: 2171144 in Brazil Brazil
Week rank: 312 Up26 in Brazil Brazil Up
Innovation award
Innovation award
Nominee: 1x

Example

<?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>'
;
}
/* ================================================================================= */

?>


  Files folder image Files  
File Role Description
Plain text file PagSeguro.Class.php Class The main file
Accessible without login Plain text file Checkout.php Example Exemplo de checkout
Accessible without login Plain text file Captura.php Example Exemplo de captura

 Version Control Unique User Downloads Download Rankings  
 0%
Total:193
This week:0
All time:8,534
This week:54Up