|
|
@@ -0,0 +1,72 @@
|
|
|
+<?php
|
|
|
+declare(strict_types=1);
|
|
|
+
|
|
|
+// Exiba erros durante o desenvolvimento
|
|
|
+ini_set('display_errors', '1');
|
|
|
+ini_set('display_startup_errors', '1');
|
|
|
+error_reporting(E_ALL);
|
|
|
+
|
|
|
+require __DIR__ . '/../vendor/autoload.php';
|
|
|
+
|
|
|
+use FrameworkX\App;
|
|
|
+use React\Http\Message\Response;
|
|
|
+
|
|
|
+function writeLog(string $event, string $body): void
|
|
|
+{
|
|
|
+ $logLine = date('Y-m-d H:i:s') . " - [{$event}] - " . $body . PHP_EOL;
|
|
|
+ file_put_contents(__DIR__ . '/../webhook.log', $logLine, FILE_APPEND);
|
|
|
+}
|
|
|
+
|
|
|
+$app = new App();
|
|
|
+
|
|
|
+$app->get('/', function () {
|
|
|
+ return new Response(
|
|
|
+ 200,
|
|
|
+ ['Content-Type' => 'application/json'],
|
|
|
+ json_encode(['message' => 'Webhook Service is up'])
|
|
|
+ );
|
|
|
+});
|
|
|
+
|
|
|
+$app->post('/edi', function ($request) {
|
|
|
+ $body = (string) $request->getBody();
|
|
|
+ writeLog('edi', $body);
|
|
|
+ return new Response(200, ['Content-Type' => 'application/json'], json_encode(['status' => 'success']));
|
|
|
+});
|
|
|
+
|
|
|
+$app->post('/qrcode/cash-in', function ($request) {
|
|
|
+ $body = (string) $request->getBody();
|
|
|
+ writeLog('qrcode:cash-in', $body);
|
|
|
+ return new Response(200, ['Content-Type' => 'application/json'], json_encode(['status' => 'success']));
|
|
|
+});
|
|
|
+
|
|
|
+$app->post('/cash-in', function ($request) {
|
|
|
+ $body = (string) $request->getBody();
|
|
|
+ writeLog('cash-in', $body);
|
|
|
+ return new Response(200, ['Content-Type' => 'application/json'], json_encode(['status' => 'success']));
|
|
|
+});
|
|
|
+
|
|
|
+$app->post('/cash-out', function ($request) {
|
|
|
+ $body = (string) $request->getBody();
|
|
|
+ writeLog('cash-out', $body);
|
|
|
+ return new Response(200, ['Content-Type' => 'application/json'], json_encode(['status' => 'success']));
|
|
|
+});
|
|
|
+
|
|
|
+$app->post('/refunds', function ($request) {
|
|
|
+ $body = (string) $request->getBody();
|
|
|
+ writeLog('refunds', $body);
|
|
|
+ return new Response(200, ['Content-Type' => 'application/json'], json_encode(['status' => 'success']));
|
|
|
+});
|
|
|
+
|
|
|
+$app->post('/ted', function ($request) {
|
|
|
+ $body = (string) $request->getBody();
|
|
|
+ writeLog('ted', $body);
|
|
|
+ return new Response(200, ['Content-Type' => 'application/json'], json_encode(['status' => 'success']));
|
|
|
+});
|
|
|
+
|
|
|
+$app->post('/{webhook}', function ($request, string $webhook) {
|
|
|
+ $body = (string) $request->getBody();
|
|
|
+ writeLog($webhook, $body);
|
|
|
+ return new Response(200, ['Content-Type' => 'application/json'], json_encode(['status' => 'success']));
|
|
|
+});
|
|
|
+
|
|
|
+$app->run();
|