'Dados inválidos']);
exit;
}
// Mapeamento dos campos do formulário Elementor
$nome = $data['fields']['name']['value'] ?? 'Cliente';
$email = $data['fields']['email']['value'] ?? '';
$cpf = $data['fields']['cpf']['value'] ?? '';
$valor = $data['fields']['amount']['value'] ?? 0;
// Configurações da API
$apiUrl = 'https://api.appfortpay.com.br/pix/create';
$token = 'I9E2HVk521NVqIJ5wof2TcbUhO4xrlh3gYWqZVuHIW0AiIbnAPyecIqG1Zqk';
$payload = json_encode([
'offer_hash' => 'e4dw7pflv7',
'product_hash' => 'vmttm2x33h',
'customer' => ['name' => $nome, 'email' => $email, 'document' => $cpf],
'amount' => $valor
]);
$ch = curl_init($apiUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Authorization: Bearer ' . $token,
'Content-Type: application/json'
]);
$response = curl_exec($ch);
curl_close($ch);
echo $response;