Repository navigation
Expand file tree
/
Copy pathbilling.php
More file actions
284 lines (241 loc) · 9.55 KB
/
Copy pathbilling.php
File metadata and controls
284 lines (241 loc) · 9.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
<?php
declare(strict_types=1);
require_once __DIR__ . '/includes/auth.php';
require_once __DIR__ . '/includes/functions.php';
require_once __DIR__ . '/includes/billing.php';
$isLoggedIn = function_exists('is_logged_in') && is_logged_in();
$teamId = $isLoggedIn ? current_team_id() : 0;
$currentPlanKey = $teamId > 0 ? current_team_plan_key($teamId) : 'none';
$pageTitle = 'Billing';
$currentPage = 'billing';
$isStaging = strpos($_SERVER['HTTP_HOST'] ?? '', 'staging') !== false;
$team = $teamId > 0 ? get_team_by_id($teamId) : null;
$billingRequiredMessage = '';
if (session_status() !== PHP_SESSION_ACTIVE) {
session_start();
}
if (!empty($_SESSION['billing_required_message'])) {
$billingRequiredMessage = (string)$_SESSION['billing_required_message'];
unset($_SESSION['billing_required_message']);
}
require_once __DIR__ . '/includes/header.php';
?>
<h1 class="page-title brand-title-font">Billing</h1>
<?php if ($billingRequiredMessage !== ''): ?>
<div class="msg info">
<?= h($billingRequiredMessage) ?>
</div>
<?php endif; ?>
<?php if (!billing_enabled()): ?>
<div class="card">
<h2>Billing is not active yet</h2>
<p class="muted">
BenchBuddy is currently in beta. Paid plans are not required right now.
</p>
</div>
<?php else: ?>
<?php
$currentPlan = normalize_plan_key((string)($team['plan_key'] ?? 'free'));
$plans = [
'free' => [
'name' => 'Free',
'tagline' => 'For trying BenchBuddy with basic lineup tools.',
'monthly' => '$0',
'yearly' => '$0',
'stripe_value_monthly' => '',
'stripe_value_yearly' => '',
'badge' => '',
'features' => [
'Basic player management',
'Basic game creation',
'Standard lineup generation',
'Up to 10 players per team',
'Up to 10 games per team',
'3 game history items',
'1 lineup template',
'Print sheets with BenchBuddy Free watermark',
],
],
'coach' => [
'name' => 'Coach',
'tagline' => 'For one coach managing a simple season.',
'monthly' => '$2',
'yearly' => '$20',
'stripe_value_monthly' => 'coach_monthly',
'stripe_value_yearly' => 'coach_yearly',
'badge' => '',
'features' => [
'Everything in Free',
'Up to 15 players per team',
'Up to 20 games per team',
'Past 10 games in game history',
'Up to 12 lineup history items',
'Up to 5 lineup templates',
'1 additional team member',
'Pitch count tracking',
'Watermark-free printouts',
'Custom branded printouts',
],
],
'coachplus' => [
'name' => 'Coach Plus',
'tagline' => 'For coaches who want the full lineup toolkit.',
'monthly' => '$5',
'yearly' => '$50',
'stripe_value_monthly' => 'coachplus_monthly',
'stripe_value_yearly' => 'coachplus_yearly',
'badge' => 'Best Value',
'features' => [
'Everything in Coach',
'Unlimited players',
'Unlimited games',
'Full game history',
'Full lineup history',
'Up to 10 lineup templates',
'Up to 3 additional team members',
'Advanced lineup settings',
'Pitch count and rest tracking',
'Watermark-free printouts',
'Custom branded printouts',
],
],
'unlimited' => [
'name' => 'Unlimited',
'tagline' => 'For clubs, associations, and multi-team programs.',
'monthly' => '$9',
'yearly' => '$90',
'stripe_value_monthly' => 'unlimited_monthly',
'stripe_value_yearly' => 'unlimited_yearly',
'badge' => 'For Clubs',
'features' => [
'Everything in Coach Plus',
'Unlimited players',
'Unlimited games',
'Unlimited game history',
'Unlimited lineup history',
'Unlimited lineup templates',
'Unlimited teams',
'Unlimited team members',
'Organization-friendly workflows',
'Priority support',
],
],
];
?>
<div class="billing-grid plan-comparison-grid">
<?php foreach ($plans as $planKey => $plan): ?>
<?php $isCurrent = $currentPlan === $planKey; ?>
<div class="card plan-card
<?= $isLoggedIn && $isCurrent ? 'current-plan' : '' ?>
<?= $planKey === 'coachplus' ? 'featured-plan' : '' ?>
">
<?php if ($plan['badge'] !== ''): ?>
<div class="plan-badge"><?= h($plan['badge']) ?></div>
<?php endif; ?>
<div class="plan-card-header">
<h2><?= h($plan['name']) ?></h2>
<p class="muted"><?= h($plan['tagline']) ?></p>
<div class="plan-price-stack">
<p class="plan-price"><?= h($plan['monthly']) ?><span>/mo</span></p>
<p class="plan-yearly-price"><?= h($plan['yearly']) ?>/year</p>
</div>
</div>
<ul class="plan-feature-list">
<?php foreach ($plan['features'] as $feature): ?>
<li><?= h($feature) ?></li>
<?php endforeach; ?>
</ul>
<div class="plan-card-footer">
<?php if ($isLoggedIn && $isCurrent): ?>
<span class="pill current">Current Plan</span>
<?php elseif ($planKey === 'free'): ?>
<span class="muted">Included with every account</span>
<?php else: ?>
<?php if ($isLoggedIn && $currentPlanKey !== ''): ?>
<form method="post" action="billing_start.php" class="plan-button-row">
<?= csrf_field() ?>
<input type="hidden" name="billing_plan" value="<?= h($plan['stripe_value_monthly']) ?>">
<input
type="text"
name="promo_code"
placeholder="Promo code"
class="promo-code-input"
>
<button type="submit" class="btn">Monthly</button>
</form>
<form method="post" action="billing_start.php" class="plan-button-row">
<?= csrf_field() ?>
<input type="hidden" name="billing_plan" value="<?= h($plan['stripe_value_yearly']) ?>">
<input
type="text"
name="promo_code"
placeholder="Promo code"
class="promo-code-input"
>
<button type="submit" class="btn btn-secondary">Yearly</button>
</form>
<?php endif; ?>
<?php endif; ?>
</div>
</div>
<?php endforeach; ?>
</div>
<div class="card plan-comparison-table-card">
<h2>Compare Plans</h2>
<div class="table-wrap">
<table class="plan-comparison-table">
<thead>
<tr>
<th>Feature</th>
<th>Free</th>
<th>Coach</th>
<th>Coach Plus</th>
<th>Unlimited</th>
</tr>
</thead>
<tbody>
<?php
$compareRows = [
['Monthly Price', '$0', '$5/mo', '$9/mo', '$19/mo'],
['Yearly Price', '$0', '$50/year', '$90/year', '$190/year'],
['Players per team', '10', '15', 'Unlimited', 'Unlimited'],
['Games per team', '10', '20', 'Unlimited', 'Unlimited'],
['Game History', '3', 'Past 10', 'Full', 'Full'],
['Lineup History', '3', '12', 'Full', 'Full'],
['Generate lineups', 'Yes', 'Yes', 'Yes', 'Yes'],
['Watermark-free printouts', 'No', 'Yes', 'Yes', 'Yes'],
['Branded Printout', 'No', 'Yes', 'Yes', 'Yes'],
['Lineup templates', '1', '5', '10', 'Unlimited'],
['Advanced lineup settings', 'No', 'No', 'Yes', 'Yes'],
['Pitch count tracking', 'No', 'Yes', 'Yes', 'Yes'],
['Full game history', 'No', 'No', 'Yes', 'Yes'],
['Additional Team members', '0', '1', '3', 'Unlimited'],
['Multiple teams', 'No', 'No', 'No', 'Yes'],
['Best for', 'Trying BenchBuddy', 'Single coach', 'Competitive coach', 'Clubs and organizations'],
];
?>
<?php foreach ($compareRows as $row): ?>
<tr>
<td><?= h($row[0]) ?></td>
<td data-title="Free"><?= h($row[1]) ?></td>
<td data-title="Coach"><?= h($row[2]) ?></td>
<td data-title="Coach Plus"><?= h($row[3]) ?></td>
<td data-title="Unlimited"><?= h($row[4]) ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
</div>
<?php if ($isLoggedIn && $currentPlanKey !== ''): ?>
<div class="card">
<h2>Manage Billing</h2>
<p class="muted">Update your payment method, view invoices, or manage your subscription.</p>
<form method="post" action="create_customer_portal.php">
<?= csrf_field() ?>
<button type="submit" class="btn btn-secondary">Manage Billing</button>
</form>
</div>
<?php endif; ?>
<?php endif; ?>
<?php require_once __DIR__ . '/includes/footer.php'; ?>