<?php
require 'stripe/init.php';

\Stripe\Stripe::setApiKey('sk_test_51HoV0JFFWbjoruwtfBBBwHo6QCMIOM7LE7u7SAOKZdr9DvePVWs3jqtcx2cijSKCwoh3WWYi4gT3vFcAu7YdzNe9006Q4YL0S5');

$data = json_decode(file_get_contents('php://input'), true);
$name = $data['name'];
$email = $data['email'];

// Create customer
$customer = \Stripe\Customer::create([
    'name' => $name,
    'email' => $email,
]);

// Create setup intent
$setupIntent = \Stripe\SetupIntent::create([
    'customer' => $customer->id,
]);

echo json_encode([
    'clientSecret' => $setupIntent->client_secret,
    'customerId' => $customer->id,
]);
