mirror of
https://github.com/myronblair/parkerslingshotrentals
synced 2026-06-30 17:50:31 -05:00
10e1ffa27b
- DEPOSIT_AMOUNT changed from $100 to $45 - Balance (package price minus $45) shown dynamically in booking form when package selected - Customer confirmation email shows breakdown: deposit hold + balance at pickup - Admin email table includes deposit hold and balance columns - Admin booking flow step 5 shows deposit held + balance at pickup - Reminder email deposit detail updated to reflect held deposit and balance - Live status field shows $45 during card authorization flow Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
81 lines
3.3 KiB
PHP
81 lines
3.3 KiB
PHP
<?php
|
|
define('PARKER_DB_HOST', 'localhost');
|
|
define('PARKER_DB_NAME', 'parker_db');
|
|
define('PARKER_DB_USER', 'parker_user');
|
|
define('PARKER_DB_PASS', 'Pk4rk3r_2026!Tx');
|
|
|
|
define('ADMIN_USER', 'admin');
|
|
define('ADMIN_PASS', '$2y$10$ynnk3RfarOD7VIJizC30kuXqu6tQ3gotNrlp5y33afh5fPOgnAMU6'); // Parker2026!
|
|
define('ADMIN_SESSION_KEY', 'parker_admin_auth');
|
|
|
|
define('SENDGRID_API_KEY', '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');
|
|
define('MAIL_FROM', 'noreply@parkerslingshotrentals.com');
|
|
define('MAIL_FROM_NAME', 'Parker County Slingshot Rentals');
|
|
define('ADMIN_EMAIL', 'info@parkerslingshotrentals.com');
|
|
|
|
define('SQUARE_ACCESS_TOKEN', 'EAAAl3FsAu_2ri8kZE_ENEyi2T_C8HXXm5XQFY6Lbnd8SX6FqYp8J_upUeXNYh7v');
|
|
define('SQUARE_APP_ID', 'sq0idp-YSM7BU9IVyOWSzpeP-0nzQ');
|
|
define('SQUARE_LOCATION_ID', 'L8GZYHYKE95CE');
|
|
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 (!SENDGRID_API_KEY || strpos(SENDGRID_API_KEY, 'YOUR_KEY') !== false) return false;
|
|
$payload = json_encode([
|
|
'personalizations' => [['to' => [['email' => $to, 'name' => $toName]]]],
|
|
'from' => ['email' => MAIL_FROM, 'name' => MAIL_FROM_NAME],
|
|
'subject' => $subject,
|
|
'content' => [['type' => 'text/html', 'value' => $html]],
|
|
]);
|
|
$ch = curl_init('https://api.sendgrid.com/v3/mail/send');
|
|
curl_setopt_array($ch, [
|
|
CURLOPT_RETURNTRANSFER => true, CURLOPT_POST => true,
|
|
CURLOPT_POSTFIELDS => $payload,
|
|
CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . SENDGRID_API_KEY, 'Content-Type: application/json'],
|
|
CURLOPT_TIMEOUT => 15, CURLOPT_SSL_VERIFYPEER => false,
|
|
]);
|
|
$code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
|
curl_exec($ch); curl_close($ch);
|
|
return $code === 202;
|
|
}
|