HTTP 500 error when submit a html/php form [closed]

Im trying to send from the form.html the “email” and “importe” imput value fields to pay.php via POST. But when I send the form it throws an HTTP error 500.

This is the code.

form.html

<form method="post" action="pay.php">
   <input name="importe" id="importe" required/>
   <input type="email" id="email" name="email" required/>
   <input type="submit" value="Submit">
</form>

pay.php

$key $secret and API_URL have other values of course, I have censored it with ****

<?php

private $key = "******************";
private $secret = "******************";

const API_URL = '***********************';
const API_VERSION = 'v2';



$timestamp = date("YmdHis");


try {
  $endPoint = 'invoices/create';
            
  $postData = json_encode([
    'timer' => false,
    'title' => 'Orden ' . $timestamp,
    'currency' => 'EUR',
    'amount' => $_POST["importe"],
    'foreign_id' => $timestamp . rand(),
    'url_success' => "https://sample.com",
    'url_failed' => "https://sample2.com",
    'email_user' => $_POST["email"],
  ]);
  
  $signature = hash_hmac('sha512', $postData, $this->secret);

  $url = self::API_URL . self::API_VERSION . '/' . $endPoint;
  $agent = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.246';
            
  $ch = curl_init($url);
  curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
  curl_setopt($ch, CURLOPT_VERBOSE, 0);
  curl_setopt($ch, CURLOPT_POST, 1);
  curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);
  curl_setopt($ch, CURLOPT_USERAGENT, $agent);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
  
  curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'X-Processing-Key: ' . $this->key,
    'X-Processing-Signature: ' . $signature,
    'Content-Type: application/json'
  ]);
  
  $result = curl_exec($ch);
  curl_close($ch);
  
  $result = json_decode($result);
  var_dump($result):

} catch (Exception $e) {
  var_dump($e);
}

print "Result = ".$result;

exit;

?>

Thanks for the help!