Skip to content

Commit 283c91e

Browse files
✨feat: New examples of Pix automatic webhook endpoints
1 parent a685924 commit 283c91e

File tree

8 files changed

+304
-0
lines changed

8 files changed

+304
-0
lines changed
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/webhooks#configurar-o-webhook-de-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+
$options["headers"] = [
24+
"x-skip-mtls-checking" => false
25+
];
26+
27+
$body = [
28+
"webhookUrl" => "https://seudominio.com.br/webhook/"
29+
];
30+
31+
try {
32+
$api = new EfiPay($options);
33+
$response = $api->pixConfigWebhookAutomaticCharge($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+
}
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/webhooks#configurar-o-webhook-de-recorrência-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+
$options["headers"] = [
24+
"x-skip-mtls-checking" => false
25+
];
26+
27+
$body = [
28+
"webhookUrl" => "https://seudominio.com.br/webhook/"
29+
];
30+
31+
try {
32+
$api = new EfiPay($options);
33+
$response = $api->pixConfigWebhookRecurrenceAutomatic($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+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?php
2+
3+
/**
4+
* Detailed endpoint documentation
5+
* https://dev.efipay.com.br/docs/api-pix/webhooks#cancelar-o-webhook-de-recorrência-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+
try {
24+
$api = new EfiPay($options);
25+
$response = $api->pixDeleteWebhookAutomaticCharge();
26+
27+
if (isset($options["responseHeaders"]) && $options["responseHeaders"]) {
28+
print_r("<pre>" . json_encode($response->body, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) . "</pre>");
29+
print_r("<pre>" . json_encode($response->headers, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) . "</pre>");
30+
} else {
31+
print_r("<pre>" . json_encode($response, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) . "</pre>");
32+
}
33+
} catch (EfiException $e) {
34+
print_r($e->code . "<br>");
35+
print_r($e->error . "<br>");
36+
print_r($e->errorDescription) . "<br>";
37+
if (isset($options["responseHeaders"]) && $options["responseHeaders"]) {
38+
print_r("<pre>" . json_encode($e->headers, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) . "</pre>");
39+
}
40+
} catch (Exception $e) {
41+
print_r($e->getMessage());
42+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?php
2+
3+
/**
4+
* Detailed endpoint documentation
5+
* https://dev.efipay.com.br/docs/api-pix/webhooks#cancelar-o-webhook-de-recorrência-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+
try {
24+
$api = new EfiPay($options);
25+
$response = $api->pixDeleteWebhookRecurrenceAutomatic();
26+
27+
if (isset($options["responseHeaders"]) && $options["responseHeaders"]) {
28+
print_r("<pre>" . json_encode($response->body, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) . "</pre>");
29+
print_r("<pre>" . json_encode($response->headers, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) . "</pre>");
30+
} else {
31+
print_r("<pre>" . json_encode($response, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) . "</pre>");
32+
}
33+
} catch (EfiException $e) {
34+
print_r($e->code . "<br>");
35+
print_r($e->error . "<br>");
36+
print_r($e->errorDescription) . "<br>";
37+
if (isset($options["responseHeaders"]) && $options["responseHeaders"]) {
38+
print_r("<pre>" . json_encode($e->headers, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) . "</pre>");
39+
}
40+
} catch (Exception $e) {
41+
print_r($e->getMessage());
42+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?php
2+
3+
/**
4+
* Detailed endpoint documentation
5+
* https://dev.efipay.com.br/docs/api-pix/webhooks#exibir-informaõees-do-webhook-de-recorrência-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+
try {
24+
$api = new EfiPay($options);
25+
$response = $api->pixListWebhookAutomaticCharge();
26+
27+
if (isset($options["responseHeaders"]) && $options["responseHeaders"]) {
28+
print_r("<pre>" . json_encode($response->body, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) . "</pre>");
29+
print_r("<pre>" . json_encode($response->headers, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) . "</pre>");
30+
} else {
31+
print_r("<pre>" . json_encode($response, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) . "</pre>");
32+
}
33+
} catch (EfiException $e) {
34+
print_r($e->code . "<br>");
35+
print_r($e->error . "<br>");
36+
print_r($e->errorDescription) . "<br>";
37+
if (isset($options["responseHeaders"]) && $options["responseHeaders"]) {
38+
print_r("<pre>" . json_encode($e->headers, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) . "</pre>");
39+
}
40+
} catch (Exception $e) {
41+
print_r($e->getMessage());
42+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?php
2+
3+
/**
4+
* Detailed endpoint documentation
5+
* https://dev.efipay.com.br/docs/api-pix/webhooks#exibir-informaõees-do-webhook-de-recorrência-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+
try {
24+
$api = new EfiPay($options);
25+
$response = $api->pixListWebhookRecurrenceAutomatic();
26+
27+
if (isset($options["responseHeaders"]) && $options["responseHeaders"]) {
28+
print_r("<pre>" . json_encode($response->body, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) . "</pre>");
29+
print_r("<pre>" . json_encode($response->headers, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) . "</pre>");
30+
} else {
31+
print_r("<pre>" . json_encode($response, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) . "</pre>");
32+
}
33+
} catch (EfiException $e) {
34+
print_r($e->code . "<br>");
35+
print_r($e->error . "<br>");
36+
print_r($e->errorDescription) . "<br>";
37+
if (isset($options["responseHeaders"]) && $options["responseHeaders"]) {
38+
print_r("<pre>" . json_encode($e->headers, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) . "</pre>");
39+
}
40+
} catch (Exception $e) {
41+
print_r($e->getMessage());
42+
}

src/Efi/EfiPay.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,12 @@
109109
* @method object pixListDueChargeBatch(array $params)
110110
* @method object pixQrCodeDetail(array $params = [], array $body)
111111
* @method object pixQrCodePay(array $params, array $body)
112+
* @method object pixConfigWebhookRecurrenceAutomatic(array $params = [], array $body)
113+
* @method object pixListWebhookRecurrenceAutomatic()
114+
* @method object pixDeleteWebhookRecurrenceAutomatic()
115+
* @method object pixConfigWebhookAutomaticCharge(array $params = [], array $body)
116+
* @method object pixListWebhookAutomaticCharge()
117+
* @method object pixDeleteWebhookAutomaticCharge()
112118
*
113119
* API OPEN FINANCE
114120
* @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
@@ -274,6 +274,36 @@
274274
"route" => "/v2/gn/pix/comprovantes",
275275
"method" => "get",
276276
"scope" => "gn.receipts.read"
277+
],
278+
"pixConfigWebhookRecurrenceAutomatic" => [
279+
"route" => "/v2/webhookrec",
280+
"method" => "put",
281+
"scope" => "webhookrec.write"
282+
],
283+
"pixListWebhookRecurrenceAutomatic" => [
284+
"route" => "/v2/webhookrec",
285+
"method" => "get",
286+
"scope" => "webhookrec.read"
287+
],
288+
"pixDeleteWebhookRecurrenceAutomatic" => [
289+
"route" => "/v2/webhookrec",
290+
"method" => "delete",
291+
"scope" => "webhookrec.write"
292+
],
293+
"pixConfigWebhookAutomaticCharge" => [
294+
"route" => "/v2/webhookcobr",
295+
"method" => "put",
296+
"scope" => "webhookcobr.write"
297+
],
298+
"pixListWebhookAutomaticCharge" => [
299+
"route" => "/v2/webhookcobr",
300+
"method" => "get",
301+
"scope" => "webhookcobr.read"
302+
],
303+
"pixDeleteWebhookAutomaticCharge" => [
304+
"route" => "/v2/webhookcobr",
305+
"method" => "delete",
306+
"scope" => "webhookcobr.write"
277307
]
278308
]
279309
];

0 commit comments

Comments
 (0)