HEX
Server: Apache
System: Linux webm004.cluster129.gra.hosting.ovh.net 5.15.167-ovh-vps-grsec-zfs-classid #1 SMP Tue Sep 17 08:14:20 UTC 2024 x86_64
User: windevelwb (110072)
PHP: 8.5.0
Disabled: _dyuweyrj4,_dyuweyrj4r,dl
Upload Files
File: /home/windevelwb/www/create_checkout.php
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);

ob_clean();
header('Content-Type: application/json; charset=utf-8');

// Charger Stripe (standalone)
require __DIR__ . '/init.php';

try {

    \Stripe\Stripe::setApiKey('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');

    if (!isset($_GET['amount'])) {
        throw new Exception("Missing amount");
    }

    $amount = intval($_GET['amount']);
    if ($amount <= 0) {
        throw new Exception("Invalid amount");
    }

    $checkout_session = \Stripe\Checkout\Session::create([
        'mode' => 'payment',
        'payment_method_types' => ['card', 'bancontact'],
        'line_items' => [[
            'price_data' => [
                'currency' => 'eur',
                'product_data' => [
                    'name' => 'Paiement Ongle Manager',
                ],
                'unit_amount' => $amount,
            ],
            'quantity' => 1,
        ]],
        'success_url' => 'https://www.windevelop.be/stripe/success.html',
        'cancel_url' => 'https://www.windevelop.be/stripe/cancel.html',
    ]);

    echo json_encode($checkout_session, JSON_UNESCAPED_SLASHES);

} catch (Exception $e) {

    echo json_encode([
        "error" => true,
        "message" => $e->getMessage()
    ]);
}

exit;