Strip Mini checkout to amount-only and use vendor email for Paystack.
Deploy Ladill Mini / deploy (push) Successful in 30s

Customers enter an amount and tap Pay; the merchant's account email (or notifications email from settings) is passed to Paystack instead of asking the payer for details.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
isaacclad
2026-06-07 20:22:16 +00:00
co-authored by Cursor
parent 52065b1ac1
commit f0bf96b438
5 changed files with 36 additions and 52 deletions
@@ -17,6 +17,7 @@ class PaymentController extends Controller
public function pay(Request $request, string $shortCode): RedirectResponse
{
$qrCode = QrCode::query()
->with('user.qrSetting')
->where('short_code', $shortCode)
->where('type', QrCode::TYPE_PAYMENT)
->where('is_active', true)
@@ -24,10 +25,6 @@ class PaymentController extends Controller
$validated = $request->validate([
'amount' => 'required|numeric|min:0.01',
'payer_email' => 'required|email|max:255',
'payer_name' => 'nullable|string|max:120',
'payer_phone' => 'nullable|string|max:32',
'payer_note' => 'nullable|string|max:255',
]);
try {
+10 -8
View File
@@ -19,7 +19,7 @@ class MiniPaymentService
) {}
/**
* @param array{payer_name?: string, payer_email: string, payer_phone?: string, payer_note?: string, amount: float} $data
* @param array{amount: float} $data
* @return array{payment: MiniPayment, checkout_url: string}
*/
public function initiate(QrCode $qrCode, array $data): array
@@ -33,9 +33,11 @@ class MiniPaymentService
throw new RuntimeException('Enter an amount greater than zero.');
}
$email = trim((string) ($data['payer_email'] ?? ''));
$qrCode->loadMissing('user.qrSetting');
$merchant = $qrCode->user;
$email = trim((string) ($merchant?->qrSetting?->notify_email ?: $merchant?->email));
if ($email === '' || ! str_contains($email, '@')) {
throw new RuntimeException('Enter a valid email address.');
throw new RuntimeException('This payment QR is not ready yet — the vendor must add an email in Ladill Mini settings.');
}
$amountMinor = (int) round($amountGhs * 100);
@@ -48,10 +50,10 @@ class MiniPaymentService
'reference' => $reference,
'amount_minor' => $amountMinor,
'currency' => $qrCode->content()['currency'] ?? 'GHS',
'payer_name' => trim((string) ($data['payer_name'] ?? '')) ?: null,
'payer_email' => $email,
'payer_phone' => trim((string) ($data['payer_phone'] ?? '')) ?: null,
'payer_note' => trim((string) ($data['payer_note'] ?? '')) ?: null,
'payer_name' => null,
'payer_email' => null,
'payer_phone' => null,
'payer_note' => null,
'status' => MiniPayment::STATUS_PENDING,
'payment_reference' => $payRef,
]);
@@ -111,7 +113,7 @@ class MiniPaymentService
'pay',
$paymentReference,
$payment->id,
sprintf('Payment via %s — %s', $businessName, $payment->payer_name ?: 'Customer'),
sprintf('Payment via %s', $businessName),
);
if ($payment->payer_phone) {
+1 -1
View File
@@ -37,7 +37,7 @@
@foreach($recentPayments as $payment)
<div class="flex items-center justify-between px-6 py-4">
<div>
<p class="font-medium text-slate-900">{{ $payment->payer_name ?: 'Customer' }}</p>
<p class="font-medium text-slate-900">{{ $payment->payer_name ?: 'Walk-in customer' }}</p>
<p class="text-xs text-slate-500">{{ $payment->qrCode?->label }} · {{ $payment->paid_at?->diffForHumans() }}</p>
</div>
<span class="text-sm font-semibold text-emerald-700">{{ $fmt($payment->merchant_amount_minor) }}</span>
+4 -2
View File
@@ -27,8 +27,10 @@
<tr>
<td class="px-6 py-4 text-slate-600">{{ $payment->paid_at?->format('M j, g:i A') ?? $payment->created_at->format('M j, g:i A') }}</td>
<td class="px-6 py-4">
<p class="font-medium text-slate-900">{{ $payment->payer_name ?: '' }}</p>
<p class="text-xs text-slate-500">{{ $payment->payer_email }}</p>
<p class="font-medium text-slate-900">{{ $payment->payer_name ?: 'Walk-in customer' }}</p>
@if($payment->payer_email)
<p class="text-xs text-slate-500">{{ $payment->payer_email }}</p>
@endif
</td>
<td class="px-6 py-4 text-slate-600">{{ $payment->qrCode?->label }}</td>
<td class="px-6 py-4 text-slate-500">{{ $payment->payer_note ?: '—' }}</td>
@@ -7,60 +7,43 @@
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
<title>Pay {{ $businessName }}</title>
@vite(['resources/css/app.css'])
</head>
<body class="min-h-screen bg-gradient-to-b from-slate-50 to-white text-slate-900">
<main class="mx-auto flex min-h-screen max-w-md flex-col justify-center px-4 py-10">
<div class="rounded-3xl border border-slate-200 bg-white p-6 shadow-sm">
<body class="min-h-screen bg-slate-50 text-slate-900">
<main class="mx-auto flex min-h-screen max-w-sm flex-col justify-center px-4 py-8">
<div class="rounded-3xl border border-slate-200/80 bg-white p-6 shadow-sm">
<div class="text-center">
@if(!empty($content['logo_path']))
<img src="{{ route('qr.public.payment.logo', $qrCode->short_code) }}" alt="" class="mx-auto h-16 w-16 rounded-2xl object-cover">
<img src="{{ route('qr.public.payment.logo', $qrCode->short_code) }}" alt="" class="mx-auto h-14 w-14 rounded-2xl object-cover">
@endif
<h1 class="mt-4 text-xl font-bold text-slate-900">{{ $businessName }}</h1>
<h1 class="mt-3 text-lg font-bold text-slate-900">{{ $businessName }}</h1>
@if(!empty($content['branch_label']))
<p class="mt-1 text-sm text-slate-500">{{ $content['branch_label'] }}</p>
<p class="mt-0.5 text-sm text-slate-500">{{ $content['branch_label'] }}</p>
@endif
<p class="mt-2 text-sm text-slate-500">Enter an amount and pay securely.</p>
</div>
@if(session('error'))
<div class="mt-4 rounded-xl bg-red-50 px-4 py-3 text-sm text-red-700">{{ session('error') }}</div>
@endif
<form method="post" action="{{ route('qr.public.payment.pay', $qrCode->short_code) }}" class="mt-6 space-y-4">
<form method="post" action="{{ route('qr.public.payment.pay', $qrCode->short_code) }}" class="mt-6">
@csrf
<div>
<label class="block text-sm font-medium text-slate-700">Amount ({{ $currency }})</label>
<input type="number" name="amount" step="0.01" min="0.01" required
class="mt-1 w-full rounded-xl border-slate-200 text-lg font-semibold focus:border-indigo-500 focus:ring-indigo-500"
<label for="amount" class="sr-only">Amount ({{ $currency }})</label>
<div class="relative">
<span class="pointer-events-none absolute inset-y-0 left-0 flex items-center pl-4 text-lg font-semibold text-slate-400">{{ $currency }}</span>
<input type="number" id="amount" name="amount" step="0.01" min="0.01" required autofocus
inputmode="decimal"
class="w-full rounded-2xl border-slate-200 py-4 pl-16 pr-4 text-3xl font-bold tracking-tight text-slate-900 focus:border-indigo-500 focus:ring-indigo-500"
placeholder="0.00" value="{{ old('amount') }}">
</div>
<div>
<label class="block text-sm font-medium text-slate-700">Your email</label>
<input type="email" name="payer_email" required value="{{ old('payer_email') }}"
class="mt-1 w-full rounded-xl border-slate-200 text-sm focus:border-indigo-500 focus:ring-indigo-500">
</div>
<div>
<label class="block text-sm font-medium text-slate-700">Name (optional)</label>
<input type="text" name="payer_name" value="{{ old('payer_name') }}"
class="mt-1 w-full rounded-xl border-slate-200 text-sm focus:border-indigo-500 focus:ring-indigo-500">
</div>
<div>
<label class="block text-sm font-medium text-slate-700">Phone (optional)</label>
<input type="tel" name="payer_phone" value="{{ old('payer_phone') }}"
class="mt-1 w-full rounded-xl border-slate-200 text-sm focus:border-indigo-500 focus:ring-indigo-500">
</div>
<div>
<label class="block text-sm font-medium text-slate-700">Note / reference (optional)</label>
<input type="text" name="payer_note" value="{{ old('payer_note') }}" maxlength="255"
class="mt-1 w-full rounded-xl border-slate-200 text-sm focus:border-indigo-500 focus:ring-indigo-500"
placeholder="e.g. Invoice #123">
</div>
<button type="submit" class="w-full rounded-xl bg-indigo-600 py-3 text-sm font-semibold text-white hover:bg-indigo-700">
Continue to pay
<button type="submit" class="mt-4 w-full rounded-2xl bg-indigo-600 py-4 text-base font-semibold text-white hover:bg-indigo-700">
Pay
</button>
</form>
<p class="mt-4 text-center text-[11px] text-slate-400">Secured by Paystack · Powered by Ladill Mini</p>
<p class="mt-4 text-center text-[11px] text-slate-400">Secured by Paystack</p>
</div>
</main>
</body>