<?php
/**
 * Requires libcurl
 */

$curl = curl_init();

$payload = array(
  "customer" => array(
    "name" => "Cliente de Teste",
    "email" => "subscricoesp@gmail.com",
    "phone" => "911234567",
    "phone_indicative" => "+351",
    "key" => "12"
  ),
  "key" => "61032",
  "value" => 30,
  "method" => "mb",
  "capture" => array(
    "descriptive" => "transaction descriptive Example",
    "transaction_key" => "32"
  )
);

curl_setopt_array($curl, [
  CURLOPT_HTTPHEADER => [
    "AccountId: bdcdd0ca-18fa-487a-b18c-ad3aa1fc03b2",
    "ApiKey: d8f45e5c-9551-4f2d-aac4-55102884873f",
    "Content-Type: application/json"
  ],
  CURLOPT_POSTFIELDS => json_encode($payload),
  CURLOPT_PORT => "",
  CURLOPT_URL => "https://api.test.easypay.pt/2.0/single",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_CUSTOMREQUEST => "POST",
]);

$response = curl_exec($curl);
$error = curl_error($curl);

curl_close($curl);

if ($error) {
  echo "cURL Error #:" . $error;
} else {
  echo $response;
}