|
| 1 | +<?php |
| 2 | + |
| 3 | +/** |
| 4 | + * Detailed endpoint documentation |
| 5 | + * https://dev.efipay.com.br/docs/api-pix/pix-automatico#consultar-lista-de-cobranças-de-pix-automático |
| 6 | + */ |
| 7 | + |
| 8 | +$autoload = realpath(__DIR__ . "/../../../../vendor/autoload.php"); |
| 9 | +if (!file_exists($autoload)) { |
| 10 | + die("Autoload file not found or on path <code>$autoload</code>."); |
| 11 | +} |
| 12 | +require_once $autoload; |
| 13 | + |
| 14 | +use Efi\Exception\EfiException; |
| 15 | +use Efi\EfiPay; |
| 16 | + |
| 17 | +$optionsFile = __DIR__ . "/../../../credentials/options.php"; |
| 18 | +if (!file_exists($optionsFile)) { |
| 19 | + die("Options file not found or on path <code>$options</code>."); |
| 20 | +} |
| 21 | +$options = include $optionsFile; |
| 22 | + |
| 23 | +$params = [ |
| 24 | + "inicio" => "2025-01-01T00:00:00Z", |
| 25 | + "fim" => "2025-12-31T23:59:59Z", |
| 26 | + // "idRec" => '00000000000000000000000000001', |
| 27 | + // "cpf" => '11122233344', |
| 28 | + // "cnpj" => '11122233344444', |
| 29 | + // "locationPresente" => true, |
| 30 | + // "status" => 'ATIVA', |
| 31 | + // "convenio" => '0000000000000001', |
| 32 | + // "paginacao.paginaAtual" => 1, |
| 33 | + // "paginacao.itensPorPagina" => 10 |
| 34 | +]; |
| 35 | + |
| 36 | +try { |
| 37 | + $api = new EfiPay($options); |
| 38 | + $response = $api->pixListAutomaticCharge($params); |
| 39 | + |
| 40 | + if (isset($options["responseHeaders"]) && $options["responseHeaders"]) { |
| 41 | + print_r("<pre>" . json_encode($response->body, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) . "</pre>"); |
| 42 | + print_r("<pre>" . json_encode($response->headers, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) . "</pre>"); |
| 43 | + } else { |
| 44 | + print_r("<pre>" . json_encode($response, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) . "</pre>"); |
| 45 | + } |
| 46 | +} catch (EfiException $e) { |
| 47 | + print_r($e->code . "<br>"); |
| 48 | + print_r($e->error . "<br>"); |
| 49 | + print_r($e->errorDescription) . "<br>"; |
| 50 | + if (isset($options["responseHeaders"]) && $options["responseHeaders"]) { |
| 51 | + print_r("<pre>" . json_encode($e->headers, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) . "</pre>"); |
| 52 | + } |
| 53 | +} catch (Exception $e) { |
| 54 | + print_r($e->getMessage()); |
| 55 | +} |
0 commit comments