1. Go to this page and download the library: Download sudrel/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/ */
sudrel / sdk example snippets
$sudrel = new \Sudrel\Sudrel(['chave' => getenv('SUDREL_API_KEY')]); // sdr_test_... no sandbox
$nota = $sudrel->nfse->emitir([
'empresa_id' => '0b7e6a52-3c1d-4f8e-9a20-5d4c3b2a1f00',
'referencia' => 'PED-1001', // mande sempre: é o que torna seguro repetir
'tomador' => ['documento' => '11222333000181'],
'valor' => '1500.00',
'servico' => ['descricao' => 'Consultoria em sistemas'],
]);
$final = $sudrel->nfse->esperar($nota['id']); // autorizada, rejeitada, falha_transmissao...
$corpo = file_get_contents('php://input');
if (!\Sudrel\Webhooks::verificar($corpo, $_SERVER['HTTP_X_SUDREL_SIGNATURE_V2'] ?? null, $segredo)) {
http_response_code(401);
exit;
}
// Deduplique por $_SERVER['HTTP_X_SUDREL_EVENT_ID'] e responda 2xx rápido.