using MongoDB.Bson;
using MongoDB.Bson.Serialization.Attributes;

namespace Nalu.Web.Data.Models;

/// <summary>
/// Stripe webhook idempotency table. One document per Stripe event ID.
/// </summary>
public class WebhookEvent
{
    [BsonId]
    [BsonRepresentation(BsonType.ObjectId)]
    public string Id { get; set; } = ObjectId.GenerateNewId().ToString();

    [BsonElement("stripe_event_id")]
    public required string StripeEventId { get; set; }

    [BsonElement("event_type")]
    public required string EventType { get; set; }

    /// "processed" | "failed" | "ignored"
    [BsonElement("status")]
    public string Status { get; set; } = "processed";

    [BsonElement("processed_at")]
    public DateTime ProcessedAt { get; set; } = DateTime.UtcNow;
}
