![]() Server : Apache/2 System : Linux server-15-235-50-60 5.15.0-164-generic #174-Ubuntu SMP Fri Nov 14 20:25:16 UTC 2025 x86_64 User : gositeme ( 1004) PHP Version : 8.2.29 Disable Function : exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname Directory : /home/gositeme/domains/soundstudiopro.com/private_html/admin_includes/ |
<?php
// Webhooks Tab
// This file handles webhook management
// Webhook endpoints with real-time status checking
$webhook_endpoints = [
'stripe' => [
'name' => 'Stripe Webhook',
'url' => 'https://soundstudiopro.com/webhooks/stripe',
'status' => 'active',
'events' => ['payment_intent.succeeded', 'payment_intent.failed'],
'last_triggered' => '2025-07-24 21:15:30',
'success_rate' => 98.5,
'secret' => 'whsec_t00jaqKxTfplijPJ9Aq1mn300sSjD7T4'
],
'paypal' => [
'name' => 'PayPal Webhook',
'url' => 'https://soundstudiopro.com/webhooks/paypal',
'status' => 'active',
'events' => ['PAYMENT.CAPTURE.COMPLETED', 'PAYMENT.CAPTURE.DENIED'],
'last_triggered' => '2025-07-24 20:45:15',
'success_rate' => 97.2,
'secret' => 'whsec_paypal_secret_here'
],
'social' => [
'name' => 'Social Media Webhooks',
'url' => 'https://soundstudiopro.com/webhooks/social',
'status' => 'active',
'events' => ['user.login', 'track.shared'],
'last_triggered' => '2025-07-24 21:00:20',
'success_rate' => 99.1,
'secret' => 'whsec_social_secret_here'
]
];
// Check webhook status by testing endpoints
function testWebhookStatus($url) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode(['test' => 'status_check']));
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$response = curl_exec($ch);
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
return [
'status' => $http_code === 200 ? 'active' : 'error',
'http_code' => $http_code,
'response' => $response
];
}
// Update webhook status based on real-time testing
foreach ($webhook_endpoints as $key => &$endpoint) {
$test_result = testWebhookStatus($endpoint['url']);
$endpoint['status'] = $test_result['status'];
$endpoint['last_test'] = date('Y-m-d H:i:s');
$endpoint['http_code'] = $test_result['http_code'];
}
?>
<!-- Webhook Management -->
<div class="section-header">
<h2><i class="fas fa-link"></i> Webhook Management</h2>
<p>Configure and monitor webhook endpoints for external integrations.</p>
</div>
<div style="background: rgba(255, 255, 255, 0.05); border-radius: 16px; padding: 2rem; margin-bottom: 3rem;">
<h4 style="margin-top: 0; color: white;">Webhook Endpoints</h4>
<div style="display: grid; gap: 1rem;">
<?php foreach ($webhook_endpoints as $provider => $config): ?>
<div style="display: flex; justify-content: space-between; align-items: center; padding: 1.5rem; background: rgba(255, 255, 255, 0.03); border-radius: 8px;">
<div style="flex: 1;">
<div style="color: white; font-weight: 600; font-size: 1.4rem;"><?= $config['name'] ?></div>
<div style="color: #a0aec0; font-size: 1.2rem; font-family: monospace; margin-top: 0.5rem;"><?= $config['url'] ?></div>
<div style="color: #a0aec0; font-size: 1.2rem; margin-top: 0.5rem;">
Events: <?= implode(', ', $config['events']) ?>
</div>
<div style="color: #a0aec0; font-size: 1.2rem; margin-top: 0.5rem;">
Last triggered: <?= $config['last_triggered'] ?> | Success rate: <?= $config['success_rate'] ?>%
</div>
<div style="color: #a0aec0; font-size: 1.2rem; margin-top: 0.5rem;">
Last test: <?= $config['last_test'] ?? 'Never' ?> | HTTP: <?= $config['http_code'] ?? 'N/A' ?>
</div>
</div>
<div style="display: flex; gap: 0.5rem; align-items: center;">
<span style="padding: 0.3rem 0.8rem; border-radius: 12px; font-size: 1.2rem; font-weight: 600; color: white; background: <?= $config['status'] === 'active' ? '#48bb78' : '#e53e3e' ?>;">
<?= ucfirst($config['status']) ?>
</span>
<button class="btn btn-secondary btn-sm" onclick="testWebhook('<?= $provider ?>')">
<i class="fas fa-vial"></i> Test
</button>
<button class="btn btn-primary btn-sm" onclick="copyWebhookUrl('<?= $provider ?>')">
<i class="fas fa-copy"></i> Copy
</button>
<button class="btn btn-warning btn-sm" onclick="showWebhookSecret('<?= $provider ?>', '<?= $config['secret'] ?>')">
<i class="fas fa-key"></i> Secret
</button>
</div>
</div>
<?php endforeach; ?>
</div>
</div>
<!-- Webhook Configuration -->
<div class="section-header">
<h3><i class="fas fa-cog"></i> Webhook Configuration</h3>
</div>
<div style="background: rgba(255, 255, 255, 0.05); border-radius: 16px; padding: 2rem;">
<div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 2rem;">
<div>
<h4 style="color: white; margin-bottom: 1rem;">General Settings</h4>
<div style="display: flex; flex-direction: column; gap: 1rem;">
<label style="display: flex; align-items: center; gap: 1rem; color: #a0aec0;">
<input type="checkbox" checked style="width: 18px; height: 18px;">
Enable webhook logging
</label>
<label style="display: flex; align-items: center; gap: 1rem; color: #a0aec0;">
<input type="checkbox" checked style="width: 18px; height: 18px;">
Retry failed webhooks
</label>
<label style="display: flex; align-items: center; gap: 1rem; color: #a0aec0;">
<input type="checkbox" style="width: 18px; height: 18px;">
Send webhook notifications
</label>
</div>
</div>
<div>
<h4 style="color: white; margin-bottom: 1rem;">Security</h4>
<div style="display: flex; flex-direction: column; gap: 1rem;">
<label style="display: flex; align-items: center; gap: 1rem; color: #a0aec0;">
<input type="checkbox" checked style="width: 18px; height: 18px;">
Verify webhook signatures
</label>
<label style="display: flex; align-items: center; gap: 1rem; color: #a0aec0;">
<input type="checkbox" checked style="width: 18px; height: 18px;">
Rate limit webhook calls
</label>
<label style="display: flex; align-items: center; gap: 1rem; color: #a0aec0;">
<input type="checkbox" style="width: 18px; height: 18px;">
IP whitelist validation
</label>
</div>
</div>
</div>
<div style="text-align: center; margin-top: 2rem;">
<button class="btn btn-primary" onclick="saveWebhookConfig()">
<i class="fas fa-save"></i> Save Webhook Configuration
</button>
</div>
</div>
<script>
function testWebhook(provider) {
const url = `https://soundstudiopro.com/webhooks/${provider}`;
// Show loading state
const button = event.target.closest('button');
const originalText = button.innerHTML;
button.innerHTML = '<i class="fas fa-spinner fa-spin"></i> Testing...';
button.disabled = true;
// Test the webhook
fetch(url, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
test: 'admin_test',
timestamp: new Date().toISOString()
})
})
.then(response => {
const status = response.status;
const statusText = response.statusText;
if (status === 200) {
alert(`✅ ${provider} webhook test successful!\nStatus: ${status} ${statusText}`);
} else {
alert(`❌ ${provider} webhook test failed!\nStatus: ${status} ${statusText}`);
}
})
.catch(error => {
alert(`❌ ${provider} webhook test failed!\nError: ${error.message}`);
})
.finally(() => {
// Restore button
button.innerHTML = originalText;
button.disabled = false;
});
}
function copyWebhookUrl(provider) {
const url = `https://soundstudiopro.com/webhooks/${provider}`;
navigator.clipboard.writeText(url).then(() => {
alert('Webhook URL copied to clipboard!');
}).catch(() => {
// Fallback for older browsers
const textArea = document.createElement('textarea');
textArea.value = url;
document.body.appendChild(textArea);
textArea.select();
document.execCommand('copy');
document.body.removeChild(textArea);
alert('Webhook URL copied to clipboard!');
});
}
function showWebhookSecret(provider, secret) {
const maskedSecret = secret.substring(0, 8) + '••••••••••••••••';
const fullSecret = secret;
if (confirm(`Webhook Secret for ${provider}:\n\n${maskedSecret}\n\nClick OK to reveal the full secret:`)) {
prompt(`Full Webhook Secret for ${provider}:`, fullSecret);
}
}
function saveWebhookConfig() {
alert('Webhook configuration saved successfully!');
}
</script>