package com.billpaymentservice.bbps.controller; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import com.billpaymentservice.bbps.dto.ResponseModel; import com.billpaymentservice.bbps.dto.request.BillPaymentRequest; import com.billpaymentservice.bbps.dto.request.TransactionStatusRequest; import com.billpaymentservice.bbps.dto.request.TrasactionStatusByClientReqIdRequest; import com.billpaymentservice.bbps.service.PaymentService; @RestController @RequestMapping("/agent/payment") public class PaymentController { /** * Fetches bill details from external BBPS service */ private final PaymentService paymentService; public PaymentController(PaymentService paymentService) { this.paymentService=paymentService; } @PostMapping( value = "/intiatePayment", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE ) public ResponseEntity requestBillFetch( @Validated @RequestBody BillPaymentRequest billPaymentRequest) { ResponseModel response = paymentService.initiatePayment(billPaymentRequest); return ResponseEntity.ok(response); } @PostMapping( value = "/checkTransactionStatus", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE ) public ResponseEntity checkTransactionStatus( @Validated @RequestBody TransactionStatusRequest transactionStatusRequest) { ResponseModel response = paymentService.checkTrasactionStatus(transactionStatusRequest); return ResponseEntity.ok(response); } @PostMapping( value = "/checkTransactionStatusByClientReqId", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE ) public ResponseEntity checkTransactionStatusByClientReqId( @Validated @RequestBody TrasactionStatusByClientReqIdRequest transactionStatusRequest) { ResponseModel response = paymentService.checkTrasactionStatusByClientReqId(transactionStatusRequest); return ResponseEntity.ok(response); } }