<?php
if (!defined('BASE_PATH')) { define('BASE_PATH', __DIR__ . '/..'); }
require_once BASE_PATH . '/database/connection.php';
require_once BASE_PATH . '/api/shared/ApiLoader.php';
header('Content-Type: application/json');
try {
    $uid = $argv[1] ?? null;
    if (!$uid) { echo json_encode(['success'=>false,'message'=>'UID requerido']); exit; }
    $pdo = Database::getInstance()->getConnection();
    $client = ApiLoader::getIntegrationClient('key2pay', $pdo);
    $res = $client->getCheckoutPage($uid);
    echo json_encode($res);
} catch (Throwable $e) { echo json_encode(['success'=>false,'message'=>$e->getMessage()]); }

