2020 * the now unlocked content is displayed.
2121 * 3. Finally, the render() method is called on the container to display the button.
2222 */
23+
24+ /* Show/Hide Verification Overlay*/
25+ function showPBVerificationOverlay ( msg = "Verifying Payment..." ) {
26+ const el = document . getElementById ( 'paybutton_overlay' ) ;
27+ if ( ! el ) return ;
28+ document . getElementById ( 'paybutton_overlay_text' ) . innerText = msg ;
29+ el . style . display = 'block' ;
30+ }
31+
32+ function hidePBVerificationOverlay ( ) {
33+ const el = document . getElementById ( 'paybutton_overlay' ) ;
34+ if ( ! el ) return ;
35+ el . style . display = 'none' ;
36+ }
37+
2338jQuery ( document ) . ready ( function ( $ ) {
2439 $ ( '.paybutton-container' ) . each ( function ( ) {
2540 var $container = $ ( this ) ;
@@ -37,6 +52,10 @@ jQuery(document).ready(function($) {
3752 // Shared state: user wallet address + unlock tx captured in onSuccess.
3853 let unlockAddr = null ;
3954 let unlockTx = null ;
55+ // Check if the unlock flow has completed to avoid showing the verification overlay.
56+ let unlockFlowCompleted = false ;
57+ // Track if a payment was actually initiated
58+ let paymentInitiated = false ;
4059
4160 // Helper to fetch and inject unlocked content
4261 function fetchUnlocked ( ) {
@@ -108,6 +127,7 @@ jQuery(document).ready(function($) {
108127 autoClose : configData . autoClose ,
109128
110129 onSuccess : function ( tx ) {
130+ paymentInitiated = true ;
111131 unlockAddr = ( tx . inputAddresses && tx . inputAddresses . length > 0 )
112132 ? tx . inputAddresses [ 0 ]
113133 : '' ;
@@ -157,6 +177,8 @@ jQuery(document).ready(function($) {
157177 success : function ( ) {
158178 // Finally, fetch and render the unlocked content
159179 fetchUnlocked ( ) ;
180+ unlockFlowCompleted = true ;
181+ hidePBVerificationOverlay ( ) ;
160182 }
161183 } ) ;
162184 } else {
@@ -171,6 +193,9 @@ jQuery(document).ready(function($) {
171193 } , nextDelay ) ;
172194 } else {
173195 alert ( '⚠️ Payment could not be verified on-chain. Please try again.' ) ;
196+ hidePBVerificationOverlay ( ) ;
197+ paymentInitiated = false ;
198+ unlockFlowCompleted = false ;
174199 }
175200 }
176201 }
@@ -187,6 +212,11 @@ jQuery(document).ready(function($) {
187212 unlockAddr = null ;
188213 unlockTx = null ;
189214 } ,
215+ onClose : function ( ) {
216+ if ( paymentInitiated && ! unlockFlowCompleted ) {
217+ showPBVerificationOverlay ( ) ;
218+ }
219+ } ,
190220 } ) ;
191221 } ) ;
192222} ) ;
0 commit comments