IA-965: feat: Trial period days, subscription status filter, and idempotent subscription upsert
MR Description
Summary
This MR introduces several improvements across the subscription and pricing plan modules.
Changes
1. Trial Period Support
- Added
trialPeriodDaysfield toPlanRequestDTOandPlanUpdateDTO - Added
getTrialPeriodDaysByGatewayPriceId()toPricingPlanServiceinterface andPricingPlanServiceImpl, resolving trial days from the linked plan - Exposed a new endpoint
GET /pricing-plans/{gatewayPriceId}/trial-daysinSubscriptionController
2. Subscription Status Filtering
- Added
getSubscriptionsByStatus()toSubscriptionServiceinterface andSubscriptionServiceImpl, mappingSubscriptionStatusTypeto the internalStatusType - Added
findByStatus()toSubscriptionRepository - Exposed a new endpoint
GET /subscriptions?status=inSubscriptionController
3. Idempotent Subscription Upsert
-
createSubscription(SubscriptionRequestDTO)now performs an upsert: if the subscription already exists bygatewaySubscriptionId, it updates the status and period dates instead of failing or duplicating — with special logic to preserveTRIALINGstatus against an incomingACTIVE -
updateSubscription(String, SubscriptionRequestDTO)now creates the subscription if it doesn't exist, making the update endpoint resilient to out-of-order webhook delivery - Added structured logging throughout both methods