diff --git a/app/Http/Controllers/Public/PaymentController.php b/app/Http/Controllers/Public/PaymentController.php index f6dde12..e9f0917 100644 --- a/app/Http/Controllers/Public/PaymentController.php +++ b/app/Http/Controllers/Public/PaymentController.php @@ -5,6 +5,7 @@ namespace App\Http\Controllers\Public; use App\Http\Controllers\Controller; use App\Models\QrCode; use App\Services\Mini\MiniPaymentService; +use Illuminate\Http\JsonResponse; use Illuminate\Http\RedirectResponse; use Illuminate\Http\Request; use Illuminate\View\View; @@ -14,7 +15,7 @@ class PaymentController extends Controller { public function __construct(private MiniPaymentService $payments) {} - public function pay(Request $request, string $shortCode): RedirectResponse + public function pay(Request $request, string $shortCode): JsonResponse|RedirectResponse { $qrCode = QrCode::query() ->with('user.qrSetting') @@ -30,9 +31,17 @@ class PaymentController extends Controller try { $result = $this->payments->initiate($qrCode, $validated); } catch (RuntimeException $e) { + if ($request->expectsJson()) { + return response()->json(['error' => $e->getMessage()], 422); + } + return back()->withInput()->with('error', $e->getMessage()); } + if ($request->expectsJson()) { + return response()->json(['checkout_url' => $result['checkout_url']]); + } + return redirect()->away($result['checkout_url']); } diff --git a/resources/views/partials/mini-paystack-frame-footer.blade.php b/resources/views/partials/mini-paystack-frame-footer.blade.php new file mode 100644 index 0000000..dcdea4b --- /dev/null +++ b/resources/views/partials/mini-paystack-frame-footer.blade.php @@ -0,0 +1,3 @@ +
+

Secured by Paystack · Powered by Ladill Mini

+
diff --git a/resources/views/partials/mini-paystack-frame-header.blade.php b/resources/views/partials/mini-paystack-frame-header.blade.php new file mode 100644 index 0000000..d954b70 --- /dev/null +++ b/resources/views/partials/mini-paystack-frame-header.blade.php @@ -0,0 +1,18 @@ +
+
+
+
+ Ladill Mini +

Complete payment

+
+ +
+
diff --git a/resources/views/partials/paystack-sheet.blade.php b/resources/views/partials/paystack-sheet.blade.php index 559bf73..5486563 100644 --- a/resources/views/partials/paystack-sheet.blade.php +++ b/resources/views/partials/paystack-sheet.blade.php @@ -1,54 +1,72 @@ {{-- - Paystack mobile bottom-sheet iframe. + Paystack checkout wrapper — bottom sheet on mobile, centered modal on desktop. Requires Alpine.js ancestor with: showSheet (bool), checkoutUrl (string). - On mobile (< md) the sheet slides up; on desktop nothing renders. --}} diff --git a/resources/views/public/qr/payment-landing.blade.php b/resources/views/public/qr/payment-landing.blade.php index 1e1d6fd..cb6533b 100644 --- a/resources/views/public/qr/payment-landing.blade.php +++ b/resources/views/public/qr/payment-landing.blade.php @@ -2,17 +2,102 @@ $content = $qrCode->content(); $businessName = $content['business_name'] ?? $qrCode->label; $currency = $content['currency'] ?? 'GHS'; + $payUrl = route('qr.public.payment.pay', $qrCode->short_code); + $csrf = csrf_token(); @endphp + Pay {{ $businessName }} - @vite(['resources/css/app.css']) + @vite(['resources/css/app.css', 'resources/js/app.js']) - -
+ + + {{-- Mobile: merchant header + bottom sheet --}} +
+
+ @if(!empty($content['logo_path'])) + + @endif +

{{ $businessName }}

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

{{ $content['branch_label'] }}

+ @endif +
+ +
+
+ +
+ + +
+ {{ $currency }} + +
+ + + +

Secured by Paystack · Powered by Ladill Mini

+
+
+ + {{-- Desktop: centered card --}} +
@if(!empty($content['logo_path'])) @@ -24,27 +109,32 @@ @endif
- @if(session('error')) -
{{ session('error') }}
- @endif +
-
- @csrf - +
+
{{ $currency }} - + placeholder="0.00">
- - +

Secured by Paystack · Powered by Ladill Mini

+ + @include('partials.paystack-sheet')