<?php
namespace Controllers;

use Core\Controller;

class MpesaCallbackController extends Controller {
    public function handle(): void {
        $raw  = file_get_contents('php://input');
        $data = json_decode($raw, true) ?? [];
        $schoolId = 1; // Default — in production derive from AccountReference
        (new \Services\MpesaService($schoolId))->handleCallback($data);
        http_response_code(200);
        echo json_encode(['ResultCode'=>0,'ResultDesc'=>'Accepted']);
        exit;
    }
}
