added basic strcture for the callbackapi

This commit is contained in:
Lincpay Tech
2025-11-24 13:07:26 +05:30
parent d838f4c5cf
commit 08d5509c1a
5 changed files with 93 additions and 6 deletions
@@ -9,12 +9,15 @@ 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.GeneralResp;
import com.billpaymentservice.bbps.dto.ResponseModel;
import com.billpaymentservice.bbps.dto.request.BillFetchByBillIdRequest;
import com.billpaymentservice.bbps.dto.request.BillFetchByClientIdRequest;
import com.billpaymentservice.bbps.dto.request.BillValidateByClientIdRequest;
import com.billpaymentservice.bbps.dto.request.FetchBillRequest;
import com.billpaymentservice.bbps.dto.request.FetchBillValidatestRequest;
import com.billpaymentservice.bbps.dto.response.BillDataResponse;
import com.billpaymentservice.bbps.dto.response.FetchBillValidateResponse;
import com.billpaymentservice.bbps.service.AgentService;
@RestController
@@ -86,5 +89,18 @@ public class AgentController {
ResponseModel response = agentService.fetchBillValidateByClientReqId(billValidateByClientIdRequest);
return ResponseEntity.ok(response);
}
@PostMapping(value="/callback/billFetch", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<ResponseModel> handleBillFetchCallback(@RequestBody BillDataResponse billDataResponse) {
ResponseModel genralResp=agentService.processBillFetchCallback(billDataResponse);
// Return a response indicating successful receipt
return ResponseEntity.ok(genralResp);
}
@PostMapping(value="/callback/billValidate", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<ResponseModel> handleBillValidateCallback(@RequestBody FetchBillValidateResponse fetchBillValidateResponse) {
ResponseModel genralResp=agentService.processBillValidateCallback(fetchBillValidateResponse);
// Return a response indicating successful receipt
return ResponseEntity.ok(genralResp);
}
}
@@ -6,6 +6,8 @@ import com.billpaymentservice.bbps.dto.request.BillFetchByClientIdRequest;
import com.billpaymentservice.bbps.dto.request.BillValidateByClientIdRequest;
import com.billpaymentservice.bbps.dto.request.FetchBillRequest;
import com.billpaymentservice.bbps.dto.request.FetchBillValidatestRequest;
import com.billpaymentservice.bbps.dto.response.BillDataResponse;
import com.billpaymentservice.bbps.dto.response.FetchBillValidateResponse;
public interface AgentService {
@@ -21,4 +23,8 @@ public interface AgentService {
ResponseModel fetchBillValidateByClientReqId( BillValidateByClientIdRequest billValidateByClientIdRequest);
ResponseModel processBillFetchCallback(BillDataResponse billDataResponse);
ResponseModel processBillValidateCallback(FetchBillValidateResponse billDataResponse);
}
@@ -4,13 +4,17 @@ 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.dto.response.TransactionStatusResponse;
public interface PaymentService {
public ResponseModel initiatePayment(BillPaymentRequest billPaymentRequest);
ResponseModel initiatePayment(BillPaymentRequest billPaymentRequest);
public ResponseModel checkTrasactionStatus(TransactionStatusRequest transactionStatusRequest);
ResponseModel checkTrasactionStatus(TransactionStatusRequest transactionStatusRequest);
ResponseModel checkTrasactionStatusByClientReqId(TrasactionStatusByClientReqIdRequest transactionStatusRequest);
ResponseModel checkTrasactionStatusByClientReqId(TrasactionStatusByClientReqIdRequest transactionStatusRequest);
ResponseModel handlePaymentIntiateCallback(TransactionStatusResponse transactionStatusResponse);
}
@@ -368,7 +368,6 @@ public class AgentServiceImpl implements AgentService {
billFetchByBillIdRequest.setReqId(reqId);
LOGGER.info("Waiting for 2 seconds before fetching bill by ID...");
try {
Thread.sleep(12000);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
@@ -648,9 +647,53 @@ public class AgentServiceImpl implements AgentService {
throw new CustomException("Invalid JSON received from API");
}
}
//================================== End Bill fetch and Bill Validate by Client Req Id==================================//
//===================================Callback Methods BillFetch and BillValidate ==================================//
@Override
public ResponseModel processBillFetchCallback(BillDataResponse billDataResponse) {
LOGGER.info("Recived Call Back from billDataResponse: {}", billDataResponse);
if(billDataResponse.getGenericResponse().getStatusCode().equals("200")) {
}
else {
LOGGER.info("Bill Fetch Callback Failed with Status: {}", billDataResponse.getGenericResponse().getStatus());
}
return new ResponseModel("CallBack Recieved Successfully",
"200",
200,
"");
}
@Override
public ResponseModel processBillValidateCallback(FetchBillValidateResponse billValidateResponse) {
LOGGER.info("Recived Call Back from FetchBillValidateResponse: {}", billValidateResponse);
if(billValidateResponse.getGenericResponse().getStatusCode().equals("200")) {
}
else {
LOGGER.info("Bill Fetch Callback Failed with Status: {}", billValidateResponse.getGenericResponse().getStatus());
}
return new ResponseModel("CallBack Recieved Successfully",
"200",
200,
"");
}}
/*
* @Override public ResponseModel
* initiateBillValidate(FetchBillValidatestRequest fetchBillValidateRequest) {
*
@@ -838,4 +881,4 @@ public class AgentServiceImpl implements AgentService {
*/
}
@@ -398,6 +398,24 @@ public class PaymentServiceImpl implements PaymentService {
throw new CustomException("Invalid JSON received from API");
}
}
@Override
public ResponseModel handlePaymentIntiateCallback(TransactionStatusResponse transactionStatusResponse) {
LOGGER.info("Recived Call Back from FetchBillValidateResponse: {}", transactionStatusResponse);
if(transactionStatusResponse.getGeneralResp().getStatusCode().equals("200")) {
}
else {
LOGGER.info("Bill Fetch Callback Failed with Status: {}", transactionStatusResponse.getGeneralResp().getStatus());
}
return new ResponseModel("CallBack Recieved Successfully",
"200",
200,
"");
}
}
/* PollBack logic for the fetchTxnByTxnId API
* @Override public ResponseModel fetchTxnByTxnId(BillFetchByBillIdRequest