<?php
require_once __DIR__ . '/../../config.php';
require_once __DIR__ . '/../../engine/Kernel.php';
require_once __DIR__ . '/../../engine/Logger.php';
if($_SERVER['REQUEST_METHOD']!=='POST'){http_response_code(405);exit;}
$ctx = Kernel::handle(['auth' => 'optional']);
$u = $ctx['user']; if(!$u){http_response_code(401);exit;}
$b=json_decode(file_get_contents('php://input'),true)??[];
require_once __DIR__.'/../../engine/MerchantEngine.php';
echo json_encode(MerchantEngine::register((int)$u['id'],$b));