@@ -2991,6 +2991,252 @@ paths:
29912991 ' 403 ' :
29922992 $ref : ' #/components/responses/Forbidden'
29932993
2994+ /api/settlements/{id} :
2995+ get :
2996+ summary : Get payments history (legacy — prefer /api/settlements)
2997+ description : Returns settlement records for the authenticated user's organization. Both `/api/payments` and `/api/settlements` resolve to the same router.
2998+ security :
2999+ - bearerAuth : []
3000+ parameters :
3001+ - in : query
3002+ name : status
3003+ schema :
3004+ type : string
3005+ enum : [Pending, Escrowed, Released, Failed, Disputed]
3006+ description : Filter payments by status.
3007+ - in : query
3008+ name : cursor
3009+ summary : Get settlement detail
3010+ description : Returns full settlement detail including escrowRelease subdocument.
3011+ security :
3012+ - bearerAuth : []
3013+ parameters :
3014+ - in : path
3015+ name : id
3016+ required : true
3017+ schema :
3018+ type : string
3019+ description : Settlement ObjectId.
3020+ responses :
3021+ ' 200 ' :
3022+ description : Settlement retrieved successfully
3023+ content :
3024+ application/json :
3025+ schema :
3026+ type : object
3027+ properties :
3028+ success :
3029+ type : boolean
3030+ message :
3031+ type : string
3032+ data :
3033+ type : array
3034+ items :
3035+ $ref : ' #/components/schemas/Settlement'
3036+ meta :
3037+ type : object
3038+ properties :
3039+ total :
3040+ type : integer
3041+ hasMore :
3042+ type : boolean
3043+ nextCursor :
3044+ type : string
3045+ nullable : true
3046+ $ref : ' #/components/schemas/Settlement'
3047+ ' 401 ' :
3048+ $ref : ' #/components/responses/Unauthorized'
3049+ ' 403 ' :
3050+ $ref : ' #/components/responses/Forbidden'
3051+ ' 404 ' :
3052+ description : Settlement not found
3053+ content :
3054+ application/json :
3055+ schema :
3056+ $ref : ' #/components/schemas/ErrorResponse'
3057+
3058+ /api/settlements/{id}/dispute :
3059+ post :
3060+ summary : Dispute a settlement
3061+ description : |
3062+ Transitions the settlement status to `Disputed` and records dispute metadata
3063+ (`disputedAt`, `disputeReason`, `additionalNotes`) in `escrowRelease`.
3064+ Restricted to ADMIN and MANAGER roles.
3065+ security :
3066+ - bearerAuth : []
3067+ parameters :
3068+ - in : path
3069+ name : id
3070+ required : true
3071+ schema :
3072+ type : string
3073+ description : Settlement ObjectId.
3074+ requestBody :
3075+ required : true
3076+ content :
3077+ application/json :
3078+ schema :
3079+ type : object
3080+ required :
3081+ - reason
3082+ properties :
3083+ reason :
3084+ type : string
3085+ minLength : 1
3086+ description : Reason for the dispute.
3087+ notes :
3088+ type : string
3089+ description : Optional additional context.
3090+ responses :
3091+ ' 200 ' :
3092+ description : Settlement disputed successfully
3093+ content :
3094+ application/json :
3095+ schema :
3096+ type : object
3097+ properties :
3098+ success :
3099+ type : boolean
3100+ message :
3101+ type : string
3102+ data :
3103+ $ref : ' #/components/schemas/Settlement'
3104+ ' 400 ' :
3105+ description : Validation error
3106+ content :
3107+ application/json :
3108+ schema :
3109+ $ref : ' #/components/schemas/ErrorResponse'
3110+ ' 401 ' :
3111+ $ref : ' #/components/responses/Unauthorized'
3112+ ' 403 ' :
3113+ description : Forbidden — VIEWER role cannot dispute
3114+ content :
3115+ application/json :
3116+ schema :
3117+ $ref : ' #/components/schemas/ErrorResponse'
3118+ ' 404 ' :
3119+ description : Settlement not found
3120+ content :
3121+ application/json :
3122+ schema :
3123+ $ref : ' #/components/schemas/ErrorResponse'
3124+
3125+ /api/settlements :
3126+ get :
3127+ summary : List settlements
3128+ description : Returns settlement records for the authenticated user's organization (cursor-paginated).
3129+ security :
3130+ - bearerAuth : []
3131+ parameters :
3132+ - in : query
3133+ name : status
3134+ schema :
3135+ type : string
3136+ enum : [Pending, Escrowed, Released, Failed, Disputed]
3137+ description : Filter by status.
3138+ - in : query
3139+ name : cursor
3140+ schema :
3141+ type : string
3142+ description : Cursor for next-page pagination.
3143+ - in : query
3144+ name : limit
3145+ schema :
3146+ type : integer
3147+ minimum : 1
3148+ maximum : 100
3149+ default : 20
3150+ responses :
3151+ ' 200 ' :
3152+ description : Settlements retrieved successfully
3153+ content :
3154+ application/json :
3155+ schema :
3156+ type : object
3157+ properties :
3158+ success :
3159+ type : boolean
3160+ message :
3161+ type : string
3162+ data :
3163+ type : array
3164+ items :
3165+ $ref : ' #/components/schemas/Settlement'
3166+ meta :
3167+ type : object
3168+ properties :
3169+ total :
3170+ type : integer
3171+ hasMore :
3172+ type : boolean
3173+ nextCursor :
3174+ type : string
3175+ nullable : true
3176+ ' 401 ' :
3177+ $ref : ' #/components/responses/Unauthorized'
3178+ ' 403 ' :
3179+ $ref : ' #/components/responses/Forbidden'
3180+
3181+ /api/settlements/summary :
3182+ get :
3183+ summary : Get settlement summary with sparkline
3184+ description : |
3185+ Returns aggregated settlement totals and a per-day sparkline array for the chosen period.
3186+ Results are cached in Redis for 5 minutes.
3187+ security :
3188+ - bearerAuth : []
3189+ parameters :
3190+ - in : query
3191+ name : period
3192+ schema :
3193+ type : string
3194+ enum : [week, month, quarter]
3195+ default : week
3196+ description : Aggregation window. `week`=7 days, `month`=30 days, `quarter`=90 days.
3197+ responses :
3198+ ' 200 ' :
3199+ description : Summary retrieved successfully
3200+ content :
3201+ application/json :
3202+ schema :
3203+ type : object
3204+ properties :
3205+ success :
3206+ type : boolean
3207+ message :
3208+ type : string
3209+ data :
3210+ type : object
3211+ properties :
3212+ totalReleased :
3213+ type : number
3214+ description : Sum of released settlement amounts in the period.
3215+ totalInEscrow :
3216+ type : number
3217+ description : Sum of escrowed settlement amounts in the period.
3218+ totalPending :
3219+ type : number
3220+ description : Sum of pending settlement amounts in the period.
3221+ sparkline :
3222+ type : array
3223+ items :
3224+ type : number
3225+ description : One entry per day in the period (released amounts per day).
3226+ period :
3227+ type : string
3228+ enum : [week, month, quarter]
3229+ ' 400 ' :
3230+ description : Invalid period value
3231+ content :
3232+ application/json :
3233+ schema :
3234+ $ref : ' #/components/schemas/ErrorResponse'
3235+ ' 401 ' :
3236+ $ref : ' #/components/responses/Unauthorized'
3237+ ' 403 ' :
3238+ $ref : ' #/components/responses/Forbidden'
3239+
29943240 /api/settlements/{id} :
29953241 get :
29963242 summary : Get settlement detail
0 commit comments