PHP code example of tryn-softwares / laravel-pagseguro
1. Go to this page and download the library: Download tryn-softwares/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/ */
tryn-softwares / laravel-pagseguro example snippets
use PagSeguro; //Utilize a Facade
try {
$pagseguro = PagSeguro::setReference('2')
->setSenderInfo([
'senderName' => 'Nome Completo', //Deve conter nome e sobrenome
'senderPhone' => '(32) 1324-1421', //Código de área enviado junto com o telefone
'senderEmail' => '[email protected]',
'senderHash' => 'Hash gerado pelo javascript',
'senderCNPJ' => '98.966.488/0001-00' //Ou CPF se for Pessoa Física
])
->setShippingAddress([
'shippingAddressStreet' => 'Rua/Avenida',
'shippingAddressNumber' => 'Número',
'shippingAddressDistrict' => 'Bairro',
'shippingAddressPostalCode' => '12345-678',
'shippingAddressCity' => 'Cidade',
'shippingAddressState' => 'UF'
])
->setItems([
[
'itemId' => 'ID',
'itemDescription' => 'Nome do Item',
'itemAmount' => 12.14, //Valor unitário
'itemQuantity' => '2', // Quantidade de itens
],
[
'itemId' => 'ID 2',
'itemDescription' => 'Nome do Item 2',
'itemAmount' => 12.14,
'itemQuantity' => '2',
]
])
->send([
'paymentMethod' => 'boleto'
]);
}
catch(\Artistas\PagSeguro\PagSeguroException $e) {
$e->getCode(); //codigo do erro
$e->getMessage(); //mensagem do erro
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.