<?php
require_once __DIR__ . '/../../config.php';
require_once __DIR__ . '/../../engine/Kernel.php';
Kernel::handle(['auth'=>false,'public'=>true]);
require_once __DIR__ . '/../../engine/Kernel.php';
if($_SERVER['REQUEST_METHOD']!=='POST'){http_response_code(405);exit;}
$u=current_user(); if(!$u){http_response_code(401);exit;}
$b=json_decode(file_get_contents('php://input'),true)??[];
require_once __DIR__.'/../../engine/BillPayEngine.php';
echo json_encode(BillPayEngine::payGov((int)$u['id'],(int)($b['service_id']??0),trim($b['applicant_id']??''),(int)($b['pin']??0)));