{{ $businessName }}
+{{ $businessName }}
@if(!empty($content['branch_label'])) -{{ $content['branch_label'] }}
+{{ $content['branch_label'] }}
@endif -Enter an amount and pay securely.
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() }}
{{ $payment->payer_name ?: '—' }}
-{{ $payment->payer_email }}
+{{ $payment->payer_name ?: 'Walk-in customer' }}
+ @if($payment->payer_email) +{{ $payment->payer_email }}
+ @endif{{ $content['branch_label'] }}
+{{ $content['branch_label'] }}
@endif -Enter an amount and pay securely.