1. Go to this page and download the library: Download owl-code-team/laravel-pix 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/ */
owl-code-team / laravel-pix example snippets
return [
'transaction_currency_code' => 986,
'country_code' => 'BR',
/*
| O PIX precisa definir seu GUI (Global Unique Identifier) para ser utilizado.
*/
'gui' => 'br.gov.bcb.pix',
'country_phone_prefix' => '+55',
/*
* Tamanho do QR code quer será gerado pelo gerador implementado no pacote, em pixels.
*/
'qr_code_size' => 200,
/*
* Você pode definir um middleware para proteger a rota disponibilizada para gerar QR codes.
* O nome registrado para este middleware precisa ser definido aqui.
*/
'create_qr_code_route_middleware' => '',
/*
* Informações do Prestador de serviço de pagamento (PSP) que você está utilizando.
* Você pode utilizar vários psps com este pacote, bastando adicionar um novo array com configurações.
* base_url: URL base da API do seu PSP.
* oauth_bearer_token: Você pode definir o seu Token
*/
'psp' => [
'default' => [
'base_url' => env('LARAVEL_PIX_PSP_BASE_URL'),
'oauth_token_url' => env('LARAVEL_PIX_PSP_OAUTH_URL', false),
'oauth_bearer_token' => env('LARAVEL_PIX_OAUTH2_BEARER_TOKEN'),
'ssl_certificate' => env('LARAVEL_PIX_PSP_SSL_CERTIFICATE'),
'client_secret' => env('LARAVEL_PIX_PSP_CLIENT_SECRET'),
'client_id' => env('LARAVEL_PIX_PSP_CLIENT_ID'),
'authentication_class' => \Junges\Pix\Api\Contracts\AuthenticatesPSPs::class
]
],
];
use Junges\Pix\Pix;
$api = Pix::api()
->clientId('client_id')
->clientSecret('client_secret');
use Junges\Pix\Pix;
// Se você já informou o seu client_id e client_secret no .env, não é necessário informar nesta requisição.
$token = Pix::api()->getOauth2Token()->json();
use Junges\Pix\Pix;
// Se você já informou o seu client_id e client_secret no .env, não é necessário informar nesta requisição.
$token = Pix::api()->certificate('path/to/certificate')->getOauth2Token()->json();
use Junges\Pix\LaravelPix;
public function register()
{
LaravelPix::validatingSslCertificate();
}
namespace App\Pix;
use Junges\Pix\Api\Auth;
class CustomAuthentication extends Auth
{
public function getToken(string $scopes = null)
{
// Metodo para retornar o token de acesso
}
public function getOauthEndpoint() : string{
// Retorna o endpoint que deve ser utilizado para autenticação.
// Você precisa informar a URL completa.
}
}
public function boot()
{
\Junges\Pix\LaravelPix::authenticatesUsing(CustomAuthentication::class);
}
public function boot()
{
\Junges\Pix\LaravelPix::useAsDefaultPsp('your-default-psp-here');
}
use Junges\Pix\Pix;
$cob = Pix::cob()->create('transactionId', $request)->json();
use Junges\Pix\Pix;
$updateCob = Pix::cob()->updateByTransactionId('transactionId', $dataToUpdate)->json();
use Junges\Pix\Pix;
$cob = Pix::cob()->getByTransactionId('transactionId')->json();
use Junges\Pix\Pix;
$cob = Pix::cob()->createWithoutTransactionId($request);
use Junges\Pix\Pix;
use Junges\Pix\Api\Filters\CobFilters;
$filters = (new CobFilters())
->startingAt(now()->subMonth()->toISOString())
->endingAt(now()->addMonth()->toISOString());
$cobs = Pix::cob()->withFilters($filters)->all()->json();
use Junges\Pix\Pix;
use Junges\Pix\Api\Filters\CobvFilters;
$filters = (new CobvFilters())
->startingAt(now()->subMonth()->toISOString())
->endingAt(now()->addMonth()->toISOString());
$cobs = Pix::cobv()->withFilters($filters)->all()->json();
use Junges\Pix\Pix;
use Junges\Pix\Api\Filters\LoteCobvFilter;
$filters = (new LoteCobvFilter())
->startingAt(now()->subMonth()->toISOString())
->endingAt(now()->addMonth()->toISOString());
$batches = Pix::loteCobv()->withFilters($filters)->all()->json();
use Junges\Pix\Pix;
use Junges\Pix\Api\Filters\PayloadLocationFilters;
$filters = (new PayloadLocationFilters())
->startingAt(now()->subMonth()->toISOString())
->endingAt(now()->addMonth()->toISOString());
$locs = Pix::payloadLocation()->withFilters($filters)->all()->json();
use Junges\Pix\Pix;
use Junges\Pix\Api\Filters\ReceivedPixFilters;
$filters = (new ReceivedPixFilters())
->startingAt(now()->subMonth()->toISOString())
->endingAt(now()->addMonth()->toISOString());
$pix = Pix::receivedPix()->withFilters($filters)->all()->json();
use Junges\Pix\Pix;
use Junges\Pix\Api\Filters\WebhookFilters;
$filters = (new WebhookFilters())
->startingAt(now()->subMonth()->toISOString())
->endingAt(now()->addMonth()->toISOString());
$webhooks = Pix::webhook()->withFilters($filters)->all()->json();