PHP code example of f5sistemas / laravel-pagseguro
1. Go to this page and download the library: Download f5sistemas/laravel-pagseguro library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
f5sistemas / laravel-pagseguro example snippets
laravel\pagseguro\Platform\Laravel5\ServiceProvider::class
'PagSeguro' => laravel\pagseguro\Platform\Laravel5\PagSeguro::class
php artisan vendor:publish
Copied File [/vendor/michael/laravelpagseguro/src/laravel/pagseguro/Config/laravelpagseguro.php] To [/config/laravelpagseguro.php]
'credentials' => array(//SETA AS CREDENCIAIS DE SUA LOJA
'token' => null,
'email' => null,
)
'http' => [
'adapter' => [
'type' => 'curl',
'options' => [
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_0,
// CURLOPT_PROXY => 'http://user:pass@host:port', // PROXY OPTION <<--
]
],
],
$data = [
'items' => [
[
'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' => '[email protected] ',
'name' => 'Isaque de Souza Barbosa',
'documents' => [
[
'number' => '01234567890',
'type' => 'CPF'
]
],
'phone' => '11985445522',
'bornDate' => '1988-03-21',
]
];
$checkout = PagSeguro::checkout()->createFromArray($data);
$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());
}
// ....
$data['cellphone_charger'] = '+5511980810000';
$checkout = PagSeguro::checkout()->createFromArray($data);
// ....
$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);
// ....
$data['game'] = [
'gameName' => 'PS LEGEND',
'playerId' => 'BR561546S4',
'timeInGameDays' => 360,
];
$checkout = PagSeguro::checkout()->createFromArray($data);
$credentials = PagSeguro::credentials()->get();
$credentials = PagSeguro::credentials()->create($token, $email);
$credentials = PagSeguro::credentials()->get();
$transaction = PagSeguro::transaction()->get($code, $credentials);
$information = $transaction->getInformation();
Route::post('/pagseguro/notification', [
'uses' => '\laravel\pagseguro\Platform\Laravel5\NotificationController@notification',
'as' => 'pagseguro.notification',
]);
'routes' => [
'notification' => [
'callback' => ['MyNotificationClass', 'myMethod'], // Callable
'credential' => 'default',
'route-name' => 'pagseguro.notification', // Nome da rota
],
],
'routes' => [
'notification' => [
'callback' => function ($information) { // Callable
\Log::debug(print_r($information, 1));
},
],
],