<?php
declare(strict_types=1);

require dirname(__DIR__) . '/_bootstrap.php';

$scheme = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') ? 'https' : 'http';
$host = $_SERVER['HTTP_HOST'] ?? 'astrotv.http02';
$projectRoot = dirname(__DIR__, 3);
$currentPath = parse_url($_SERVER['REQUEST_URI'] ?? '/new/credits/', PHP_URL_PATH) ?: '/new/credits/';
$canonicalUrl = sprintf('%s://%s%s', $scheme, $host, rtrim($currentPath, '/') . '/');

$page = [
    'title' => 'Koop credits | AstroTV',
    'description' => 'Kies hier uw AstroTV credits pakket en start direct een betaling met uw telefoonnummer.',
    'canonical_url' => $canonicalUrl,
    'body_class' => 'page-credits',
    'payment_state' => in_array((string) ($_GET['payment'] ?? ''), ['return', 'cancel'], true) ? (string) $_GET['payment'] : '',
    'payment_return_url' => sprintf('%s://%s/new/credits/?payment=return', $scheme, $host),
    'payment_cancel_url' => sprintf('%s://%s/new/credits/?payment=cancel', $scheme, $host),
    'packages' => [
        [
            'kicker' => 'Probeer het',
            'credits' => '1000 credits',
            'copy' => '€10 • ±10 min',
            'price' => '€10',
            'minutes' => '±10 min',
            'button_label' => 'Koop €10',
            'product_code' => 'astrotv.credits.small',
            'featured' => false,
            'note' => '',
        ],
        [
            'kicker' => 'Voordeelpakket',
            'credits' => '3100 credits',
            'copy' => '€30 • ±31 min',
            'price' => '€30',
            'minutes' => '±31 min',
            'button_label' => 'Koop €30',
            'product_code' => 'astrotv.credits.medium',
            'featured' => true,
            'ribbon' => 'Meest gekozen',
            'note' => 'Meest gekozen door klanten',
        ],
        [
            'kicker' => 'Beste prijs',
            'credits' => '5200 credits',
            'copy' => '€50 • ±52 min',
            'price' => '€50',
            'minutes' => '±52 min',
            'button_label' => 'Koop €50',
            'product_code' => 'astrotv.credits.large',
            'featured' => false,
            'note' => '',
        ],
    ],
];
$view = $projectRoot . '/templates/pages/credits.php';

require $projectRoot . '/templates/layout.php';
