PHP code example of flaviomoreir4 / laravel-transfeera
1. Go to this page and download the library: Download flaviomoreir4/laravel-transfeera 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/ */
flaviomoreir4 / laravel-transfeera example snippets
use FlavioMoreir4\Transfeera\TransfeeraClient;
class PaymentService
{
public function __construct(
private TransfeeraClient $transfeera,
) {}
public function payout(array $transfers): BatchResponseDTO
{
return $this->transfeera->batches()->create([
'name' => 'Lote de pagamentos',
'transfers' => $transfers,
]);
}
}
// Ouvir eventos no EventServiceProvider
use FlavioMoreir4\Transfeera\Events\TransfeeraWebhookReceived;
protected $listen = [
TransfeeraWebhookReceived::class => [
MinhaListener::class,
],
];
use FlavioMoreir4\Transfeera\Exceptions\{
TransfeeraException,
TransfeeraAuthenticationException, // 401
TransfeeraValidationException, // 422 — use $e->getErrors()
TransfeeraRateLimitException, // 429 — use $e->getRetryAfter()
PaymentException, // Erros em Pagamentos
ReceivableException, // Erros em Recebimentos
PixAutomaticoException, // Erros em Pix Automático
ContaCertaException, // Erros em Conta Certa
AccountException, // Erros no Hub de Contas
InfractionException, // Erros em MED/Infrações
};
try {
$batch = Transfeera::batches()->create([...]);
} catch (TransfeeraValidationException $e) {
// Campos inválidos
foreach ($e->getErrors() as $field => $messages) { ... }
} catch (TransfeeraRateLimitException $e) {
// Rate limit — backoff
$retryAfter = $e->getRetryAfter();
$limit = $e->getLimit();
$remaining = $e->getRemaining();
} catch (PaymentException $e) {
// Erro específico de pagamentos
}
// Forçar renovação manual
Transfeera::getConfig(); // ou via TokenManager
// Operar como conta específica
$batches = Transfeera::batches('acc_123')->list();
// Criar recurso em nome de outra conta
$batch = Transfeera::batches('acc_456')->create([
'name' => 'Lote Conta B',
]);