PHP code example of sysvelox / api-fiscal-sdk

1. Go to this page and download the library: Download sysvelox/api-fiscal-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/ */

    

sysvelox / api-fiscal-sdk example snippets


use SysVelox\Fiscal\Client;

$client = new Client('sk_test_...');

$nota = $client->notas()->emitirNfce([
    'company_id' => 'emp_xxx',
    'payments' => [['method' => 'pix', 'amount_cents' => 1500]],
    'items' => [[
        'description' => 'Pão francês', 'ncm' => '19059090', 'cfop' => '5102',
        'unit' => 'KG', 'quantity' => 2, 'unit_price_cents' => 1290,
        'csosn' => '102', 'cst_pis' => '07', 'cst_cofins' => '07',
    ]],
]);
// Idempotency-Key gerada automaticamente se você não passar uma

echo $nota->status; // "processando"

$nota->aguardarAutorizacao(); // polling até sair de "processando" (ou use webhook)
echo $nota->status; // "autorizado", "rejeitado" ou "contingencia"

use SysVelox\Fiscal\Webhook;

$corpoBruto = file_get_contents('php://input');
$header = $_SERVER['HTTP_X_SYSVELOX_SIGNATURE'];

if (!Webhook::verificar($corpoBruto, $header, $meuWebhookSecret)) {
    http_response_code(401);
    exit;
}