46 lines
1.3 KiB
PHP
46 lines
1.3 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Controllers;
|
|
|
|
use Core\Request;
|
|
use Core\Response;
|
|
use App\Services\SuperQiParserService;
|
|
|
|
class PaymentController
|
|
{
|
|
/**
|
|
* POST /api/v1/payments/ingest-notification
|
|
* Invoked securely by the Android Bridge Listener app when a SuperQi/ZainCash notification arrives.
|
|
*/
|
|
public function ingestNotification(Request $request): void
|
|
{
|
|
$secret = $request->getHeader('x-listener-secret');
|
|
$expectedSecret = getenv('NOTIFICATION_INGEST_SECRET') ?: 'secure_ingest_key_for_android_bridge_listener';
|
|
|
|
if ($secret !== $expectedSecret) {
|
|
Response::forbidden('Invalid listener secret.');
|
|
}
|
|
|
|
$body = $request->getBody();
|
|
$result = SuperQiParserService::processIngestedNotification($body);
|
|
|
|
if (!$result['success']) {
|
|
Response::error($result['message'] ?? 'Ingestion failed', 400);
|
|
}
|
|
|
|
Response::success($result, 'Notification ingested and processed.');
|
|
}
|
|
|
|
/**
|
|
* POST /api/v1/payments/swiftpay-webhook
|
|
*/
|
|
public function swiftPayWebhook(Request $request): void
|
|
{
|
|
// Handle SwiftPayIQ transaction webhook
|
|
$payload = $request->getBody();
|
|
Response::success(['status' => 'received'], 'Webhook processed.');
|
|
}
|
|
}
|