Deploy: 2026-05-22 01:25:54
This commit is contained in:
@@ -68,5 +68,44 @@ $router->get('/api/chatbot/rules', [\App\Controllers\ChatbotController::class, '
|
||||
$router->post('/api/chatbot/rules',[\App\Controllers\ChatbotController::class, 'store'], [\App\Middlewares\AuthMiddleware::class]);
|
||||
$router->post('/api/chatbot/generate-prompt-from-audio', [\App\Controllers\ChatbotController::class, 'generatePromptFromAudio'], [\App\Middlewares\AuthMiddleware::class]);
|
||||
|
||||
// Mock External API for Entaleq Payment Verification (Used to demo automated slip validation)
|
||||
$router->post('/api/external/verify-payment', function ($request, $response) {
|
||||
$body = $request->getBody();
|
||||
$phone = $body['phone'] ?? '';
|
||||
$transactionId = $body['transaction_id'] ?? '';
|
||||
$amount = $body['amount'] ?? '';
|
||||
$method = $body['method'] ?? '';
|
||||
|
||||
if (empty($transactionId) || empty($amount)) {
|
||||
$response->status(400)->json([
|
||||
'status' => 'error',
|
||||
'message' => 'Missing transaction_id or amount'
|
||||
]);
|
||||
return;
|
||||
}
|
||||
|
||||
// Mock validation rules:
|
||||
// If transaction_id contains 'fail' or starts with '9', mock verification failure
|
||||
if (strpos(strtolower($transactionId), 'fail') !== false || (is_string($transactionId) && $transactionId[0] === '9')) {
|
||||
$response->json([
|
||||
'status' => 'failed',
|
||||
'message' => 'هذا الرقم التعريفي للعملية تم استخدامه مسبقاً أو غير صحيح'
|
||||
]);
|
||||
return;
|
||||
}
|
||||
|
||||
$response->json([
|
||||
'status' => 'success',
|
||||
'message' => 'Payment verified and driver balance updated',
|
||||
'data' => [
|
||||
'driver_phone' => $phone,
|
||||
'transaction_id' => $transactionId,
|
||||
'amount' => $amount,
|
||||
'method' => $method,
|
||||
'new_balance' => 150.00
|
||||
]
|
||||
]);
|
||||
});
|
||||
|
||||
// 4. Dispatch the request
|
||||
$router->dispatch($request, $response);
|
||||
|
||||
Reference in New Issue
Block a user