11import {
22 Body ,
33 Controller ,
4+ Get ,
45 Param ,
56 ParseUUIDPipe ,
67 Post ,
@@ -10,6 +11,7 @@ import {
1011 ApiBearerAuth ,
1112 ApiConflictResponse ,
1213 ApiForbiddenResponse ,
14+ ApiOkResponse ,
1315 ApiOperation ,
1416 ApiTags ,
1517 ApiUnprocessableEntityResponse ,
@@ -20,18 +22,36 @@ import { RolesGuard } from '../auth/guards/roles.guard';
2022import { UserRole } from '../common/enums/role.enum' ;
2123import { User } from '../users/entities/user.entity' ;
2224import { PaymentsService } from './payments.service' ;
25+ import { Payment } from './entities/payment.entity' ;
2326import { SubmitPaymentDto } from './dto/submit-payment.dto' ;
2427import { TestSignAndSubmitPaymentDto } from './dto/test-sign-and-submit-payment.dto' ;
2528
2629@ApiTags ( 'payments' )
2730@ApiBearerAuth ( )
2831@Controller ( 'shipments/:shipmentId/payment' )
29- @UseGuards ( RolesGuard )
30- @Roles ( UserRole . SHIPPER , UserRole . ADMIN )
3132export class PaymentsController {
3233 constructor ( private readonly paymentsService : PaymentsService ) { }
3334
35+ @Get ( )
36+ @ApiOperation ( {
37+ summary : 'Get payment/escrow status for a shipment' ,
38+ description :
39+ 'Returns the escrow payment record if one exists for this shipment. Accessible to the shipper, carrier, and admin.' ,
40+ } )
41+ @ApiOkResponse ( { description : 'Payment record found' , type : Payment } )
42+ @ApiOperation ( { summary : 'Get escrow status for a shipment' } )
43+ @UseGuards ( RolesGuard )
44+ @Roles ( UserRole . SHIPPER , UserRole . CARRIER , UserRole . ADMIN )
45+ getStatus (
46+ @Param ( 'shipmentId' , ParseUUIDPipe ) shipmentId : string ,
47+ @CurrentUser ( ) user : User ,
48+ ) {
49+ return this . paymentsService . findByShipmentIdForUser ( shipmentId , user ) ;
50+ }
51+
3452 @Post ( )
53+ @UseGuards ( RolesGuard )
54+ @Roles ( UserRole . SHIPPER , UserRole . ADMIN )
3555 @ApiOperation ( {
3656 summary :
3757 'Build an unsigned funding transaction for an accepted shipment (shipper only)' ,
0 commit comments