mirror of
https://github.com/myronblair/parkerslingshot
synced 2026-06-30 17:50:22 -05:00
Initial commit — Parker County Slingshot Rentals booking site
Full booking system with Square card-on-file, 10-step booking flow, pre-departure checklist, and Mailjet email integration. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,91 @@
|
||||
<?php
|
||||
define('SITE_URL', 'https://parkerslingshot.epictravelexpeditions.com');
|
||||
|
||||
define('PARKER_DB_HOST', 'localhost');
|
||||
define('PARKER_DB_NAME', 'epic_parkersling');
|
||||
define('PARKER_DB_USER', 'epic_parkersling');
|
||||
define('PARKER_DB_PASS', 'REPLACE_WITH_DB_PASSWORD');
|
||||
|
||||
define('ADMIN_USER', 'admin');
|
||||
define('ADMIN_PASS', '$2y$10$ynnk3RfarOD7VIJizC30kuXqu6tQ3gotNrlp5y33afh5fPOgnAMU6'); // Parker2026!
|
||||
define('ADMIN_SESSION_KEY', 'parker_admin_auth');
|
||||
define('ADMIN_PHONE', '(817) 555-0199');
|
||||
|
||||
// Mailjet credentials — fill in once you have your Mailjet account
|
||||
define('MAILJET_API_KEY', 'YOUR_MAILJET_API_KEY'); // Mailjet API Key (public)
|
||||
define('MAILJET_SECRET_KEY', 'YOUR_MAILJET_SECRET_KEY'); // Mailjet Secret Key (private)
|
||||
define('MAIL_FROM', 'noreply@parkerslingshotrentals.com');
|
||||
define('MAIL_FROM_NAME', 'Parker County Slingshot Rentals');
|
||||
define('ADMIN_EMAIL', 'info@parkerslingshotrentals.com');
|
||||
|
||||
define('SQUARE_ACCESS_TOKEN', 'YOUR_SQUARE_ACCESS_TOKEN
|
||||
define('SQUARE_APP_ID', 'YOUR_SQUARE_APP_ID
|
||||
define('SQUARE_LOCATION_ID', 'YOUR_SQUARE_LOCATION_ID');
|
||||
define('SQUARE_VERSION', '2024-01-18');
|
||||
define('DEPOSIT_AMOUNT', 45.00); // $45 deposit hold — balance due at pickup
|
||||
|
||||
define('PACKAGES', [
|
||||
'half-day' => ['label' => 'Half Day (4 hrs)', 'amount' => 99.00, 'days' => 0],
|
||||
'full-day' => ['label' => 'Full Day (8 hrs)', 'amount' => 169.00, 'days' => 0],
|
||||
'weekend' => ['label' => 'Weekend (48 hrs)', 'amount' => 299.00, 'days' => 1],
|
||||
]);
|
||||
|
||||
function db(): PDO {
|
||||
static $pdo;
|
||||
if (!$pdo) {
|
||||
$pdo = new PDO(
|
||||
'mysql:host=' . PARKER_DB_HOST . ';dbname=' . PARKER_DB_NAME . ';charset=utf8mb4',
|
||||
PARKER_DB_USER, PARKER_DB_PASS,
|
||||
[PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC]
|
||||
);
|
||||
}
|
||||
return $pdo;
|
||||
}
|
||||
|
||||
function squareApi(string $method, string $path, array $body = []): array {
|
||||
$ch = curl_init('https://connect.squareup.com/v2' . $path);
|
||||
$headers = [
|
||||
'Authorization: Bearer ' . SQUARE_ACCESS_TOKEN,
|
||||
'Content-Type: application/json',
|
||||
'Square-Version: ' . SQUARE_VERSION,
|
||||
];
|
||||
$opts = [CURLOPT_RETURNTRANSFER => true, CURLOPT_HTTPHEADER => $headers, CURLOPT_TIMEOUT => 30, CURLOPT_SSL_VERIFYPEER => false];
|
||||
if ($method === 'POST') {
|
||||
$opts[CURLOPT_POST] = true;
|
||||
$opts[CURLOPT_POSTFIELDS] = $body ? json_encode($body) : '{}';
|
||||
}
|
||||
curl_setopt_array($ch, $opts);
|
||||
$resp = curl_exec($ch);
|
||||
curl_close($ch);
|
||||
return json_decode($resp ?: '{}', true);
|
||||
}
|
||||
|
||||
function generateRef(): string {
|
||||
return 'PSR-' . strtoupper(substr(uniqid(), -6));
|
||||
}
|
||||
|
||||
function sendEmail(string $to, string $toName, string $subject, string $html): bool {
|
||||
if (strpos(MAILJET_API_KEY, 'YOUR_') !== false) return false;
|
||||
$payload = json_encode([
|
||||
'Messages' => [[
|
||||
'From' => ['Email' => MAIL_FROM, 'Name' => MAIL_FROM_NAME],
|
||||
'To' => [['Email' => $to, 'Name' => $toName]],
|
||||
'Subject' => $subject,
|
||||
'HTMLPart' => $html,
|
||||
]],
|
||||
]);
|
||||
$ch = curl_init('https://api.mailjet.com/v3.1/send');
|
||||
curl_setopt_array($ch, [
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_POST => true,
|
||||
CURLOPT_POSTFIELDS => $payload,
|
||||
CURLOPT_HTTPHEADER => ['Content-Type: application/json'],
|
||||
CURLOPT_USERPWD => MAILJET_API_KEY . ':' . MAILJET_SECRET_KEY,
|
||||
CURLOPT_TIMEOUT => 15,
|
||||
CURLOPT_SSL_VERIFYPEER => false,
|
||||
]);
|
||||
$resp = curl_exec($ch);
|
||||
$code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
curl_close($ch);
|
||||
return $code === 200;
|
||||
}
|
||||
Reference in New Issue
Block a user