Present Paystack checkout in a responsive mobile sheet and desktop modal.
Deploy Ladill Give / deploy (push) Successful in 44s
Deploy Ladill Give / deploy (push) Successful in 44s
Standardize customer-facing Ladill Pay checkout shells across products, open them on all viewports, and escape iframe callbacks back to the product flow.
This commit is contained in:
@@ -3,11 +3,11 @@
|
||||
namespace App\Http\Controllers\Public;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\GiveDonation;
|
||||
use App\Models\QrCode;
|
||||
use App\Services\Give\GiveDonationService;
|
||||
use App\Support\LadillLink;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\View\View;
|
||||
use RuntimeException;
|
||||
@@ -50,21 +50,40 @@ class DonationController extends Controller
|
||||
]);
|
||||
}
|
||||
|
||||
public function callback(Request $request, string $shortCode): RedirectResponse|View
|
||||
public function callback(Request $request, string $shortCode): View
|
||||
{
|
||||
$reference = trim((string) $request->query('reference', ''));
|
||||
if ($reference === '') {
|
||||
return redirect()->away(LadillLink::url($shortCode))->with('error', 'Missing payment reference.');
|
||||
return view('public.payment-return', [
|
||||
'redirect' => LadillLink::url($shortCode),
|
||||
]);
|
||||
}
|
||||
|
||||
try {
|
||||
$donation = $this->donations->complete($reference);
|
||||
} catch (RuntimeException $e) {
|
||||
return redirect()->away(LadillLink::url($shortCode))->with('order_error', $e->getMessage());
|
||||
} catch (\Throwable) {
|
||||
return redirect()->away(LadillLink::url($shortCode))->with('order_error', 'Payment could not be verified. Contact the organisation with reference: '.$reference);
|
||||
return view('public.payment-return', [
|
||||
'redirect' => LadillLink::url($shortCode),
|
||||
]);
|
||||
}
|
||||
|
||||
return view('public.payment-return', [
|
||||
'redirect' => route('qr.public.donation.confirmed', [
|
||||
'shortCode' => $shortCode,
|
||||
'reference' => $donation->payment_reference,
|
||||
], absolute: true),
|
||||
]);
|
||||
}
|
||||
|
||||
public function confirmed(string $shortCode, string $reference): View
|
||||
{
|
||||
$donation = GiveDonation::query()
|
||||
->with('qrCode')
|
||||
->where('payment_reference', $reference)
|
||||
->where('status', GiveDonation::STATUS_PAID)
|
||||
->whereHas('qrCode', fn ($q) => $q->where('short_code', $shortCode))
|
||||
->firstOrFail();
|
||||
|
||||
return view('public.qr.donation-confirmed', [
|
||||
'donation' => $donation,
|
||||
'qrCode' => $donation->qrCode,
|
||||
|
||||
Reference in New Issue
Block a user