1. Go to this page and download the library: Download joshua-barbosa/erede-sdk 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/ */
use eRede\eRede;
class CobrancaService
{
public function __construct(private eRede $erede) {}
}
$erede = new eRede(pv: '...', token: '...', env: 'production');
use eRede\Classes\Transaction;
$transaction = (new Transaction(amount: 149.90, reference: 'pedido-1234'))
->creditCard('5448280000000007', '123', 12, 2030, 'JOAO DA SILVA')
->setInstallments(3)
->setSoftDescriptor('MINHA LOJA');
$response = $erede->transactions()->create($transaction);
$response->getTid();
$response->getReturnCode(); // '00' = aprovada
$response->getAuthorizationCode();
$transaction->capture(false);
$autorizada = $erede->transactions()->create($transaction);
// mais tarde
$erede->transactions($autorizada->getTid())->capture(new Amount(149.90));
use eRede\Classes\Amount;
use eRede\Classes\Url;
$erede->transactions($tid)->refunds()->create(
new Amount(149.90),
new Url('https://minhaloja.com.br/webhooks/erede'), // opcional
);
$erede->transactions($tid)->refunds()->getByTid()->getRefundsList();
$erede->transactions($tid)->refunds()->get($refundId);
use eRede\Classes\Transaction;
$transaction = (new Transaction(amount: 39.00, reference: 'pedido-1234'))
->pix(now()->addMinutes(30)); // expiração: futura e de no máximo 15 dias
$response = $erede->transactions()->create($transaction);
$response->getTid(); // guarde para consultar e devolver
$response->getQrCodeResponse()->getQrCodeData(); // Pix copia e cola (EMV)
$response->getQrCodeResponse()->getQrCodeImage(); // imagem do QR Code em base64
$consulta = $erede->transactions($tid)->get();
if ($qr = $consulta->getQrCodeResponse()) {
$qr->isPending(); // ainda não pago; QR Code segue disponível
} else {
$consulta->getAuthorization()->getStatus(); // 'Approved' (pago) ou 'Canceled' (devolvido)
$consulta->getAuthorization()->getEndToEndId();
$consulta->getRefunds(); // devoluções, se houver
}