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;