Skip to content

Commit 3965fe5

Browse files
✨feat: New examples of Pix automatic cobR endpoints
1 parent 158490b commit 3965fe5

File tree

8 files changed

+370
-0
lines changed

8 files changed

+370
-0
lines changed
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
<?php
2+
3+
/**
4+
* Detailed endpoint documentation
5+
* https://dev.efipay.com.br/docs/api-pix/pix-automatico#criar-cobrança-de-pix-automático-sem-txid
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+
$body = [
24+
"idRec" => "RR000000000000000000000000001",
25+
"infoAdicional" => "Streamming",
26+
"calendario" => [
27+
"dataDeVencimento" => "2026-12-31"
28+
],
29+
"valor" => [
30+
"original" => "0.01"
31+
],
32+
"ajusteDiaUtil" => true,
33+
"devedor" => [
34+
"cep" => "12345678",
35+
"cidade" => "City",
36+
"email" => "client.mail@server.com",
37+
"logradouro" => "Street name 123",
38+
"uf" => "MG"
39+
],
40+
"recebedor" => [
41+
"agencia" => "0001",
42+
"conta" => "00000",
43+
"tipoConta" => "CORRENTE"
44+
]
45+
];
46+
47+
try {
48+
$api = new EfiPay($options);
49+
$response = $api->pixCreateAutomaticCharge($params, $body);
50+
51+
if (isset($options["responseHeaders"]) && $options["responseHeaders"]) {
52+
print_r("<pre>" . json_encode($response->body, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) . "</pre>");
53+
print_r("<pre>" . json_encode($response->headers, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) . "</pre>");
54+
} else {
55+
print_r("<pre>" . json_encode($response, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) . "</pre>");
56+
}
57+
} catch (EfiException $e) {
58+
print_r($e->code . "<br>");
59+
print_r($e->error . "<br>");
60+
print_r($e->errorDescription) . "<br>";
61+
if (isset($options["responseHeaders"]) && $options["responseHeaders"]) {
62+
print_r("<pre>" . json_encode($e->headers, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) . "</pre>");
63+
}
64+
} catch (Exception $e) {
65+
print_r($e->getMessage());
66+
}
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
<?php
2+
3+
/**
4+
* Detailed endpoint documentation
5+
* https://dev.efipay.com.br/docs/api-pix/pix-automatico#criar-cobrança-de-pix-automático-com-txid
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+
"txid" => "00000000000000000000000001"
25+
];
26+
27+
$body = [
28+
"idRec" => "RR000000000000000000000000001",
29+
"infoAdicional" => "Streamming",
30+
"calendario" => [
31+
"dataDeVencimento" => "2026-12-31"
32+
],
33+
"valor" => [
34+
"original" => "0.01"
35+
],
36+
"ajusteDiaUtil" => true,
37+
"devedor" => [
38+
"cep" => "12345678",
39+
"cidade" => "City",
40+
"email" => "client.mail@server.com",
41+
"logradouro" => "Street name 123",
42+
"uf" => "MG"
43+
],
44+
"recebedor" => [
45+
"agencia" => "0001",
46+
"conta" => "00000",
47+
"tipoConta" => "CORRENTE"
48+
]
49+
];
50+
51+
try {
52+
$api = new EfiPay($options);
53+
$response = $api->pixCreateAutomaticChargeTxid($params, $body);
54+
55+
if (isset($options["responseHeaders"]) && $options["responseHeaders"]) {
56+
print_r("<pre>" . json_encode($response->body, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) . "</pre>");
57+
print_r("<pre>" . json_encode($response->headers, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) . "</pre>");
58+
} else {
59+
print_r("<pre>" . json_encode($response, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) . "</pre>");
60+
}
61+
} catch (EfiException $e) {
62+
print_r($e->code . "<br>");
63+
print_r($e->error . "<br>");
64+
print_r($e->errorDescription) . "<br>";
65+
if (isset($options["responseHeaders"]) && $options["responseHeaders"]) {
66+
print_r("<pre>" . json_encode($e->headers, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) . "</pre>");
67+
}
68+
} catch (Exception $e) {
69+
print_r($e->getMessage());
70+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?php
2+
3+
/**
4+
* Detailed endpoint documentation
5+
* https://dev.efipay.com.br/docs/api-pix/pix-automatico#consultar-cobrança-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+
"txid" => "0000000000000000000000000001"
25+
];
26+
27+
try {
28+
$api = new EfiPay($options);
29+
$response = $api->pixDetailAutomaticCharge($params);
30+
31+
if (isset($options["responseHeaders"]) && $options["responseHeaders"]) {
32+
print_r("<pre>" . json_encode($response->body, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) . "</pre>");
33+
print_r("<pre>" . json_encode($response->headers, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) . "</pre>");
34+
} else {
35+
print_r("<pre>" . json_encode($response, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) . "</pre>");
36+
}
37+
} catch (EfiException $e) {
38+
print_r($e->code . "<br>");
39+
print_r($e->error . "<br>");
40+
print_r($e->errorDescription) . "<br>";
41+
if (isset($options["responseHeaders"]) && $options["responseHeaders"]) {
42+
print_r("<pre>" . json_encode($e->headers, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) . "</pre>");
43+
}
44+
} catch (Exception $e) {
45+
print_r($e->getMessage());
46+
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
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+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<?php
2+
3+
/**
4+
* Detailed endpoint documentation
5+
* https://dev.efipay.com.br/docs/api-pix/pix-automatico#solicitar-retentativa-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+
"txid" => "0000000000000000000000000001",
25+
"data" => "2025-12-10"
26+
];
27+
28+
try {
29+
$api = new EfiPay($options);
30+
$response = $api->pixRetryRequestAutomatic($params);
31+
32+
if (isset($options["responseHeaders"]) && $options["responseHeaders"]) {
33+
print_r("<pre>" . json_encode($response->body, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) . "</pre>");
34+
print_r("<pre>" . json_encode($response->headers, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) . "</pre>");
35+
} else {
36+
print_r("<pre>" . json_encode($response, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) . "</pre>");
37+
}
38+
} catch (EfiException $e) {
39+
print_r($e->code . "<br>");
40+
print_r($e->error . "<br>");
41+
print_r($e->errorDescription) . "<br>";
42+
if (isset($options["responseHeaders"]) && $options["responseHeaders"]) {
43+
print_r("<pre>" . json_encode($e->headers, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) . "</pre>");
44+
}
45+
} catch (Exception $e) {
46+
print_r($e->getMessage());
47+
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<?php
2+
3+
/**
4+
* Detailed endpoint documentation
5+
* https://dev.efipay.com.br/docs/api-pix/pix-automatico#revisar-cobrança-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+
"txid" => "00000000000000000000000001"
25+
];
26+
27+
$body = [
28+
"status" => "CANCELADA"
29+
];
30+
31+
try {
32+
$api = new EfiPay($options);
33+
$response = $api->pixUpdateAutomaticCharge($params, $body);
34+
35+
if (isset($options["responseHeaders"]) && $options["responseHeaders"]) {
36+
print_r("<pre>" . json_encode($response->body, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) . "</pre>");
37+
print_r("<pre>" . json_encode($response->headers, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) . "</pre>");
38+
} else {
39+
print_r("<pre>" . json_encode($response, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) . "</pre>");
40+
}
41+
} catch (EfiException $e) {
42+
print_r($e->code . "<br>");
43+
print_r($e->error . "<br>");
44+
print_r($e->errorDescription) . "<br>";
45+
if (isset($options["responseHeaders"]) && $options["responseHeaders"]) {
46+
print_r("<pre>" . json_encode($e->headers, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) . "</pre>");
47+
}
48+
} catch (Exception $e) {
49+
print_r($e->getMessage());
50+
}

src/Efi/EfiPay.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,12 @@
126126
* @method object pixCreateRequestRecurrenceAutomatic($params, $body)
127127
* @method object pixDetailRequestRecurrenceAutomatic($params)
128128
* @method object pixUpdateRequestRecurrenceAutomatic($params, $body)
129+
* @method object pixCreateAutomaticChargeTxid($params, $body)
130+
* @method object pixUpdateAutomaticCharge($params, $body)
131+
* @method object pixDetailAutomaticCharge($params)
132+
* @method object pixCreateAutomaticCharge($params = [], $body)
133+
* @method object pixListAutomaticCharge($params)
134+
* @method object pixRetryRequestAutomatic($params)
129135
*
130136
* API OPEN FINANCE
131137
* @method object ofConfigUpdate(array $params = [], array $body)

src/Efi/Endpoints/Pix.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,36 @@
359359
"route" => "/v2/solicrec/:idSolicRec",
360360
"method" => "patch",
361361
"scope" => "solicrec.write"
362+
],
363+
"pixCreateAutomaticChargeTxid" => [
364+
"route" => "/v2/cobr/:txid",
365+
"method" => "put",
366+
"scope" => "cobr.write"
367+
],
368+
"pixUpdateAutomaticCharge" => [
369+
"route" => "/v2/cobr/:txid",
370+
"method" => "patch",
371+
"scope" => "cobr.write"
372+
],
373+
"pixDetailAutomaticCharge" => [
374+
"route" => "/v2/cobr/:txid",
375+
"method" => "get",
376+
"scope" => "cobr.read"
377+
],
378+
"pixCreateAutomaticCharge" => [
379+
"route" => "/v2/cobr",
380+
"method" => "post",
381+
"scope" => "cobr.write"
382+
],
383+
"pixListAutomaticCharge" => [
384+
"route" => "/v2/cobr",
385+
"method" => "get",
386+
"scope" => "cobr.read"
387+
],
388+
"pixRetryRequestAutomatic" => [
389+
"route" => "/v2/cobr/:txid/retentativa/:data",
390+
"method" => "post",
391+
"scope" => "cobr.write"
362392
]
363393
]
364394
];

0 commit comments

Comments
 (0)