'Method not allowed']); exit; } $stripe_secret_key = getenv('STRIPE_SECRET_KEY') ?: 'sk_test_YOUR_SECRET_KEY_HERE'; $input = file_get_contents('php://input'); $data = json_decode($input, true); if (!$data || !isset($data['product_id']) || !isset($data['price'])) { http_response_code(400); echo json_encode(['error' => 'Missing fields']); exit; } $product_id = $data['product_id']; $price_cents = (int)$data['price']; $currency = $data['currency'] ?? 'eur'; $products = [ 'inference_tokens' => [ 'name' => 'Inference Tokens — API IA Huawei Cloud', 'description' => '1M tokens/mois • 20+ LLM (Llama, Qwen, Claude, GPT) • Latence <50ms • Dashboard analytics' ], 'gpu_a100' => [ 'name' => 'GPU A100 — IA & ML', 'description' => 'NVIDIA A100 40GB • 96 vCPU • 768GB RAM • 2TB NVMe • TensorFlow/PyTorch' ], 'modelarts' => [ 'name' => 'ModelArts — Plateforme IA', 'description' => '100+ modèles • Training distribué • AutoML • MLOps complet' ], 'cloud_stack' => [ 'name' => 'Cloud Stack — Infrastructure Hybride', 'description' => '3-100+ nodes on-premise • API Huawei Cloud • Souveraineté totale' ], 'cce_k8s' => [ 'name' => 'CCE — Kubernetes Managé', 'description' => 'K8s 1.28+ • 1-1000 nodes • Auto-scaling • Prometheus • Istio' ], 'ecs_compute' => [ 'name' => 'ECS Compute — Production', 'description' => '32 vCPU • 128GB RAM • 1TB SSD • HA 99.95%' ], 'gpu_v100' => [ 'name' => 'GPU V100 — Deep Learning', 'description' => 'NVIDIA V100 32GB • 64 vCPU • 512GB RAM • Tensor Cores' ], 'gaussdb' => [ 'name' => 'GaussDB — Database IA', 'description' => 'MySQL • 10TB auto-scale • 100K IOPS • AI optimizer' ], 'obs_storage' => [ 'name' => 'Object Storage OBS', 'description' => '10TB • S3 API • CDN inclus • Encryption' ], 'bare_metal' => [ 'name' => 'Bare Metal Server', 'description' => 'Xeon Gold • 96 cores • 1TB RAM • RDMA 100 Gbps' ], 'functiongraph' => [ 'name' => 'FunctionGraph — Serverless', 'description' => 'Multi-language • Auto-scaling • Event triggers • 1M gratuit' ] ]; if (!isset($products[$product_id])) { http_response_code(400); echo json_encode(['error' => 'Invalid product']); exit; } $product = $products[$product_id]; try { require_once('/var/www/vendor/stripe/stripe-php/init.php'); \Stripe\Stripe::setApiKey($stripe_secret_key); $session = \Stripe\Checkout\Session::create([ 'payment_method_types' => ['card'], 'line_items' => [[ 'price_data' => [ 'currency' => $currency, 'product_data' => [ 'name' => $product['name'], 'description' => $product['description'], ], 'unit_amount' => $price_cents, ], 'quantity' => 1, ]], 'mode' => 'payment', 'success_url' => 'https://weval-consulting.com/products/huawei-success.html?session_id={CHECKOUT_SESSION_ID}', 'cancel_url' => 'https://weval-consulting.com/huawei-cloud.html', 'customer_email' => $data['email'] ?? null, 'metadata' => [ 'product_id' => $product_id, 'provider' => 'huawei_cloud', 'partner' => 'weval' ] ]); echo json_encode([ 'sessionId' => $session->id, 'url' => $session->url ]); } catch (\Stripe\Exception\ApiErrorException $e) { http_response_code(500); echo json_encode([ 'error' => 'Stripe API error', 'message' => $e->getMessage() ]); } catch (Exception $e) { http_response_code(500); echo json_encode([ 'error' => 'Server error', 'message' => $e->getMessage() ]); }