mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-26 18:42:49 +00:00
54 lines
2.0 KiB
TypeScript
54 lines
2.0 KiB
TypeScript
import { Body, Controller, Get, Param, Post, UseGuards } from '@nestjs/common';
|
|
import { ApiTags, ApiOperation, ApiBearerAuth } from '@nestjs/swagger';
|
|
import { PaymentsService } from './payments.service';
|
|
import { InitiatePaymentDto, RefundDto, AddPaymentMethodDto } from './payments.dto';
|
|
import { JwtGuard } from '../../common/jwt.guard';
|
|
|
|
@ApiTags('Payment')
|
|
@Controller('payments')
|
|
@UseGuards(JwtGuard)
|
|
@ApiBearerAuth('JWT-auth')
|
|
export class PaymentsController {
|
|
constructor(private service: PaymentsService) {}
|
|
|
|
@Post('initiate')
|
|
@ApiOperation({
|
|
summary: 'Initiate payment with nationality-based payment methods',
|
|
description: `Initiates payment for a booking with support for multiple payment providers:
|
|
|
|
**Ethiopian Payment Methods:**
|
|
- TELEBIRR - Ethiopia's leading mobile money
|
|
- CBE_BIRR - Commercial Bank of Ethiopia
|
|
- EBIRR - Electronic payment gateway
|
|
|
|
**Djiboutian Payment Methods:**
|
|
- WAAFI - Djibouti's mobile money service
|
|
|
|
**International Payment Methods:**
|
|
- CARD - Visa, Mastercard
|
|
- WALLET - Internal wallet balance
|
|
|
|
**Multi-Currency:**
|
|
- All transactions processed in ETB
|
|
- Display amounts in ETB, DJF, or USD
|
|
- Real-time exchange rate conversion`
|
|
})
|
|
initiatePayment(@Body() dto: InitiatePaymentDto) { return this.service.initiatePayment(dto); }
|
|
|
|
@Get('intents/:bookingId')
|
|
@ApiOperation({ summary: 'Get payment intent status for a booking' })
|
|
getIntent(@Param('bookingId') bookingId: string) { return this.service.getIntentByBookingId(bookingId); }
|
|
|
|
@Post('refund')
|
|
@ApiOperation({ summary: 'Refund a confirmed booking' })
|
|
refund(@Body() dto: RefundDto) { return this.service.refund(dto); }
|
|
|
|
@Post('methods')
|
|
@ApiOperation({ summary: 'Add a payment method' })
|
|
addMethod(@Body() dto: AddPaymentMethodDto) { return this.service.addPaymentMethod(dto); }
|
|
|
|
@Get('methods/:userId')
|
|
@ApiOperation({ summary: 'Get payment methods for user' })
|
|
getMethods(@Param('userId') userId: string) { return this.service.getPaymentMethods(userId); }
|
|
}
|