| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- <?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('/genial/cashin', function ($request) {
- $body = (string) $request->getBody();
- writeLog('/genial/cashin', $body);
- return new Response(200, ['Content-Type' => 'application/json'], json_encode(['status' => 'success']));
- });
- $app->post('/genial/cashout', function ($request) {
- $body = (string) $request->getBody();
- writeLog('/genial/cashout', $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();
|