Add Stripe webhook idempotency persistence guard

This commit is contained in:
ي
2026-03-05 11:17:21 +05:30
parent 81052d06b4
commit 45dbf095f6
2 changed files with 101 additions and 18 deletions

View File

@@ -408,3 +408,17 @@ class FraudWarning(Base):
reason_notes = Column(Text, nullable=True)
meta_info = Column(JSON, nullable=True)
created_at = Column(DateTime, default=datetime.utcnow)
class StripeWebhookEvent(Base):
"""Processed Stripe webhook events for idempotency and replay protection."""
__tablename__ = "stripe_webhook_events"
event_id = Column(String(100), primary_key=True)
event_type = Column(String(100), nullable=False)
status = Column(String(20), nullable=False, default="processing") # processing, processed, failed
error_message = Column(Text, nullable=True)
processed_at = Column(DateTime, nullable=True)
created_at = Column(DateTime, default=datetime.utcnow, nullable=False)