|  |  |  | @ -7,6 +7,7 @@ import { InjectModel } from "@nestjs/sequelize"; | 
			
		
	
		
			
				
					|  |  |  |  | import { Payment } from "./entities/payment.entity"; | 
			
		
	
		
			
				
					|  |  |  |  | import { JwtAuthGuard } from "src/guard/auth.guard"; | 
			
		
	
		
			
				
					|  |  |  |  | import { Transaction } from "src/wallet/entities/transaction.entity"; | 
			
		
	
		
			
				
					|  |  |  |  | import { RoleGuard } from "src/guard/role.guard"; | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | @Controller("payment") | 
			
		
	
		
			
				
					|  |  |  |  | export class PaymentController { | 
			
		
	
	
		
			
				
					|  |  |  | @ -20,11 +21,14 @@ export class PaymentController { | 
			
		
	
		
			
				
					|  |  |  |  |   ) {} | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |   @UseGuards(JwtAuthGuard) | 
			
		
	
		
			
				
					|  |  |  |  |   @Post("request/:userId") | 
			
		
	
		
			
				
					|  |  |  |  |   async requestPayment(@Request() req): Promise<{ url: string }> { | 
			
		
	
		
			
				
					|  |  |  |  |   @Post("request") | 
			
		
	
		
			
				
					|  |  |  |  |   async requestPayment(@Request() req) { | 
			
		
	
		
			
				
					|  |  |  |  |     const userId = req.user.id; | 
			
		
	
		
			
				
					|  |  |  |  |     const invoice = await this.invoiceService.getInvoicePendingByUser(userId); | 
			
		
	
		
			
				
					|  |  |  |  |     const totalAmount = invoice.totalPaymentAmount; | 
			
		
	
		
			
				
					|  |  |  |  |     if(totalAmount<1000){ | 
			
		
	
		
			
				
					|  |  |  |  |       return{message:'please enter amount above 1000'} | 
			
		
	
		
			
				
					|  |  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  |  |     const callbackUrl = `http://localhost:3000/payment/verify?userId=${userId}&amount=${totalAmount}`; | 
			
		
	
		
			
				
					|  |  |  |  |     const paymentUrl = await this.paymentService.requestPayment(totalAmount, "Purchase products", callbackUrl); | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
	
		
			
				
					|  |  |  | @ -69,4 +73,5 @@ export class PaymentController { | 
			
		
	
		
			
				
					|  |  |  |  |       throw new Error(`Error during payment verification: ${error.message}`); | 
			
		
	
		
			
				
					|  |  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  |  |   } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | } | 
			
		
	
	
		
			
				
					|  |  |  | 
 |