From f0bf96b438ed0816a9c092d0f3054bcf013c1893 Mon Sep 17 00:00:00 2001 From: isaacclad Date: Sun, 7 Jun 2026 20:22:16 +0000 Subject: [PATCH] Strip Mini checkout to amount-only and use vendor email for Paystack. 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 --- .../Controllers/Public/PaymentController.php | 5 +- app/Services/Mini/MiniPaymentService.php | 18 +++--- resources/views/mini/dashboard.blade.php | 2 +- resources/views/mini/payments.blade.php | 6 +- .../views/public/qr/payment-landing.blade.php | 57 +++++++------------ 5 files changed, 36 insertions(+), 52 deletions(-) diff --git a/app/Http/Controllers/Public/PaymentController.php b/app/Http/Controllers/Public/PaymentController.php index 6eadc71..f6dde12 100644 --- a/app/Http/Controllers/Public/PaymentController.php +++ b/app/Http/Controllers/Public/PaymentController.php @@ -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 { diff --git a/app/Services/Mini/MiniPaymentService.php b/app/Services/Mini/MiniPaymentService.php index 4c7b54f..c50535d 100644 --- a/app/Services/Mini/MiniPaymentService.php +++ b/app/Services/Mini/MiniPaymentService.php @@ -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) { diff --git a/resources/views/mini/dashboard.blade.php b/resources/views/mini/dashboard.blade.php index 4643cde..e0248eb 100644 --- a/resources/views/mini/dashboard.blade.php +++ b/resources/views/mini/dashboard.blade.php @@ -37,7 +37,7 @@ @foreach($recentPayments as $payment)
-

{{ $payment->payer_name ?: 'Customer' }}

+

{{ $payment->payer_name ?: 'Walk-in customer' }}

{{ $payment->qrCode?->label }} · {{ $payment->paid_at?->diffForHumans() }}

{{ $fmt($payment->merchant_amount_minor) }} diff --git a/resources/views/mini/payments.blade.php b/resources/views/mini/payments.blade.php index e2f3bd3..388dbbd 100644 --- a/resources/views/mini/payments.blade.php +++ b/resources/views/mini/payments.blade.php @@ -27,8 +27,10 @@ {{ $payment->paid_at?->format('M j, g:i A') ?? $payment->created_at->format('M j, g:i A') }} -

{{ $payment->payer_name ?: '—' }}

-

{{ $payment->payer_email }}

+

{{ $payment->payer_name ?: 'Walk-in customer' }}

+ @if($payment->payer_email) +

{{ $payment->payer_email }}

+ @endif {{ $payment->qrCode?->label }} {{ $payment->payer_note ?: '—' }} diff --git a/resources/views/public/qr/payment-landing.blade.php b/resources/views/public/qr/payment-landing.blade.php index da260b1..b9dd98c 100644 --- a/resources/views/public/qr/payment-landing.blade.php +++ b/resources/views/public/qr/payment-landing.blade.php @@ -7,60 +7,43 @@ - + Pay {{ $businessName }} @vite(['resources/css/app.css']) - -
-
+ +
+
@if(!empty($content['logo_path'])) - + @endif -

{{ $businessName }}

+

{{ $businessName }}

@if(!empty($content['branch_label'])) -

{{ $content['branch_label'] }}

+

{{ $content['branch_label'] }}

@endif -

Enter an amount and pay securely.

+ @if(session('error'))
{{ session('error') }}
@endif -
+ + @csrf -
- - Amount ({{ $currency }}) +
+ {{ $currency }} +
-
- - -
-
- - -
-
- - -
-
- - -
- -

Secured by Paystack · Powered by Ladill Mini

+ +

Secured by Paystack