From ec8fe8611f9a0f5b7c2b87c3bac0bcc94b238d4e Mon Sep 17 00:00:00 2001 From: isaacclad Date: Tue, 21 Jul 2026 22:09:58 +0000 Subject: [PATCH] Allow Paystack checkout iframes to use fullscreen in POS. Patch Inline iframes after mount so fullscreen/payment permissions work inside the POS payment bottomsheet. --- .../views/partials/paystack-sheet.blade.php | 48 ++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) diff --git a/resources/views/partials/paystack-sheet.blade.php b/resources/views/partials/paystack-sheet.blade.php index a6724a2..aba40fd 100644 --- a/resources/views/partials/paystack-sheet.blade.php +++ b/resources/views/partials/paystack-sheet.blade.php @@ -147,6 +147,48 @@ activePopup = null; } + function ensurePaystackIframePermissions(root) { + try { + var nodes = (root || document).querySelectorAll( + 'iframe[src*="checkout.paystack.com"], iframe[id^="inline-checkout"], iframe[id^="inline-background"], iframe[src*="paystack"]' + ); + nodes.forEach(function (iframe) { + var allow = (iframe.getAttribute('allow') || '').trim(); + var needed = ['payment', 'fullscreen', 'clipboard-read', 'clipboard-write']; + var parts = allow ? allow.split(';').map(function (p) { return p.trim(); }).filter(Boolean) : []; + var lower = parts.map(function (p) { return p.toLowerCase(); }); + needed.forEach(function (perm) { + if (!lower.some(function (p) { return p === perm || p.indexOf(perm + ' ') === 0; })) { + parts.push(perm); + } + }); + iframe.setAttribute('allow', parts.join('; ')); + if (!iframe.hasAttribute('allowfullscreen')) { + iframe.setAttribute('allowfullscreen', ''); + } + }); + } catch (e) {} + } + + function watchPaystackIframes() { + if (window.__ladillPaystackIframeWatch) return; + window.__ladillPaystackIframeWatch = true; + ensurePaystackIframePermissions(document); + try { + var obs = new MutationObserver(function (mutations) { + for (var i = 0; i < mutations.length; i++) { + var m = mutations[i]; + if (m.addedNodes && m.addedNodes.length) { + ensurePaystackIframePermissions(document); + break; + } + } + }); + obs.observe(document.documentElement || document.body, { childList: true, subtree: true }); + } catch (e) {} + } + + function createStoreDefinition() { return { frameable: false, @@ -224,10 +266,12 @@ cancelInline(); var popup = new PaystackPop(); activePopup = popup; + watchPaystackIframes(); popup.resumeTransaction(accessCode, { onLoad: function () { if (token !== store._launchToken) return; store.launching = false; + ensurePaystackIframePermissions(document); }, onSuccess: function (transaction) { if (token !== store._launchToken) return; @@ -283,6 +327,8 @@ ensureStore(); } + watchPaystackIframes(); + window.LadillPayCheckout = { isFrameable: isFrameable, isPaystackCheckoutUrl: isPaystackCheckoutUrl, @@ -384,7 +430,7 @@ :src="showSheet && $store.ladillPayCheckout && $store.ladillPayCheckout.frameable ? checkoutUrl : ''" class="h-full min-h-[60dvh] w-full border-0 md:min-h-0" style="min-height: 28rem" - allow="payment *" + allow="payment *; fullscreen *; clipboard-read *; clipboard-write *" title="{{ $iframeTitle }}">