|
26 | 26 | <label><input type="checkbox" id="redirect-headless" /> Enable headless mode (skip “Continue to payment” / Pay; open PSP immediately)</label> |
27 | 27 | <label style="margin-left: 1.25rem;"><input type="checkbox" id="redirect-silent-failure" disabled /> Silent failure view (headless: no in-widget error; listen for <code>failure</code>)</label> |
28 | 28 | <label style="margin-left: 1.25rem;"><input type="checkbox" id="redirect-show-loader" checked disabled /> Show headless loader while opening PSP</label> |
| 29 | + <label style="margin-left: 1.25rem;"><input type="checkbox" id="redirect-popup-blocked-overlay" checked disabled /> SDK popup-blocked overlay (uncheck to suppress and handle <code>redirect-popup-blocked</code> yourself)</label> |
29 | 30 | <label><input type="checkbox" id="redirect-overlay-root" /> Mount PSP action overlay on <code>#action-overlay-root</code> instead of <code>document.body</code></label> |
30 | 31 | </div> |
31 | 32 | </fieldset> |
|
82 | 83 | const headless = document.getElementById('redirect-headless').checked; |
83 | 84 | document.getElementById('redirect-silent-failure').disabled = !headless; |
84 | 85 | document.getElementById('redirect-show-loader').disabled = !headless; |
| 86 | + document.getElementById('redirect-popup-blocked-overlay').disabled = !headless; |
85 | 87 | if (!headless) { |
86 | 88 | document.getElementById('redirect-silent-failure').checked = false; |
87 | 89 | document.getElementById('redirect-show-loader').checked = true; |
| 90 | + document.getElementById('redirect-popup-blocked-overlay').checked = true; |
88 | 91 | } |
89 | 92 | } |
90 | 93 |
|
|
103 | 106 | if (document.getElementById('redirect-headless').checked && !document.getElementById('redirect-show-loader').checked) { |
104 | 107 | redirect.showHeadlessLoader = false; |
105 | 108 | } |
| 109 | + if (document.getElementById('redirect-headless').checked && !document.getElementById('redirect-popup-blocked-overlay').checked) { |
| 110 | + redirect.popupBlockedOverlay = false; |
| 111 | + } |
106 | 112 | if (document.getElementById('redirect-overlay-root').checked) { |
107 | 113 | redirect.actionOverlayMountParent = document.getElementById('action-overlay-root'); |
108 | 114 | } |
|
211 | 217 | } |
212 | 218 | }) |
213 | 219 |
|
| 220 | + // redirect-popup-blocked fires when the headless auto-open was blocked by the browser |
| 221 | + // (e.g. Safari). By default the SDK shows its own Pay button overlay automatically. |
| 222 | + // When popupBlockedOverlay: false is set, handle it here instead. |
| 223 | + apm.on('redirect-popup-blocked', function (data) { |
| 224 | + if (document.getElementById('redirect-popup-blocked-overlay').checked) return; // SDK overlay is active |
| 225 | + // Example custom UI: a simple fixed overlay with a retry button |
| 226 | + var overlay = document.createElement('div'); |
| 227 | + overlay.style.cssText = 'position:fixed;inset:0;z-index:2147483647;display:flex;align-items:center;justify-content:center;padding:16px;background:rgba(0,0,0,0.5);'; |
| 228 | + var btn = document.createElement('button'); |
| 229 | + btn.textContent = 'Continue to payment'; |
| 230 | + btn.style.cssText = 'padding:0.75em 1.5em;font-size:1rem;cursor:pointer;'; |
| 231 | + btn.onclick = function () { |
| 232 | + overlay.remove(); |
| 233 | + data.retry(); |
| 234 | + }; |
| 235 | + overlay.appendChild(btn); |
| 236 | + document.body.appendChild(overlay); |
| 237 | + }) |
| 238 | + |
214 | 239 | try { |
215 | 240 | apm.initialise() |
216 | 241 | } catch (e) { |
|
0 commit comments