summaryrefslogtreecommitdiff
path: root/Biz/PodcastItLater/Billing.py
AgeCommit message (Collapse)Author
36 hoursSimplify Stripe portal error handling and fix account page paddingBen Sima
- Remove user-facing error messages for portal configuration - Just log the error server-side and return 500 status - Use Bootstrap card-header class for proper padding on section headers - This fixes icons touching the card borders Portal errors will now be logged but won't break the UI. Amp-Thread-ID: https://ampcode.com/threads/T-8edacbeb-b343-49ca-b524-1c999272acb6 Co-authored-by: Amp <amp@ampcode.com>
36 hoursAdd error handling for unconfigured Stripe billing portalBen Sima
- Catch Stripe exceptions when portal not configured - Redirect to account page with user-friendly error message - Display error alert on account page when present - Change portal return URL to /account instead of / Fixes issue when Stripe billing portal settings haven't been configured in test/production dashboard. Amp-Thread-ID: https://ampcode.com/threads/T-8edacbeb-b343-49ca-b524-1c999272acb6 Co-authored-by: Amp <amp@ampcode.com>
37 hoursImprove type safety in Billing moduleBen Sima
- Add explicit type annotations to TIER_LIMITS dict - Add type annotation to tier_info dict in get_tier_info - Remove unnecessary type: ignore comments - Use .get() consistently for dict access Improves type safety and removes 3 type: ignore suppressions. Amp-Thread-ID: https://ampcode.com/threads/T-8edacbeb-b343-49ca-b524-1c999272acb6 Co-authored-by: Amp <amp@ampcode.com>
39 hoursSimplify billing to single paid planBen Sima
- Remove /billing page and BillingPage component - Add callout box on home page showing articles remaining for free users - Upgrade Now button goes directly to Stripe checkout - Change tier from 'pro' to 'paid' throughout - Update redirect URLs to go to / instead of /billing - Remove Billing button from navbar, add Manage Account link for all users - Add /account route with coming soon page - Hide payment banner for paid users Amp-Thread-ID: https://ampcode.com/threads/T-7de89e42-947c-4243-be19-0cb75be607e7 Co-authored-by: Amp <amp@ampcode.com>
41 hoursSwitch to just one paid planBen Sima
I don't need the complexity of multiple plans, just one for now to test.
41 hoursCleanup some logging setup codeBen Sima
I think the calls to Log.setup() were accidentally creating multiple loggers, hopefully this fixes the problem.
2 daysUpdate webhook test to match real Stripe API behaviorBen Sima
- Use billing_cycle_anchor instead of current_period_start/end in test - Reflects actual Stripe API v2025-10-29 subscription structure - Test validates upgrade flow works with newer API versions - Removes debug logging (list of available keys)
2 daysFix subscription webhook to handle Stripe API version differencesBen Sima
- Use billing_cycle_anchor or start_date as fallback for period start - Calculate period end by adding 1 month if not provided - Handles newer Stripe API versions that don't include current_period_* fields - Fixes issue where subscription.created webhook couldn't update user plan - Works with Stripe API Version 2025-10-29.clover and newer
2 daysAdd detailed logging for missing subscription period datesBen Sima
Log available keys when period dates are missing to help debug why subscription webhooks fail to update user plan.
2 daysAdd full checkout flow test with proper client_reference_idBen Sima
- Test simulates complete Stripe checkout flow end-to-end - Step 1: checkout.session.completed with client_reference_id - Step 2: customer.subscription.created with subscription details - Verifies customer linking and plan upgrade to pro tier - Tests ensure webhook flow works without calling real Stripe API - Validates that client_reference_id properly links session to user
2 daysFix TypeError in checkout webhook when client_reference_id is NoneBen Sima
- Handle case where client_reference_id is None or missing - Fall back to checking metadata.user_id if client_reference_id not available - Add try/except for int() conversion with proper error logging - Use safe .get() for session ID in error messages - Prevents TypeError: int() argument must be a string when webhook has None value
2 daysAllow webhook signature verification bypass for local testingBen Sima
- Skip signature verification if STRIPE_WEBHOOK_SECRET is not set - Add warning log when verification is skipped - Parse webhook payload as JSON directly in test mode - Enables local testing with 'stripe trigger' without configuring webhook secret - Production still requires proper webhook secret for security
2 daysAdd Stripe webhook tests and testing documentationBen Sima
- Add TestWebhookHandling class with tests for subscription webhooks - Test normal subscription creation flow with mock data - Test handling of incomplete webhook data (missing fields) - Add STRIPE_TESTING.md with comprehensive testing guide: - How to use Stripe test mode and test cards - How to use Stripe CLI to trigger test webhooks - Instructions for running unit tests - Database migration instructions for production - End-to-end testing workflow - Common troubleshooting issues Tests verify webhook handling works without calling real Stripe API.
2 daysFix Stripe webhook KeyError by using safe dict accessBen Sima
- Replace direct dict key access with .get() for all subscription fields - Add validation and early return for missing required fields - Add logging warnings when subscription data is incomplete - Handles both dict and Stripe object access patterns safely - Fixes KeyError: 'current_period_start' when processing webhooks
3 daysRemove personal tier, keep only free and proBen Sima
Simplified pricing to two tiers: - Free: 10 articles total (lifetime) - Pro: $29/month unlimited articles Removed STRIPE_PRICE_ID_PERSONAL from configuration.
3 daysChange free plan from monthly to lifetime limitBen Sima
Free tier now has 10 articles total (lifetime) instead of 10 per month. Period boundaries for free users now span from account creation to far future.
5 daysfeat: Add stripe to Python deps and document dependency processBen Sima
- Add stripe to Omni/Bild/Deps/Python.nix (alphabetically sorted) - Fix all type annotations in Billing.py for mypy - Document how to add Python packages in AGENTS.md - Add billing routes to Web.py (checkout, portal, webhook) This enables Stripe integration in PodcastItLater. Related to task t-144e7lF
6 daysfeat(PodcastItLater): Add Stripe billing infrastructureBen Sima
Add complete Stripe integration backend ready for testing once stripe package is available in Nix environment. Components: - Billing.py: Stripe Checkout, Billing Portal, webhook handling - Database migrations for subscription tracking - Usage tracking with tier-based limits - Idempotent webhook processing with stripe_events table Tier limits: free (10/mo), personal (50/mo), pro (unlimited) Webhook events handled: - checkout.session.completed (link customer to user) - customer.subscription.{created,updated,deleted} (sync state) - invoice.payment_failed (mark past_due) Requires: Stripe Python package in Nix, Web.py routes (next commit) Related to task t-144e7lF Amp-Thread-ID: https://ampcode.com/threads/T-8feaca83-dcc2-46cb-8f71-d0785960a2f7 Co-authored-by: Amp <amp@ampcode.com>