prompt:
##TASK
Add subscription support to webhook event metadata and outgoing webhook content systems to enable proper subscription lifecycle event handling and webhook delivery for subscription-related operations.

chosen:
##OUTPUT
The webhook system requires subscription event support to handle subscription lifecycle events (creation, payment, cancellation) and deliver them to merchants via outgoing webhooks. This affects the event metadata enumeration and webhook content transformation layers. The complete flow is: subscription event occurs → EventMetadata::Subscription variant created with subscription_id, invoice_id, payment_id → stored in database → retrieved for webhook delivery → OutgoingWebhookEventContent::foreign_from converts EventMetadata to OutgoingWebhookEventContent::Subscription → StripeWebhookObject::From transforms to StripeWebhookObject::Subscriptions for Stripe compatibility. The OutgoingWebhookEventContent::foreign_from function (router/src/core/webhooks/outgoing_v2.rs::OutgoingWebhookEventContent::foreign_from) must add the Subscription variant match arm because it's the bridge from storage EventMetadata to webhook content representation—without this, subscription events cannot be converted to webhook content and would be silently dropped during webhook processing. The StripeWebhookObject::From implementation (router/src/compatibility/stripe/webhooks.rs::StripeWebhookObject::From) must handle OutgoingWebhookContent::SubscriptionDetails because it provides Stripe-compatible webhook formatting—without this, merchants using Stripe webhook endpoints would receive malformed or missing subscription events.

##SELECT
crates/router/src/core/webhooks/outgoing_v2.rs::OutgoingWebhookEventContent::foreign_from
crates/router/src/compatibility/stripe/webhooks.rs::StripeWebhookObject::From
<EOS>

rejected:
##OUTPUT
The webhook system needs to support subscriptions by adding new event types. The subscription events need to be handled in the webhook processing pipeline.

##SELECT
crates/router/src/core/webhooks/outgoing_v2.rs::OutgoingWebhookEventContent::foreign_from
crates/api_models/src/webhooks.rs::WebhookEvent
crates/router/src/handlers/webhooks.rs::handle_webhook
<EOS>


prompt:
##TASK
Update subscription response mapping to use common_enums::SubscriptionStatus instead of subscription_types::SubscriptionStatus for consistent enum usage across the codebase.

chosen:
##OUTPUT
The subscription system needs to standardize on a single SubscriptionStatus enum type to avoid type inconsistencies and import conflicts. The current flow is: subscription handler creates SubscriptionResponse → calls to_subscription_response method → converts string status to subscription_types::SubscriptionStatus → returns response. The to_subscription_response method (crates/subscriptions/src/core/subscription_handler.rs::SubscriptionWithHandler::to_subscription_response) must change because it's the conversion point where the status enum is instantiated. Using common_enums::SubscriptionStatus ensures consistency with other parts of the system that already use this common enum type. Without this change, the subscription module would maintain its own duplicate enum, creating potential mismatches and requiring conversions throughout the codebase when interacting with other modules that expect the common enum type.

##SELECT
crates/subscriptions/src/core/subscription_handler.rs::SubscriptionWithHandler::to_subscription_response
<EOS>

rejected:
##OUTPUT
The subscription response should use the common enum type for consistency. Need to update the import statements and change the enum usage.

##SELECT
crates/subscriptions/src/core/subscription_handler.rs::SubscriptionWithHandler::to_subscription_response
crates/subscriptions/src/types.rs::SubscriptionStatus
<EOS>


prompt:
##TASK
Add subscription support to webhook event system by including Subscriptions in EventClass enum and implementing SubscriptionStatus to EventType mapping for proper webhook routing.

chosen:
##OUTPUT
The webhook system needs to handle subscription-related events for proper event classification and routing. The current flow is: webhook event received → EventClass determines routing category → EventType specifies the exact event type → handlers process based on event type. The EventClass enum (crates/common_enums/src/enums.rs::EventClass) must include Subscriptions because it's the primary classification that determines which subsystem handles the event. The SubscriptionStatus transformer (crates/common_enums/src/transformers.rs::impl::Option<EventType>) must map subscription status changes to appropriate EventType values because it converts domain state changes into webhook events. Without EventClass::Subscriptions, subscription events would be misclassified or unhandled. Without the SubscriptionStatus mapping, subscription status changes wouldn't trigger appropriate webhook notifications, breaking integration with external systems that depend on subscription lifecycle events.

##SELECT
crates/common_enums/src/enums.rs::EventClass
crates/common_enums/src/transformers.rs::impl::Option<EventType>
<EOS>

rejected:
##OUTPUT
Subscription support requires adding the Subscriptions variant to EventClass and mapping status changes to events.

##SELECT
crates/common_enums/src/enums.rs::EventClass
crates/common_enums/src/enums.rs::EventType
crates/common_enums/src/transformers.rs::impl::Option<EventType>
<EOS>