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'),
);
$erede->transactions($tid)->refunds()->getByTid();
use eRede\Exceptions\eRedeException;
try {
$response = $erede->transactions()->create($transaction);
} catch (eRedeException $e) {
$e->getMessage(); // mensagem da Rede já traduzida
$e->returnCode(); // ex.: '51' (saldo insuficiente)
$e->getCode(); // status HTTP
$e->context(); // dados já sanitizados
}