diff --git a/website/app/Http/Controllers/Account/BillingController.php b/website/app/Http/Controllers/Account/BillingController.php index 3cc291a..99e085d 100644 --- a/website/app/Http/Controllers/Account/BillingController.php +++ b/website/app/Http/Controllers/Account/BillingController.php @@ -76,6 +76,35 @@ class BillingController extends Controller return back()->with('success', 'Default payment method updated.'); } + public function paymentMethods(Request $request): Response + { + $user = $request->user(); + $paymentMethods = []; + $defaultPaymentMethod = null; + + if ($user->hasStripeId()) { + $methods = $user->paymentMethods(); + $defaultPm = $user->defaultPaymentMethod(); + $defaultPaymentMethod = $defaultPm?->id; + + foreach ($methods as $method) { + $paymentMethods[] = [ + 'id' => $method->id, + 'brand' => $method->card->brand ?? 'unknown', + 'last_four' => $method->card->last_four ?? '****', + 'exp_month' => $method->card->exp_month, + 'exp_year' => $method->card->exp_year, + 'is_default' => $method->id === $defaultPaymentMethod, + ]; + } + } + + return Inertia::render('Billing/PaymentMethods', [ + 'paymentMethods' => $paymentMethods, + 'defaultPaymentMethod' => $defaultPaymentMethod, + ]); + } + public function invoices(Request $request): Response { $invoices = $request->user() diff --git a/website/resources/ts/Pages/Billing/PaymentMethods.vue b/website/resources/ts/Pages/Billing/PaymentMethods.vue new file mode 100644 index 0000000..db438f7 --- /dev/null +++ b/website/resources/ts/Pages/Billing/PaymentMethods.vue @@ -0,0 +1,229 @@ + + + + + + + + + + Billing + + + + Payment Methods + + + Payment Methods + + + + Your Cards + + + + + No payment methods on file + + Payment methods are added automatically during checkout. + + + + + + + + + + + {{ pm.brand }} + ending in {{ pm.last_four }} + Default + + + Expires {{ pm.exp_month }}/{{ pm.exp_year }} + + + + + + Set as Default + + + Remove + + + + + + + + + + Add a New Card + + + + To add a new payment method, please use the checkout flow when purchasing a new plan, + or contact our support team for assistance. + + + + + + + + + + + Remove Payment Method + + + + Are you sure you want to remove this payment method? + + + + + + {{ deletingMethod.brand }} ending in {{ deletingMethod.last_four }} + + + Expires {{ deletingMethod.exp_month }}/{{ deletingMethod.exp_year }} + + + + + + + This is your default payment method. Removing it may affect active subscriptions. + + + + + + + Cancel + + + Remove + + + + + + diff --git a/website/resources/ts/navigation/account.ts b/website/resources/ts/navigation/account.ts index 14dcac8..fa4c29f 100644 --- a/website/resources/ts/navigation/account.ts +++ b/website/resources/ts/navigation/account.ts @@ -8,6 +8,7 @@ export const accountNavItems: VerticalNavItems = [ { heading: 'Billing' }, { title: 'Billing', to: '/billing', icon: 'tabler-credit-card' }, + { title: 'Payment Methods', to: '/billing/payment-methods', icon: 'tabler-wallet' }, { title: 'Plans', to: '/plans', icon: 'tabler-package' }, { heading: 'Support' }, diff --git a/website/routes/account.php b/website/routes/account.php index 02baf34..7b1a2ee 100644 --- a/website/routes/account.php +++ b/website/routes/account.php @@ -49,6 +49,7 @@ Route::get('/billing', [BillingController::class, 'index'])->name('account.billi Route::post('/billing/payment-methods', [BillingController::class, 'addPaymentMethod'])->name('account.billing.add-payment-method'); Route::delete('/billing/payment-methods/{paymentMethod}', [BillingController::class, 'removePaymentMethod'])->name('account.billing.remove-payment-method'); Route::post('/billing/payment-methods/default', [BillingController::class, 'setDefaultPaymentMethod'])->name('account.billing.set-default-payment-method'); +Route::get('/billing/payment-methods', [BillingController::class, 'paymentMethods'])->name('account.billing.payment-methods'); Route::get('/billing/invoices', [BillingController::class, 'invoices'])->name('account.billing.invoices'); Route::get('/billing/invoices/{invoice}/download', [BillingController::class, 'downloadInvoice'])->name('account.billing.invoices.download'); Route::get('/billing/transactions', [BillingController::class, 'transactions'])->name('account.billing.transactions');
+ Are you sure you want to remove this payment method? +