diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index c45d8e65..f4151bc9 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -622,6 +622,9 @@ jobs:
distribution: "temurin"
java-version: "21"
+ - name: Install Firestore emulator
+ run: sudo apt-get install -y google-cloud-cli-firestore-emulator
+
- name: Install dependencies
run: poetry install
diff --git a/backend/services/stripe_admin_service.py b/backend/services/stripe_admin_service.py
index e7af4193..89dba66e 100644
--- a/backend/services/stripe_admin_service.py
+++ b/backend/services/stripe_admin_service.py
@@ -146,7 +146,7 @@ class StripeAdminService:
"refunded_at": None,
"refund_reason": None,
# Timestamps
- "created_at": datetime.utcnow(),
+ "created_at": datetime.utcfromtimestamp(session["created"]) if session.get("created") else datetime.utcnow(),
"processed_at": datetime.utcnow(),
# Metadata
"is_test": is_test,
diff --git a/frontend/app/admin/payments/page.tsx b/frontend/app/admin/payments/page.tsx
index e236c299..1806d3f7 100644
--- a/frontend/app/admin/payments/page.tsx
+++ b/frontend/app/admin/payments/page.tsx
@@ -266,7 +266,7 @@ function RevenueOverviewTab() {
) : chart.length > 0 ? (
-
+
diff --git a/frontend/components/admin/payment-detail.tsx b/frontend/components/admin/payment-detail.tsx
index 09d8cc3e..ac42631d 100644
--- a/frontend/components/admin/payment-detail.tsx
+++ b/frontend/components/admin/payment-detail.tsx
@@ -80,7 +80,7 @@ export function PaymentDetailSheet({ payment, onClose, onRefund }: PaymentDetail
return (
!open && onClose()}>
-
+
Payment Details
diff --git a/pyproject.toml b/pyproject.toml
index eb5c6d62..53064640 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -1,6 +1,6 @@
[tool.poetry]
name = "karaoke-gen"
-version = "0.125.1"
+version = "0.125.2"
description = "Generate karaoke videos with synchronized lyrics. Handles the entire process from downloading audio and lyrics to creating the final video with title screens."
authors = ["Andrew Beveridge "]
license = "MIT"
diff --git a/scripts/fix_backfill_dates.py b/scripts/fix_backfill_dates.py
new file mode 100644
index 00000000..0e5651fc
--- /dev/null
+++ b/scripts/fix_backfill_dates.py
@@ -0,0 +1,85 @@
+#!/usr/bin/env python3
+"""Fix backfilled stripe_payments created_at dates.
+
+The initial backfill stored datetime.utcnow() instead of the original
+Stripe session creation timestamp. This script fetches the real `created`
+timestamp from each Stripe session and updates the Firestore documents.
+
+Usage:
+ STRIPE_SECRET_KEY=... GOOGLE_CLOUD_PROJECT=nomadkaraoke python scripts/fix_backfill_dates.py [--dry-run]
+"""
+
+import os
+import sys
+import time
+import stripe
+from datetime import datetime, timezone
+from google.cloud import firestore
+
+def main():
+ dry_run = "--dry-run" in sys.argv
+
+ stripe.api_key = os.environ.get("STRIPE_SECRET_KEY")
+ if not stripe.api_key:
+ print("ERROR: STRIPE_SECRET_KEY not set")
+ sys.exit(1)
+
+ db = firestore.Client()
+ collection = db.collection("stripe_payments")
+
+ # Get all payment docs
+ docs = list(collection.stream())
+ print(f"Found {len(docs)} payment documents")
+
+ updated = 0
+ skipped = 0
+ errors = 0
+
+ for doc in docs:
+ data = doc.to_dict()
+ session_id = data.get("session_id", doc.id)
+
+ try:
+ # Fetch the Stripe session to get the real created timestamp
+ session = stripe.checkout.Session.retrieve(session_id)
+ real_created = datetime.fromtimestamp(session.created, tz=timezone.utc)
+
+ current_created = data.get("created_at")
+ # Check if dates differ by more than 1 hour (backfill vs real)
+ if current_created:
+ if hasattr(current_created, 'timestamp'):
+ diff = abs(current_created.timestamp() - session.created)
+ else:
+ diff = 999999 # force update if not a datetime
+
+ if diff < 3600:
+ skipped += 1
+ continue
+
+ if dry_run:
+ print(f" [DRY RUN] {session_id}: would update created_at to {real_created}")
+ updated += 1
+ else:
+ collection.document(doc.id).update({"created_at": real_created})
+ print(f" Updated {session_id}: created_at -> {real_created}")
+ updated += 1
+
+ # Rate limit
+ time.sleep(0.1)
+
+ except stripe.error.InvalidRequestError as e:
+ if "No such checkout.session" in str(e):
+ skipped += 1
+ else:
+ print(f" ERROR {session_id}: {e}")
+ errors += 1
+ except Exception as e:
+ print(f" ERROR {session_id}: {e}")
+ errors += 1
+
+ prefix = "[DRY RUN] " if dry_run else ""
+ print(f"\n{prefix}Done: {updated} updated, {skipped} skipped, {errors} errors")
+
+
+if __name__ == "__main__":
+ main()