PHPackages                             lgthomazelli/laravel-pagseguro - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Framework](/categories/framework)
4. /
5. lgthomazelli/laravel-pagseguro

ActiveLibrary[Framework](/categories/framework)

lgthomazelli/laravel-pagseguro
==============================

Biblioteca de integração com o gateway de pagamento PagSeguro.

1.1.2(5y ago)0130MITPHPPHP &gt;=5.4.0

Since Dec 31Pushed 5y agoCompare

[ Source](https://github.com/lgthomazelli/laravel-pagseguro)[ Packagist](https://packagist.org/packages/lgthomazelli/laravel-pagseguro)[ RSS](/packages/lgthomazelli-laravel-pagseguro/feed)WikiDiscussions master Synced yesterday

READMEChangelog (3)Dependencies (5)Versions (17)Used By (0)

Laravel PagSeguro - 1.1
-----------------------

[](#laravel-pagseguro---11)

[![](https://camo.githubusercontent.com/1eb5fed7044de5bbccc041efd5e27f17866fe7ee7ea45531999d7bbbb91a9de8/68747470733a2f2f617469747564652d66696c65732e73332d73612d656173742d312e616d617a6f6e6177732e636f6d2f6c61726176656c5f70616773656775726f2e706e67)](https://camo.githubusercontent.com/1eb5fed7044de5bbccc041efd5e27f17866fe7ee7ea45531999d7bbbb91a9de8/68747470733a2f2f617469747564652d66696c65732e73332d73612d656173742d312e616d617a6f6e6177732e636f6d2f6c61726176656c5f70616773656775726f2e706e67)

[![Build Status](https://camo.githubusercontent.com/db90367bd8d87da58471205bfd7e2032e60738fc1d0df71fa3fb9f6983bb130b/68747470733a2f2f7472617669732d63692e6f72672f6c6774686f6d617a656c6c692f6c61726176656c2d70616773656775726f2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/lgthomazelli/laravel-pagseguro)[![Total Downloads](https://camo.githubusercontent.com/c87dd06eeeecc2068d2040e85d8051a9b44bc5e9f0fdd6f7827a9ac1d956b578/68747470733a2f2f706f7365722e707567782e6f72672f6c6774686f6d617a656c6c692f6c61726176656c70616773656775726f2f646f776e6c6f616473)](https://packagist.org/packages/lgthomazelli/laravelpagseguro)[![Latest Unstable Version](https://camo.githubusercontent.com/cb43fa77060261511add7378c02448c5ae57d124af3037bb107148170061ccf0/68747470733a2f2f706f7365722e707567782e6f72672f6c656170686c792f636172742d62756e646c652f762f756e737461626c652e737667)](//packagist.org/packages/lgthomazelli/laravelpagseguro)[![License](https://camo.githubusercontent.com/3864c0d39439273179ec036bb3fce33aeb169cd758eaa224a261c8490cc1c374/68747470733a2f2f706f7365722e707567782e6f72672f6c656170686c792f636172742d62756e646c652f6c6963656e73652e737667)](https://packagist.org/packages/lgthomazelli/laravelpagseguro)

Esta é uma versão baseada no package original e mantendo a mesma documentação. Nesta versão foi implementado o recebimento de notificações via PIX.
---------------------------------------------------------------------------------------------------------------------------------------------------

[](#esta-é-uma-versão-baseada-no-package-original-e-mantendo-a-mesma-documentaçãonesta-versão-foi-implementado-o-recebimento-de-notificações-via-pix)

O laravel-pagseguro consome a API do PagSeguro e prove uma forma simples de gerar o pagamento, e notificar sobre as suas transações.

Criação e configuração do usuário
---------------------------------

[](#criação-e-configuração-do-usuário)

Antes de você utilizar o Laravel PagSeguro é importante você verificar se o seu usuário do PagSeguro está correto para a integração segue URL de configuração do usuário PagSeguro:

Compatibilidade
---------------

[](#compatibilidade)

PHP &gt;= 5.4 Laravel 5.x

Instalação
----------

[](#instalação)

Abra o arquivo `composer.json` e insira a seguinte instrução:

```
"require": {
    "lgthomazelli/laravelpagseguro": "dev-master"
}

```

**Observação**: Para a versão 5.1 do laravel ou abaixo especifique a versão **0.4.1** ao invés de utilizar **dev-master**

Após inserir no require o `Laravel PagSeguro`, você deverá executar o comando:

```
composer update

```

Ou execute o comando:

```
composer require lgthomazelli/laravelpagseguro:dev-master

```

Configuração do Service Provider
--------------------------------

[](#configuração-do-service-provider)

Abra o arquivo `config/app.php` e adicione no array `providers` a seguinte instrução:

```
laravel\pagseguro\Platform\Laravel5\ServiceProvider::class
```

Aliases do package
------------------

[](#aliases-do-package)

Em seu arquivo `config/app.php` adicione no array `aliases` a seguinte instrução:

```
'PagSeguro' => laravel\pagseguro\Platform\Laravel5\PagSeguro::class
```

Criação do configurador
-----------------------

[](#criação-do-configurador)

Agora você irá executar o comando:

```
php artisan vendor:publish
```

Se tudo ocorreu bem, a seguinte mensagem sera exibida:

```
Copied File [/vendor/lgthomazelli/laravelpagseguro/src/laravel/pagseguro/Config/laravelpagseguro.php] To [/config/laravelpagseguro.php]
```

Ajuste da configuração
----------------------

[](#ajuste-da-configuração)

Abra o arquivo `config/laravelpagseguro.php` altere o `token` e também o `e-mail` informando o da sua loja:

```
    'credentials' => array(//SETA AS CREDENCIAIS DE SUA LOJA
        'token' => null,
        'email' => null,
    )
```

Proxy
-----

[](#proxy)

Caso você precise de proxy para utilizar a Laravel PagSeguro descomente e configure a linha de http adapter:

```
'http' => [
    'adapter' => [
        'type' => 'curl',
        'options' => [
            CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_0,
            // CURLOPT_PROXY => 'http://user:pass@host:port', // PROXY OPTION  [
        [
            'id' => '18',
            'description' => 'Item Um',
            'quantity' => '1',
            'amount' => '1.15',
            'weight' => '45',
            'shippingCost' => '3.5',
            'width' => '50',
            'height' => '45',
            'length' => '60',
        ],
        [
            'id' => '19',
            'description' => 'Item Dois',
            'quantity' => '1',
            'amount' => '3.15',
            'weight' => '50',
            'shippingCost' => '8.5',
            'width' => '40',
            'height' => '50',
            'length' => '80',
        ],
    ],
    'shipping' => [
        'address' => [
            'postalCode' => '06410030',
            'street' => 'Rua Leonardo Arruda',
            'number' => '12',
            'district' => 'Jardim dos Camargos',
            'city' => 'Barueri',
            'state' => 'SP',
            'country' => 'BRA',
        ],
        'type' => 2,
        'cost' => 30.4,
    ],
    'sender' => [
        'email' => 'sender@gmail.com',
        'name' => 'Isaque de Souza Barbosa',
        'documents' => [
            [
                'number' => '01234567890',
                'type' => 'CPF'
            ]
        ],
        'phone' => [
            'number' => '985445522',
            'areaCode' => '11',
        ],
        'bornDate' => '1988-03-21',
    ]
];
```

Após ter os dados, utilize o método: `createFromArray` para criar o objeto de checkout:

```
$checkout = PagSeguro::checkout()->createFromArray($data);
```

Para confirmar o envio utilize o método: `send` da seguinte forma:

```
$checkout = PagSeguro::checkout()->createFromArray($data);
$credentials = PagSeguro::credentials()->get();
$information = $checkout->send($credentials); // Retorna um objeto de laravel\pagseguro\Checkout\Information\Information
if ($information) {
    print_r($information->getCode());
    print_r($information->getDate());
    print_r($information->getLink());
}
```

Informando metadados de Recarga de celular:

```
// ....
$data['cellphone_charger'] = '+5511980810000';
$checkout = PagSeguro::checkout()->createFromArray($data);
```

Informando metadados para Dados de viagem:

```
// ....
$data['travel'] = [
  'passengers' => [
      [
          'name' => 'Isaque de Souza',
          'cpf' => '40404040411',
          'passport' => '4564897987'
      ],
      [
          'name' => 'Michael Douglas',
          'cpf' => '80808080822',
      ]
  ],
  'origin' => [
      'city' => 'SAO PAULO - SP',
      'airportCode' => 'CGH', // Congonhas
  ],
  'destination' => [
      'city' => 'RIO DE JANEIRO - RJ',
      'airportCode' => 'SDU', // Santos Dumont
  ]
];
$checkout = PagSeguro::checkout()->createFromArray($data);
```

Informando metadados para Jogos:

```
// ....
$data['game'] = [
    'gameName' => 'PS LEGEND',
    'playerId' => 'BR561546S4',
    'timeInGameDays' => 360,
];
$checkout = PagSeguro::checkout()->createFromArray($data);
```

Credenciais
-----------

[](#credenciais)

Para resgatar as credenciais padrões do arquivo você pode usar:

```
$credentials = PagSeguro::credentials()->get();
```

Ou usar credenciais alternativas

```
$credentials = PagSeguro::credentials()->create($token, $email);
```

Consultando uma Transação manualmente
-------------------------------------

[](#consultando-uma-transação-manualmente)

```
$credentials = PagSeguro::credentials()->get();
$transaction = PagSeguro::transaction()->get($code, $credentials);
$information = $transaction->getInformation();
```

Recebendo Notificações de Transação
-----------------------------------

[](#recebendo-notificações-de-transação)

Crie uma rota POST com o nome "pagseguro.notification" (Esta no config)

```
Route::post('/pagseguro/notification', [
    'uses' => '\laravel\pagseguro\Platform\Laravel5\NotificationController@notification',
    'as' => 'pagseguro.notification',
]);
```

Registre um callback (callable) no seu config laravelpagseguro.php

```
'routes' => [
    'notification' => [
        'callback' => ['MyNotificationClass', 'myMethod'], // Callable
        'credential' => 'default',
        'route-name' => 'pagseguro.notification', // Nome da rota
    ],
],
```

Ou ....

```
'routes' => [
    'notification' => [
        'callback' => function ($information) { // Callable
            \Log::debug(print_r($information, 1));
        },
    ],
],
```

Exemplo de callable em uma classe
---------------------------------

[](#exemplo-de-callable-em-uma-classe)

No arquivo de configuração você deverá deixar da seguinte maneira:

```
'notification' => [
  'callback' => ['App\Controllers\PagSeguroController', 'Notification'], // Callable callback to Notification function (notificationInfo) : void {}
  'credential' => 'default', // Callable resolve credential function (notificationCode) : Credentials {}
  'route-name' => 'pagseguro.notification', // Criar uma rota com este nome
],
```

E na controller você deverá criar o método, por exemplo, Notification:

```
public static function Notification($information)
{
    \Log::debug(print_r($information->getStatus()->getCode(), 1));
}
```

Criação de plano de pagamento recorrente
----------------------------------------

[](#criação-de-plano-de-pagamento-recorrente)

A criação de plano de pagamento recorrente inicia com a criação do plano e para isso você deverá criar o seguinte array:

Caso queira ver os objetos de requisição:

```
$plan = [
    'body' => [
        'reference' => 'plano laravel pagseguro',
    ],

    'preApproval' => [
        'name' => 'Plano ouro - mensal',
        'charge' => 'AUTO', // outro valor pode ser MANUAL
        'period' => 'MONTHLY', //WEEKLY, BIMONTHLY, TRIMONTHLY, SEMIANNUALLY, YEARLY
        'amountPerPayment' => '125.00', // obrigatório para o charge AUTO - mais que 1.00, menos que 2000.00
        'membershipFee' => '50.00', //opcional - cobrado com primeira parcela
        'trialPeriodDuration' => 30, //opcional
        'details' => 'Decrição do plano', //opcional
        'expiration' => [ // opcional
            'value' => 1, // obrigatório de 1 a 1000000
            'unit' => 'YEARLY', // obrigatório
        ],
    ]

];
```

E então você deverá chamar o método de criação do plano:

```
$plan = \PagSeguro::plan()->createFromArray($plan);
$credentials = \PagSeguro::credentials()->get();
$information = $plan->send($credentials); // Retorna um objeto de laravel\pagseguro\Checkout\Information\Information
if ($information) {
  print_r($information->getCode());
  print_r($information->getDate());
  print_r($information->getLink());
}
```

Licença
-------

[](#licença)

O Laravel PagSeguro utiliza a licença MIT, para saber mais leia no link: [MIT license](http://opensource.org/licenses/MIT)

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor1

Top contributor holds 55.8% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~159 days

Recently: every ~279 days

Total

15

Last Release

1920d ago

Major Versions

0.6.0 → 1.0.02016-03-03

PHP version history (2 changes)0.3.0PHP &gt;=5.3.0

0.4.0PHP &gt;=5.4.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/c3ca50929947182db544b9b2f8c1c8af9ff2d48987f4f8ed827b1563805debb6?d=identicon)[lgthomazelli](/maintainers/lgthomazelli)

---

Top Contributors

[![michaeldouglas](https://avatars.githubusercontent.com/u/2530054?v=4)](https://github.com/michaeldouglas "michaeldouglas (163 commits)")[![isaquesb](https://avatars.githubusercontent.com/u/3066343?v=4)](https://github.com/isaquesb "isaquesb (74 commits)")[![marabesi](https://avatars.githubusercontent.com/u/2129872?v=4)](https://github.com/marabesi "marabesi (28 commits)")[![lgthomazelli](https://avatars.githubusercontent.com/u/10109914?v=4)](https://github.com/lgthomazelli "lgthomazelli (6 commits)")[![raphaelpaez](https://avatars.githubusercontent.com/u/69905648?v=4)](https://github.com/raphaelpaez "raphaelpaez (4 commits)")[![kaiocesar](https://avatars.githubusercontent.com/u/2325842?v=4)](https://github.com/kaiocesar "kaiocesar (2 commits)")[![aronpc](https://avatars.githubusercontent.com/u/181354?v=4)](https://github.com/aronpc "aronpc (2 commits)")[![crossworth](https://avatars.githubusercontent.com/u/1251151?v=4)](https://github.com/crossworth "crossworth (2 commits)")[![hectordufau](https://avatars.githubusercontent.com/u/12888215?v=4)](https://github.com/hectordufau "hectordufau (2 commits)")[![ibrunotome](https://avatars.githubusercontent.com/u/4256471?v=4)](https://github.com/ibrunotome "ibrunotome (2 commits)")[![JoseNetoooo](https://avatars.githubusercontent.com/u/1051129?v=4)](https://github.com/JoseNetoooo "JoseNetoooo (2 commits)")[![thiivalente](https://avatars.githubusercontent.com/u/29163712?v=4)](https://github.com/thiivalente "thiivalente (2 commits)")[![carusogabriel](https://avatars.githubusercontent.com/u/16328050?v=4)](https://github.com/carusogabriel "carusogabriel (1 commits)")[![TopFuel](https://avatars.githubusercontent.com/u/3332131?v=4)](https://github.com/TopFuel "TopFuel (1 commits)")[![lfserrra](https://avatars.githubusercontent.com/u/10976421?v=4)](https://github.com/lfserrra "lfserrra (1 commits)")

---

Tags

frameworklaravelPagseguroGateway Pagamento

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/lgthomazelli-laravel-pagseguro/health.svg)

```
[![Health](https://phpackages.com/badges/lgthomazelli-laravel-pagseguro/health.svg)](https://phpackages.com/packages/lgthomazelli-laravel-pagseguro)
```

###  Alternatives

[michael/laravelpagseguro

Biblioteca de integração com o gateway de pagamento PagSeguro.

357149.3k1](/packages/michael-laravelpagseguro)[laravel/lumen-framework

The Laravel Lumen Framework.

1.5k26.2M709](/packages/laravel-lumen-framework)[rahulalam31/laravel-abuse-ip

Block ip address of all spammer's around the world.

27431.5k](/packages/rahulalam31-laravel-abuse-ip)[krzysztofrewak/laravel-oop-validator

Laravel Validator object-oriented wrapper

805.8k](/packages/krzysztofrewak-laravel-oop-validator)[laracord/framework

The Laracord Framework.

455.6k1](/packages/laracord-framework)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
