@@ -16,6 +16,20 @@ import { Throttle, ThrottlerGuard } from '@nestjs/throttler';
1616import { ListSubscriptionsQueryDto } from './dto/list-subscriptions-query.dto' ;
1717import { ListCreatorSubscribersQueryDto } from './dto/list-creator-subscribers-query.dto' ;
1818import { SubscriptionStateQueryDto } from './dto/subscription-state-query.dto' ;
19+ import {
20+ CreateCheckoutDto ,
21+ CheckoutResponseDto ,
22+ ValidateBalanceDto ,
23+ ValidateBalanceResponseDto ,
24+ ConfirmSubscriptionDto ,
25+ ConfirmSubscriptionResponseDto ,
26+ FailCheckoutDto ,
27+ CancelSubscriptionDto ,
28+ PlanSummaryResponseDto ,
29+ PriceBreakdownResponseDto ,
30+ WalletStatusResponseDto ,
31+ TransactionPreviewResponseDto ,
32+ } from './dto/checkout.dto' ;
1933import { FanBearerGuard } from './guards/fan-bearer.guard' ;
2034import type { RequestWithFan } from './guards/fan-bearer.guard' ;
2135import { SubscriptionsService } from './subscriptions.service' ;
@@ -150,19 +164,13 @@ export class SubscriptionsController {
150164 @Throttle ( { short : { limit : 10 , ttl : 60000 } } )
151165 @UseGuards ( FeatureFlagGuard )
152166 @RequireFeatureFlag ( 'newSubscriptionFlow' )
153- @ApiOperation ( { summary : 'Create a subscription checkout session' } )
154- @ApiResponse ( { status : 429 , description : 'Too many requests' } )
155- @ApiResponse ( { status : 201 , description : 'Checkout session created' } )
167+ @ApiOperation ( { summary : 'Create a subscription checkout session' , description : 'Initiates a new checkout session for subscribing to a creator plan. The session expires after 15 minutes.' } )
168+ @ApiResponse ( { status : 201 , description : 'Checkout session created' , type : CheckoutResponseDto } )
156169 @ApiResponse ( { status : 403 , description : 'New subscription flow is disabled' } )
170+ @ApiResponse ( { status : 404 , description : 'Plan not found' } )
171+ @ApiResponse ( { status : 429 , description : 'Too many requests' } )
157172 createCheckout (
158- @Body ( )
159- body : {
160- fanAddress : string ;
161- creatorAddress : string ;
162- planId : number ;
163- assetCode ?: string ;
164- assetIssuer ?: string ;
165- } ,
173+ @Body ( ) body : CreateCheckoutDto ,
166174 @Headers ( 'x-network' ) requestNetwork ?: string ,
167175 ) {
168176 const checkout = this . subscriptionsService . createCheckout (
@@ -192,9 +200,10 @@ export class SubscriptionsController {
192200 }
193201
194202 @Get ( 'checkout/:id' )
195- @ApiOperation ( { summary : 'Get a checkout session by ID' } )
203+ @ApiOperation ( { summary : 'Get a checkout session by ID' , description : 'Returns full checkout details including transaction hash and error if present.' } )
196204 @ApiParam ( { name : 'id' , description : 'Checkout session ID' } )
197- @ApiResponse ( { status : 200 , description : 'Checkout session details' } )
205+ @ApiResponse ( { status : 200 , description : 'Checkout session details' , type : CheckoutResponseDto } )
206+ @ApiResponse ( { status : 400 , description : 'Checkout session has expired' } )
198207 @ApiResponse ( { status : 404 , description : 'Checkout not found' } )
199208 getCheckout ( @Param ( 'id' ) checkoutId : string ) {
200209 const checkout = this . subscriptionsService . getCheckout ( checkoutId ) ;
@@ -218,35 +227,39 @@ export class SubscriptionsController {
218227 }
219228
220229 @Get ( 'checkout/:id/plan' )
221- @ApiOperation ( { summary : 'Get plan summary for a checkout session' } )
230+ @ApiOperation ( { summary : 'Get plan summary for a checkout session' , description : 'Returns creator name, asset, amount, and billing interval for the plan attached to this checkout.' } )
222231 @ApiParam ( { name : 'id' , description : 'Checkout session ID' } )
223- @ApiResponse ( { status : 200 , description : 'Plan summary' } )
232+ @ApiResponse ( { status : 200 , description : 'Plan summary' , type : PlanSummaryResponseDto } )
233+ @ApiResponse ( { status : 404 , description : 'Checkout or plan not found' } )
224234 getPlanSummary ( @Param ( 'id' ) checkoutId : string ) {
225235 const checkout = this . subscriptionsService . getCheckout ( checkoutId ) ;
226236 return this . subscriptionsService . getPlanSummary ( checkout . planId ) ;
227237 }
228238
229239 @Get ( 'checkout/:id/price' )
230- @ApiOperation ( { summary : 'Get price breakdown for a checkout session' } )
240+ @ApiOperation ( { summary : 'Get price breakdown for a checkout session' , description : 'Returns subtotal, platform fee, network fee, and total for the checkout.' } )
231241 @ApiParam ( { name : 'id' , description : 'Checkout session ID' } )
232- @ApiResponse ( { status : 200 , description : 'Price breakdown' } )
242+ @ApiResponse ( { status : 200 , description : 'Price breakdown' , type : PriceBreakdownResponseDto } )
243+ @ApiResponse ( { status : 404 , description : 'Checkout not found' } )
233244 getPriceBreakdown ( @Param ( 'id' ) checkoutId : string ) {
234245 return this . subscriptionsService . getPriceBreakdown ( checkoutId ) ;
235246 }
236247
237248 @Get ( 'checkout/:id/wallet' )
238- @ApiOperation ( { summary : 'Get wallet status for a checkout session' } )
249+ @ApiOperation ( { summary : 'Get wallet status for a checkout session' , description : 'Returns the fan wallet balances and connection status for the checkout session.' } )
239250 @ApiParam ( { name : 'id' , description : 'Checkout session ID' } )
240- @ApiResponse ( { status : 200 , description : 'Wallet status' } )
251+ @ApiResponse ( { status : 200 , description : 'Wallet status' , type : WalletStatusResponseDto } )
252+ @ApiResponse ( { status : 404 , description : 'Checkout not found' } )
241253 getWalletStatus ( @Param ( 'id' ) checkoutId : string ) {
242254 const checkout = this . subscriptionsService . getCheckout ( checkoutId ) ;
243255 return this . subscriptionsService . getWalletStatus ( checkout . fanAddress ) ;
244256 }
245257
246258 @Get ( 'checkout/:id/preview' )
247- @ApiOperation ( { summary : 'Get transaction preview for a checkout session' } )
259+ @ApiOperation ( { summary : 'Get transaction preview for a checkout session' , description : 'Returns a preview of the Stellar transaction including from/to addresses, asset, amount, fee, and memo.' } )
248260 @ApiParam ( { name : 'id' , description : 'Checkout session ID' } )
249- @ApiResponse ( { status : 200 , description : 'Transaction preview' } )
261+ @ApiResponse ( { status : 200 , description : 'Transaction preview' , type : TransactionPreviewResponseDto } )
262+ @ApiResponse ( { status : 404 , description : 'Checkout not found' } )
250263 getTransactionPreview ( @Param ( 'id' ) checkoutId : string ) {
251264 return this . subscriptionsService . getTransactionPreview ( checkoutId ) ;
252265 }
@@ -256,10 +269,11 @@ export class SubscriptionsController {
256269 @ApiOperation ( { summary : 'Validate fan wallet balance for a checkout session' } )
257270 @ApiResponse ( { status : 429 , description : 'Too many requests' } )
258271 @ApiParam ( { name : 'id' , description : 'Checkout session ID' } )
259- @ApiResponse ( { status : 200 , description : 'Balance validation result' } )
272+ @ApiResponse ( { status : 200 , description : 'Balance validation result' , type : ValidateBalanceResponseDto } )
273+ @ApiResponse ( { status : 404 , description : 'Checkout not found' } )
260274 validateBalance (
261275 @Param ( 'id' ) checkoutId : string ,
262- @Body ( ) body : { assetCode : string ; amount : string } ,
276+ @Body ( ) body : ValidateBalanceDto ,
263277 ) {
264278 const checkout = this . subscriptionsService . getCheckout ( checkoutId ) ;
265279 return this . subscriptionsService . validateBalance (
@@ -274,10 +288,12 @@ export class SubscriptionsController {
274288 @ApiOperation ( { summary : 'Confirm a subscription checkout' } )
275289 @ApiResponse ( { status : 429 , description : 'Too many requests' } )
276290 @ApiParam ( { name : 'id' , description : 'Checkout session ID' } )
277- @ApiResponse ( { status : 200 , description : 'Subscription confirmed' } )
291+ @ApiResponse ( { status : 200 , description : 'Subscription confirmed' , type : ConfirmSubscriptionResponseDto } )
292+ @ApiResponse ( { status : 400 , description : 'Checkout expired' } )
293+ @ApiResponse ( { status : 404 , description : 'Checkout not found' } )
278294 confirmSubscription (
279295 @Param ( 'id' ) checkoutId : string ,
280- @Body ( ) body : { txHash ?: string } ,
296+ @Body ( ) body : ConfirmSubscriptionDto ,
281297 ) {
282298 return this . subscriptionsService . confirmSubscription ( checkoutId , body . txHash ) ;
283299 }
@@ -288,9 +304,10 @@ export class SubscriptionsController {
288304 @ApiResponse ( { status : 429 , description : 'Too many requests' } )
289305 @ApiParam ( { name : 'id' , description : 'Checkout session ID' } )
290306 @ApiResponse ( { status : 200 , description : 'Checkout marked as failed' } )
307+ @ApiResponse ( { status : 404 , description : 'Checkout not found' } )
291308 failCheckout (
292309 @Param ( 'id' ) checkoutId : string ,
293- @Body ( ) body : { error : string ; rejected ?: boolean } ,
310+ @Body ( ) body : FailCheckoutDto ,
294311 ) {
295312 return this . subscriptionsService . failCheckout (
296313 checkoutId ,
@@ -304,8 +321,9 @@ export class SubscriptionsController {
304321 @ApiOperation ( { summary : 'Cancel a subscription' } )
305322 @ApiResponse ( { status : 429 , description : 'Too many requests' } )
306323 @ApiResponse ( { status : 200 , description : 'Subscription cancelled' } )
324+ @ApiResponse ( { status : 404 , description : 'Subscription not found' } )
307325 cancelSubscription (
308- @Body ( ) body : { fanAddress : string ; creatorAddress : string } ,
326+ @Body ( ) body : CancelSubscriptionDto ,
309327 ) {
310328 return this . subscriptionsService . cancelSubscription (
311329 body . fanAddress ,
0 commit comments