Paywall Integration Specification
This document outlines the plan to integrate st-paywall into the Wrdler application to enable subscription-based access.
1. Dependencies
Add st-paywall to the project dependencies.
- File:
pyproject.toml - Action: Add
st-paywallto thedependencieslist.
2. Configuration
Configure the payment provider (Stripe or Buy Me A Coffee) in Streamlit secrets.
- File:
.streamlit/secrets.toml(User needs to create this if not exists) - Content:
Note:[stripe] api_key = "sk_live_..." link = "https://buy.stripe.com/..." # OR [bmac] api_key = "..." link = "https://www.buymeacoffee.com/..."st-paywallexpects specific keys. Refer to documentation for exact structure.
3. Code Integration
Integrate the authentication and subscription check into the main UI flow.
- File:
wrdler/ui.py - Import:
from st_paywall import add_auth - Placement:
- The
add_authfunction should be called early in therun_appfunction or before rendering sensitive content. - It handles the login UI and subscription check.
- The
Integration Strategy
We will add a "Premium" toggle or check, or enforce it for the whole app depending on requirements. For now, we will document how to gate the entire app or specific premium features (like AI Wordlist generation).
Option A: Gate Entire App
Call add_auth(required=True) at the start of run_app.
Option B: Gate Premium Features
Call add_auth(required=False) to show the login/subscribe sidebar but allow free access. Then check st.session_state.user_subscribed (or similar provided by the library) before enabling features like:
- AI Wordlist Generation
- Challenge Mode creation
4. Implementation Plan
- Update
pyproject.toml: Addst-paywall. - Update
wrdler/ui.py:- Import
add_auth. - Insert
add_auth(...)call inrun_appor_render_sidebar. - (Optional) Wrap premium features with subscription checks.
- Import
5. Testing
- Verify that the login button appears.
- Verify that non-subscribed users are prompted to subscribe.
- Verify that subscribed users can access the content.
- Test with
testing_mode = truein secrets.