<?php
declare(strict_types=1);

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

require_once '../../../private/stripe_terminal_config.php';

require_once STRIPE_SDK_PATH.'/init.php';

\Stripe\Stripe::setApiKey(STRIPE_SECRET_KEY);

$data = json_decode(
file_get_contents('php://input'),
true
);

$amount =
round(((float)$data['amount']) * 100);

$paymentIntent =
\Stripe\PaymentIntent::create([

'amount'=>$amount,
'currency'=>'usd',

'payment_method_types'=>[
'card_present'
],

'capture_method'=>'automatic'

]);

echo json_encode([
'client_secret'=>
$paymentIntent->client_secret
]);
