Files
hostpioneers/api/hire.php
T
horus 1b56aed681 HostPioneers - AI Agent Hiring Platform
Features:
- AI Agent Hiring API (/api/hire)
- Agent Discovery (/api/agents.json)
- Stripe Checkout Integration
- Webhooks for payment notifications
- Telegram + Email alerts
- Mobile responsive design
- SEO optimized
- AI-to-AI commerce ready

Built: March 2026
2026-03-19 17:17:02 +01:00

114 lines
3.3 KiB
PHP

<?php
header('Content-Type: application/json');
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: POST, OPTIONS');
header('Access-Control-Allow-Headers: Content-Type');
if ($_SERVER['REQUEST_METHOD'] === 'OPTIONS') {
http_response_code(200);
exit;
}
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
http_response_code(405);
echo json_encode(['error' => 'Method not allowed. Use POST.']);
exit;
}
$input = json_decode(file_get_contents('php://input'), true);
if (empty($input['agent']) || empty($input['email'])) {
http_response_code(400);
echo json_encode([
'error' => 'Missing required fields',
'required' => ['agent', 'email'],
'example' => [
'agent' => 'single-agent',
'email' => 'your@email.com'
]
]);
exit;
}
$agent = $input['agent'];
$email = filter_var($input['email'], FILTER_VALIDATE_EMAIL);
$name = $input['name'] ?? '';
$agents = [
'single-agent' => [
'name' => 'Single AI Agent',
'setup_price' => 199700,
'monthly_price' => 79700,
'checkout_url' => 'https://hostpioneers.com/checkout-single.html'
],
'multi-agent' => [
'name' => 'Multi AI Agent Team',
'setup_price' => 499700,
'monthly_price' => 179700,
'checkout_url' => 'https://hostpioneers.com/checkout-multi.html'
]
];
if (!isset($agents[$agent])) {
http_response_code(400);
echo json_encode([
'error' => 'Invalid agent type',
'valid_agents' => array_keys($agents)
]);
exit;
}
$agentConfig = $agents[$agent];
$stripeSecretKey = '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';
$stripeUrl = 'https://api.stripe.com/v1/checkout/sessions';
$data = [
'payment_method_types[]' => 'card',
'line_items[0][price_data][product_data][name]' => $agentConfig['name'] . ' - Setup',
'line_items[0][price_data][unit_amount]' => $agentConfig['setup_price'],
'line_items[0][price_data][currency]' => 'usd',
'line_items[0][quantity]' => 1,
'mode' => 'payment',
'success_url' => 'https://hostpioneers.com/success.html?agent=' . urlencode($agent),
'cancel_url' => $agentConfig['checkout_url'],
'customer_email' => $email,
'metadata' => [
'agent_type' => $agent,
'customer_name' => $name
]
];
$ch = curl_init($stripeUrl);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Authorization: Bearer ' . $stripeSecretKey,
'Content-Type: application/x-www-form-urlencoded'
]);
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
$responseData = json_decode($response, true);
if ($httpCode === 200 && isset($responseData['url'])) {
echo json_encode([
'success' => true,
'checkout_url' => $responseData['url'],
'session_id' => $responseData['id'],
'agent' => $agentConfig['name'],
'email' => $email,
'notification' => 'Telegram + Email on payment'
]);
} else {
http_response_code(500);
echo json_encode([
'error' => 'Failed to create checkout session',
'details' => $responseData['error'] ?? 'Unknown error'
]);
}