Files
ladill-mini/resources/views/public/qr/payment-landing.blade.php
T
isaacclad bd8764523c
Deploy Ladill Mini / deploy (push) Successful in 44s
Fix Paystack Fullscreen permission policy for Inline iframes.
Pre-set allow=fullscreen on Paystack iframes before navigation (createElement
hook + MutationObserver on allow/src/id), re-apply if Paystack overwrites
allow, and send Permissions-Policy HTTP headers so checkout.paystack.com can
use fullscreen inside the in-app sheet.
2026-07-21 22:17:14 +00:00

139 lines
8.0 KiB
PHP

@php
$content = $qrCode->content();
$businessName = $content['business_name'] ?? $qrCode->label;
$currency = $content['currency'] ?? 'GHS';
// Public scans stay on ladl.link/{code} (HTML proxied to Mini). Prefer a
// same-origin pay path so fetch() does not cross to mini.ladill.com.
// Direct visits on mini.ladill.com keep the local /q/{code}/pay route.
$isProxiedPublicScan = request()->headers->get('X-Ladill-Internal') === '1';
$payUrl = $isProxiedPublicScan
? '/'.$qrCode->short_code.'/pay'
: url('/q/'.$qrCode->short_code.'/pay');
$csrf = csrf_token();
@endphp
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
<meta name="csrf-token" content="{{ $csrf }}">
{{-- Permissions-Policy for Paystack is set as an HTTP header (middleware + nginx).
Meta http-equiv is not reliably applied by browsers for this feature. --}}
<title>Pay {{ $businessName }}</title>
<link rel="preconnect" href="https://fonts.bunny.net">
<link href="https://fonts.bunny.net/css?family=figtree:400,500,600,700&display=swap" rel="stylesheet" />
<style>[x-cloak]{display:none!important}</style>
@vite(['resources/css/app.css', 'resources/js/app.js'])
</head>
<body class="min-h-screen bg-slate-50 font-sans text-slate-900 antialiased"
x-data="miniPaymentLanding({
payUrl: @js($payUrl),
csrf: @js($csrf),
amount: @js(old('amount', session('amount'))),
errorMsg: @js(session('error')),
bootstrapCheckoutUrl: @js(session('checkout_url')),
bootstrapAccessCode: @js(session('access_code')),
bootstrapPublicKey: @js(session('public_key')),
bootstrapCallbackUrl: @js(session('callback_url')),
bootstrapProvider: @js(session('provider', 'paystack')),
})">
{{-- Mobile: Ladill Mini branding + fixed payment sheet --}}
<div class="md:hidden">
<div class="fixed inset-0 overflow-hidden bg-slate-50">
<div class="flex h-full flex-col items-center justify-center px-6 pb-72 text-center pt-[max(2.5rem,env(safe-area-inset-top))]">
<img src="{{ asset('images/launcher-icons/mini.svg') }}?v={{ @filemtime(public_path('images/launcher-icons/mini.svg')) ?: '1' }}"
alt="Ladill Mini" class="h-14 w-14 object-contain">
<h1 class="mt-4 text-xl 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>
@endif
</div>
</div>
<div class="mini-payment-bottom-bleed md:hidden"
:style="sheetBleedStyle"
aria-hidden="true"></div>
<div class="mini-payment-sheet rounded-t-3xl border-t border-slate-200/80 bg-white px-5 pt-3 shadow-[0_-12px_40px_rgba(15,23,42,0.12)] md:hidden"
:style="paymentSheetStyle">
<div class="mx-auto mb-4 h-1 w-10 rounded-full bg-slate-200"></div>
{{-- Always-visible (no x-cloak) server/client error so failures are never silent --}}
<div class="mb-4 rounded-xl bg-red-50 px-4 py-3 text-sm text-red-700"
x-show="errorMsg"
x-text="errorMsg"
@if(session('error')) style="display:block" @else style="display:none" @endif>{{ session('error') }}</div>
<form method="POST" action="{{ $payUrl }}" @submit.prevent="submitPay()" class="space-y-0">
@csrf
<label for="amount-mobile" 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-mobile" name="amount" x-model="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>
<button type="submit" :disabled="loading"
class="mt-4 flex w-full items-center justify-center gap-2 rounded-2xl bg-indigo-600 py-4 text-base font-semibold text-white hover:bg-indigo-700 disabled:opacity-60">
<svg x-show="loading" class="h-4 w-4 animate-spin" fill="none" viewBox="0 0 24 24" style="display:none">
<circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
<path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"></path>
</svg>
<span x-text="loading ? 'Opening payment…' : 'Pay'">Pay</span>
</button>
</form>
<p class="mt-3 text-center text-[11px] text-slate-400">Your payment is processed securely</p>
</div>
</div>
{{-- Desktop: centered card --}}
<main class="mx-auto hidden min-h-screen max-w-sm flex-col justify-center px-4 py-8 md:flex">
<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="{{ $qrCode->publicPath('payment-logo') }}" alt="" class="mx-auto h-14 w-14 rounded-2xl object-cover">
@endif
<h1 class="mt-3 text-lg font-bold text-slate-900">{{ $businessName }}</h1>
@if(!empty($content['branch_label']))
<p class="mt-0.5 text-sm text-slate-500">{{ $content['branch_label'] }}</p>
@endif
</div>
<div class="mt-4 rounded-xl bg-red-50 px-4 py-3 text-sm text-red-700"
x-show="errorMsg"
x-text="errorMsg"
@if(session('error')) style="display:block" @else style="display:none" @endif>{{ session('error') }}</div>
<form method="POST" action="{{ $payUrl }}" @submit.prevent="submitPay()" class="mt-6">
@csrf
<label for="amount-desktop" 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-desktop" name="amount" x-model="amount" step="0.01" min="0.01" required
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>
<button type="submit" :disabled="loading"
class="mt-4 flex w-full items-center justify-center gap-2 rounded-2xl bg-indigo-600 py-4 text-base font-semibold text-white hover:bg-indigo-700 disabled:opacity-60">
<svg x-show="loading" class="h-4 w-4 animate-spin" fill="none" viewBox="0 0 24 24" style="display:none">
<circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
<path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"></path>
</svg>
<span x-text="loading ? 'Opening payment…' : 'Pay'">Pay</span>
</button>
</form>
<p class="mt-4 text-center text-[11px] text-slate-400">Your payment is processed securely</p>
</div>
</main>
@include('partials.paystack-sheet')
</body>
</html>