Skip to content

Add a 'Verification' overlay after login and content unlock#112

Merged
Klakurka merged 3 commits intomasterfrom
feat/add-payment-processing-overlay
Dec 14, 2025
Merged

Add a 'Verification' overlay after login and content unlock#112
Klakurka merged 3 commits intomasterfrom
feat/add-payment-processing-overlay

Conversation

@xecdev
Copy link
Collaborator

@xecdev xecdev commented Dec 13, 2025

This PR implements #108 by adding a "Payment Verification" overlay for Cashtab Login and content unlocking flows.

Test Plan:

  • Install the plugin
  • Login via Cashtab and check the login verification overlay
  • Unlock a content, if the webhook didn't arrive instantly a verification overlay will be shown until the unlock is done

Summary by CodeRabbit

  • New Features
    • Added a verification overlay (full-page backdrop, centered content, spinner and status text) that appears during payment/login verification and hides on completion or failure.
    • Overlay is invoked across login and unlock flows to provide clear, consistent feedback while processing.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Dec 13, 2025

Walkthrough

Adds a full-page payment-verification overlay: CSS rules, template markup, and JS show/hide helpers wired into login and unlock PayButton lifecycles to display during in-progress verification and hide on completion or failure.

Changes

Cohort / File(s) Summary
Overlay Styling
assets/css/paywall-styles.css
Appended CSS rules for a full-page verification overlay (#paybutton_overlay, inner/content containers), spinner (.paybutton_overlay_spinner) and @keyframes paybutton_spin, plus caption text styling.
Overlay Markup
templates/public/sticky-header.php
Added a closing </div> for the sticky header and new overlay HTML (#paybutton_overlay with nested .paybutton_overlay_inner, .paybutton_overlay_content, spinner and caption). Overlay rendered hidden by default.
Login overlay control
assets/js/paybutton-paywall-cashtab-login.js
Added public helpers showPBVerificationOverlay(msg) and hidePBVerificationOverlay(); introduced a paymentInitiated flag in renderLoginPaybutton; set it on onSuccess; on onClose when a payment was initiated, call showPBVerificationOverlay("Verifying login..."); hide/reset on retry failure.
Unlock overlay control & state
assets/js/paywalled-content.js
Added showPBVerificationOverlay(msg) and hidePBVerificationOverlay(); introduced unlockFlowCompleted and paymentInitiated flags; updated PayButton.render() to include onClose that shows the overlay when unlock not completed; hide overlay on verification success or final failure and set unlockFlowCompleted when done.

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant DOM as Overlay (DOM)
  participant PayButton
  participant Server

  User->>PayButton: open/login/unlock action
  PayButton->>PayButton: onSuccess -> mark paymentInitiated
  PayButton->>Server: request verification / token
  Note right of PayButton: async verification flow
  Server-->>PayButton: verification result (success/fail)
  alt success
    PayButton->>DOM: hide overlay (hidePBVerificationOverlay)
    PayButton->>User: reveal unlocked content
  else fail / closed before completion
    PayButton->>DOM: show overlay (showPBVerificationOverlay)
    Note right of DOM: spinner + message shown
    Server-->>PayButton: final failure
    PayButton->>DOM: hide overlay and reset flags
    PayButton->>User: show alert / error
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • Inspect initialization and all mutation sites for unlockFlowCompleted and paymentInitiated in assets/js/paywalled-content.js and assets/js/paybutton-paywall-cashtab-login.js.
  • Verify onClose and onSuccess paths consistently show/hide the overlay and handle error/retry branches without leaving the overlay visible.
  • Check templates/public/sticky-header.php insertion preserves DOM structure and does not break markup nesting or accessibility.
  • Quick visual check of CSS overlay (z-index, responsiveness, spinner animation).

Possibly related issues

Possibly related PRs

Suggested reviewers

  • Klakurka

Poem

🐰 I twitched my nose and spun a wheel,
A tiny spinner began to peal,
"Verifying," I hummed with a hop and a twitch,
CSS and JS made the pause feel rich,
Hooray — the overlay keeps things in stitch! 🎩✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Add a 'Verification' overlay after login and content unlock' accurately and directly describes the main change: introducing a verification overlay UI component for login and content unlock flows.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/add-payment-processing-overlay

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@xecdev xecdev self-assigned this Dec 13, 2025
@xecdev xecdev added the enhancement (UI/UX/feature) New feature or request label Dec 13, 2025
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
assets/js/paybutton-paywall-cashtab-login.js (1)

98-137: Overlay shown but never hidden when user closes without completing login.

If the user closes the PayButton modal without completing a transaction (loginAddr is null), the overlay is shown on line 100 but the if block (line 102) is skipped, leaving the overlay visible indefinitely with no way to dismiss it.

Add an else branch to hide the overlay when there's no transaction to validate:

         onClose: function () {
             // Show verification overlay immediately
             showPBVerificationOverlay("Verifying login...");

             if (loginAddr && loginTx && loginTx.hash) {
                 // ... validation logic
             }
+            else {
+                // No transaction to validate - hide overlay immediately
+                hidePBVerificationOverlay();
+            }
             // Safe to clear shared state (the flow above uses the copies)
             loginAddr = null;
             loginTx = null;
         }
🧹 Nitpick comments (4)
assets/js/paybutton-paywall-cashtab-login.js (1)

4-16: Code duplication with paywalled-content.js.

These overlay functions are duplicated in assets/js/paywalled-content.js (lines 25-36). Consider extracting them to a shared utility module to maintain DRY principles and ensure consistent behavior.

templates/public/sticky-header.php (1)

74-80: Consider adding accessibility attributes to the overlay.

The overlay lacks ARIA attributes for screen reader users. Consider adding role="dialog", aria-modal="true", and aria-live="polite" for the text element to announce status changes.

-<div id="paybutton_overlay" class="paybutton_overlay" style="display:none;">
+<div id="paybutton_overlay" class="paybutton_overlay" style="display:none;" role="dialog" aria-modal="true" aria-labelledby="paybutton_overlay_text">
     <div class="paybutton_overlay_inner">
         <div class="paybutton_overlay_content">
             <span class="paybutton_overlay_spinner"></span>
-            <p id="paybutton_overlay_text">Verifying Payment...</p>
+            <p id="paybutton_overlay_text" aria-live="polite">Verifying Payment...</p>
         </div>
     </div>
 </div>
assets/css/paywall-styles.css (1)

73-87: Consider respecting reduced motion preferences.

Users with motion sensitivity may find the continuous spinner animation uncomfortable. Adding a prefers-reduced-motion media query would improve accessibility.

@media (prefers-reduced-motion: reduce) {
    .paybutton_overlay_spinner {
        animation: none;
        border-color: #0074C2;
    }
}
assets/js/paywalled-content.js (1)

24-36: Duplicate overlay functions.

As noted, these functions are duplicated in assets/js/paybutton-paywall-cashtab-login.js. Consider consolidating into a shared module.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ff49711 and 8bdf26a.

📒 Files selected for processing (4)
  • assets/css/paywall-styles.css (1 hunks)
  • assets/js/paybutton-paywall-cashtab-login.js (3 hunks)
  • assets/js/paywalled-content.js (5 hunks)
  • templates/public/sticky-header.php (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (2)
assets/js/paybutton-paywall-cashtab-login.js (1)
assets/js/paywalled-content.js (2)
  • el (26-26)
  • el (33-33)
assets/js/paywalled-content.js (1)
assets/js/paybutton-paywall-cashtab-login.js (2)
  • el (6-6)
  • el (13-13)
🔇 Additional comments (2)
assets/js/paywalled-content.js (2)

55-56: LGTM on the flag initialization.

The unlockFlowCompleted flag is a good addition to track flow state. Just needs the complementary paymentInitiated flag as suggested above to handle the edge case.


174-179: LGTM on success path handling.

The overlay is correctly hidden after the content is fetched and the completion flag is properly set.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

♻️ Duplicate comments (1)
assets/js/paybutton-paywall-cashtab-login.js (1)

4-16: Duplicate: Extract overlay functions to a shared module.

These functions are duplicated from assets/js/paywalled-content.js (lines 24-36). See the review comment on that file for the recommended refactor.

🧹 Nitpick comments (1)
assets/js/paywalled-content.js (1)

177-182: Consider hiding the overlay after fetchUnlocked() completes.

The overlay is hidden immediately after calling fetchUnlocked() (line 179), but before the unlocked content is actually rendered. If fetchUnlocked() encounters a network or server error, the overlay disappears while the content remains locked, leaving the user without feedback.

Move the overlay cleanup into fetchUnlocked()'s completion callbacks:

                                         success: function () {
                                             // Finally, fetch and render the unlocked content
-                                            fetchUnlocked();
-                                            unlockFlowCompleted = true;
-                                            hidePBVerificationOverlay();
+                                            fetchUnlocked(function onComplete() {
+                                                unlockFlowCompleted = true;
+                                                hidePBVerificationOverlay();
+                                            }, function onError() {
+                                                unlockFlowCompleted = true;
+                                                hidePBVerificationOverlay();
+                                                alert('Content unlocked but failed to display. Please refresh the page.');
+                                            });
                                         }

You would need to update fetchUnlocked() to accept success/error callbacks.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8bdf26a and 0abdb4a.

📒 Files selected for processing (3)
  • assets/css/paywall-styles.css (1 hunks)
  • assets/js/paybutton-paywall-cashtab-login.js (4 hunks)
  • assets/js/paywalled-content.js (6 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • assets/css/paywall-styles.css
🧰 Additional context used
🧬 Code graph analysis (2)
assets/js/paybutton-paywall-cashtab-login.js (1)
assets/js/paywalled-content.js (3)
  • el (26-26)
  • el (33-33)
  • paymentInitiated (58-58)
assets/js/paywalled-content.js (1)
assets/js/paybutton-paywall-cashtab-login.js (3)
  • el (6-6)
  • el (13-13)
  • paymentInitiated (82-82)
🔇 Additional comments (6)
assets/js/paywalled-content.js (3)

55-58: LGTM! Addresses previous review feedback.

The addition of the paymentInitiated flag correctly addresses the previous review concern about the overlay being stuck when users close the PayButton modal without completing payment. The state management is clear and appropriately scoped.


194-197: Appropriate error handling with user feedback.

The overlay is correctly hidden before showing the alert, providing clear feedback when verification fails.


213-217: LGTM! Correctly implements the fix from previous review.

The onClose handler now properly checks both paymentInitiated and !unlockFlowCompleted before showing the overlay, preventing the issue where the overlay would be stuck if the user closed the modal without completing payment.

assets/js/paybutton-paywall-cashtab-login.js (3)

81-82: LGTM! Appropriate state management for login flow.

The paymentInitiated flag is correctly scoped and initialized. The simpler flag structure (no unlockFlowCompleted) is appropriate since the login flow triggers a page reload in handleLogin().


102-105: LGTM! Overlay behavior appropriate for login flow.

The overlay correctly appears when paymentInitiated is true. Note that on successful login, the overlay remains visible until the page reloads (called in handleLogin), which is the expected behavior.


129-132: Clear error feedback.

The overlay is appropriately hidden before showing the error alert to the user.

@xecdev xecdev requested a review from Klakurka December 13, 2025 16:43
@xecdev xecdev linked an issue Dec 13, 2025 that may be closed by this pull request
@Klakurka Klakurka merged commit 7716eb6 into master Dec 14, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement (UI/UX/feature) New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a 'Verification' overlay after login and content unlock

2 participants