54 lines
1.9 KiB
PHP
54 lines
1.9 KiB
PHP
<?php
|
|
session_start();
|
|
require_once 'db/config.php';
|
|
require_once 'stripe/config.php'; // for $subscriptions
|
|
|
|
if (!isset($_SESSION['user_id']) || $_SESSION['user_role'] !== 'client') {
|
|
header('Location: login.php');
|
|
exit;
|
|
}
|
|
|
|
global $subscriptions; // from stripe/config.php
|
|
|
|
?>
|
|
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Subscribe</title>
|
|
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
|
|
</head>
|
|
<body>
|
|
<div class="container mt-5">
|
|
<h2>Subscription Plans</h2>
|
|
<div class="row">
|
|
<?php foreach ($subscriptions as $id => $plan): ?>
|
|
<div class="col-md-4">
|
|
<div class="card mb-4">
|
|
<div class="card-body">
|
|
<h5 class="card-title"><?= htmlspecialchars($plan['name']) ?></h5>
|
|
<p class="card-text">
|
|
$<?= number_format($plan['price'] / 100, 2) ?> per <?= htmlspecialchars($plan['interval']) ?><br>
|
|
Includes <?= $plan['sessions'] ?> sessions.
|
|
</p>
|
|
<a href="subscribe-checkout.php?plan_id=<?= $id ?>" class="btn btn-primary">Subscribe</a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
<?php if (isset($_GET['error'])): ?>
|
|
<div class="alert alert-danger mt-3">
|
|
<?php
|
|
if ($_GET['error'] === 'invalid_plan') {
|
|
echo 'Invalid subscription plan selected.';
|
|
} else {
|
|
echo 'An error occurred with the payment processor. Please try again.';
|
|
}
|
|
?>
|
|
</div>
|
|
<?php endif; ?>
|
|
</div>
|
|
</body>
|
|
</html>
|