<?php
// Verificar credenciais da Moonfy
header('Content-Type: text/plain');

// Credenciais fornecidas pelo usuário
$secret_key = 'sk_live_v2qH1vr3VkJhw3XBI3bkOMjOiuVO7qcbcBDHdUxjEq';
$public_key = 'pk_live_v2Mnp0PFV68jvNRFzYAmauvn2N4kjuYDq';

echo "=== VERIFICAÇÃO DE CREDENCIAIS MOONFY ===\n";
echo "Secret Key: " . $secret_key . "\n";
echo "Public Key: " . $public_key . "\n\n";

// Verificar se as credenciais seguem o padrão esperado
echo "=== ANÁLISE DAS CREDENCIAIS ===\n";
echo "Secret Key length: " . strlen($secret_key) . "\n";
echo "Public Key length: " . strlen($public_key) . "\n";
echo "Secret Key starts with 'sk_live_': " . (strpos($secret_key, 'sk_live_') === 0 ? 'SIM' : 'NÃO') . "\n";
echo "Public Key starts with 'pk_live_': " . (strpos($public_key, 'pk_live_') === 0 ? 'SIM' : 'NÃO') . "\n\n";

// Testar diferentes URLs da API
$urls = [
    'https://api.moonfy.com.br/v1',
    'https://api.moonfy.com.br',
    'https://moonfy.com.br/api/v1',
    'https://moonfy.com.br/api'
];

echo "=== TESTANDO DIFERENTES URLs ===\n";
foreach ($urls as $url) {
    echo "Testando: " . $url . "\n";
    
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url . '/transactions');
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_HTTPHEADER, [
        'Authorization: Basic ' . base64_encode($secret_key . ':')
    ]);
    curl_setopt($ch, CURLOPT_TIMEOUT, 5);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    
    $response = curl_exec($ch);
    $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    $error = curl_error($ch);
    curl_close($ch);
    
    echo "  HTTP Code: " . $httpCode . "\n";
    echo "  Error: " . $error . "\n";
    echo "  Response: " . substr($response, 0, 100) . "\n\n";
}

// Verificar se a API está acessível
echo "=== TESTE DE CONECTIVIDADE ===\n";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.moonfy.com.br');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_NOBODY, true);

$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$error = curl_error($ch);
curl_close($ch);

echo "Conectividade com api.moonfy.com.br:\n";
echo "  HTTP Code: " . $httpCode . "\n";
echo "  Error: " . $error . "\n";
?>
