update code

This commit is contained in:
Mohd-Arham
2025-11-25 17:53:35 +05:30
4 changed files with 48 additions and 39 deletions
@@ -81,7 +81,6 @@ public class AgentServiceImpl implements AgentService {
String mid = fetchBillRequest.getMid();
LOGGER.info("[{}] START | reqId={} | mid={} | billerId={}", apiName, requestId, mid,
fetchBillRequest.getBillerId());
helper.validateMerchant(mid);
String txnId = helper.generateTxnId(15);
String fullUrl = agentDtaUrl + BBPSConstant.BILL_FETCH_INTI;
fetchBillRequest.setClientReqId(txnId);
@@ -92,12 +91,12 @@ public class AgentServiceImpl implements AgentService {
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnId, apiName, fetchBillRequest.getMid(),
BBPSConstant.HTTP_POST, requestJson);
helper.validateMerchant(mid);
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, requestId, apiName, fullUrl,
BBPSConstant.HTTP_POST, forwardJson);
LOGGER.debug("Outbound log created successfully for txnId: {} and reqId: {}", txnId, requestId);
try {
LOGGER.info("[{}] Calling external API | URL={}", apiName, fullUrl);
Map<String, String> responseMap = httpService.postRequest(fullUrl, forwardJson,
helper.buildHeaders(beneficiaryDetailsRepository.findByOrgId(BBPSConstant.ORG_ID)));
@@ -164,8 +163,6 @@ public class AgentServiceImpl implements AgentService {
String reqId = billFetchByBillIdRequest.getReqId();
String billId = billFetchByBillIdRequest.getBillId();
String fullUrl = agentDtaUrl + BBPSConstant.BILL_FETCH_BY_ID + billFetchByBillIdRequest.getBillId();
helper.validateMerchant(billFetchByBillIdRequest.getMid());
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, reqId, apiName, fullUrl, BBPSConstant.HTTP_GET,
null);
LOGGER.debug("Outbound log created successfully for FetchBillById: {}", fullUrl);
@@ -217,13 +214,12 @@ public class AgentServiceImpl implements AgentService {
String reqId = billFetchByBillIdRequest.getReqId();
String billId = billFetchByBillIdRequest.getBillId();
String mid = billFetchByBillIdRequest.getMid();
String requestJson = helper.convertObjectToJson(billFetchByBillIdRequest);
LOGGER.info("[{}] START | reqId={} | mid={} | billId={}", apiName, reqId, mid, billId);
String fullUrl = agentDtaUrl + BBPSConstant.BILL_FETCH_BY_ID + billFetchByBillIdRequest.getBillId();
helper.validateMerchant(mid);
String txnId = helper.generateTxnId(15);
InboundTraceLog inboundLog = helper.createInboundLog(reqId, txnId, apiName, billFetchByBillIdRequest.getMid(),
BBPSConstant.HTTP_GET, null);
BBPSConstant.HTTP_GET, requestJson);
LOGGER.info("Initiating {} API for billId={} and reqId={}", apiName, billId, reqId);
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, reqId, apiName, fullUrl, BBPSConstant.HTTP_GET,
null);
@@ -274,10 +270,8 @@ public class AgentServiceImpl implements AgentService {
String apiName = BBPSConstant.API_INITIATE_BILL_VALIDATE;
String reqId = fetchBillValidateRequest.getReqId();
String mid = fetchBillValidateRequest.getMid();
LOGGER.info("[{}] START | reqId={} | mid={} | billerId={}", apiName, fetchBillValidateRequest, mid,
fetchBillValidateRequest.getBillerId());
helper.validateMerchant(fetchBillValidateRequest.getMid());
String txnId = helper.generateTxnId(15);
String fullUrl = agentDtaUrl + BBPSConstant.BILLER_VALIDATE_URL;
fetchBillValidateRequest.setClientReqId(txnId);
@@ -291,6 +285,7 @@ public class AgentServiceImpl implements AgentService {
InboundTraceLog inboundLog = helper.createInboundLog(reqId, txnId, apiName, fetchBillValidateRequest.getMid(),
BBPSConstant.HTTP_POST, requestJson);
helper.validateMerchant(fetchBillValidateRequest.getMid());
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, reqId, apiName, fullUrl, BBPSConstant.HTTP_POST,
forwardJson);
LOGGER.debug("Outbound log created successfully for txnId: {} and reqId: {}", txnId, reqId);
@@ -364,8 +359,6 @@ public class AgentServiceImpl implements AgentService {
String billId = billRequest.getBillId();
String fullUrl = agentDtaUrl + BBPSConstant.BILL_VALIDATE_ID_URL + billRequest.getBillId();
helper.validateMerchant(billRequest.getMid());
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, reqId, apiName, fullUrl,
BBPSConstant.HTTP_GET, null);
LOGGER.debug("Outbound log created successfully for FetchBillById: {}", fullUrl);
@@ -417,23 +410,20 @@ public class AgentServiceImpl implements AgentService {
@Override
public ResponseModel initiateBillValidateByBillId(BillFetchByBillIdRequest billRequest) {
String apiName = BBPSConstant.API_FETCH_BILL_BY_ID;
String reqId = billRequest.getReqId();
String billId = billRequest.getBillId();
String mid = billRequest.getMid();
String requestJson = helper.convertObjectToJson(billRequest);
LOGGER.info("[{}] START | reqId={} | mid={} | billId={}", apiName, billRequest, mid, billId);
helper.validateMerchant(billRequest.getMid());
String txnId = helper.generateTxnId(15);
String fullUrl = agentDtaUrl + BBPSConstant.BILL_VALIDATE_ID_URL + billRequest.getBillId();
LOGGER.info("Initiating {} API for billId={} and reqId={}", apiName, billId, reqId);
InboundTraceLog inboundLog = helper.createInboundLog(reqId, txnId, apiName, billRequest.getMid(),
BBPSConstant.HTTP_GET, null);
BBPSConstant.HTTP_GET, requestJson);
helper.validateMerchant(billRequest.getMid());
try {
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, reqId, apiName, fullUrl,
@@ -492,12 +482,14 @@ public class AgentServiceImpl implements AgentService {
String reqId = billValidateByClientIdRequest.getReqId();
String clientReqId = billValidateByClientIdRequest.getClientReqId();
String mid = billValidateByClientIdRequest.getMid();
String txnId = helper.generateTxnId(15);
String requestJson = helper.convertObjectToJson(billValidateByClientIdRequest);
LOGGER.info("[{}] START | reqId={} | mid={} | clientReqId={}", apiName, reqId, mid,
billValidateByClientIdRequest.getClientReqId());
InboundTraceLog inboundLog = helper.createInboundLog(reqId, txnId, apiName,
billValidateByClientIdRequest.getMid(), BBPSConstant.HTTP_GET,requestJson);
helper.validateMerchant(billValidateByClientIdRequest.getMid());
String txnId = helper.generateTxnId(15);
Optional<BillInitiate> billInitiate = billIntiateRepository.findByReqId(clientReqId);
if (billInitiate.isEmpty()) {
throw new CustomException(BBPSConstant.NO_BILL_FOUND);
@@ -505,9 +497,6 @@ public class AgentServiceImpl implements AgentService {
String fullUrl = agentDtaUrl + BBPSConstant.BILL_VALIDATE_BY_CLIENT_REQ_ID + billInitiate.get().getTxnId();
helper.validateMerchant(billValidateByClientIdRequest.getMid());
InboundTraceLog inboundLog = helper.createInboundLog(reqId, txnId, apiName,
billValidateByClientIdRequest.getMid(), BBPSConstant.HTTP_GET, null);
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, reqId, apiName, fullUrl, BBPSConstant.HTTP_GET,
null);
@@ -552,21 +541,21 @@ public class AgentServiceImpl implements AgentService {
String reqId = billFetchByClientIdRequest.getReqId();
String clientReqId = billFetchByClientIdRequest.getClientReqId();
String mid = billFetchByClientIdRequest.getMid();
String requestJson = helper.convertObjectToJson(billFetchByClientIdRequest);
LOGGER.info("[{}] START | reqId={} | mid={} | clientReqId={}", apiName, reqId, mid,
billFetchByClientIdRequest.getClientReqId());
helper.validateMerchant(billFetchByClientIdRequest.getMid());
String txnId = helper.generateTxnId(15);
helper.validateMerchant(billFetchByClientIdRequest.getMid());
InboundTraceLog inboundLog = helper.createInboundLog(reqId, txnId, apiName, billFetchByClientIdRequest.getMid(),
BBPSConstant.HTTP_GET, requestJson);
helper.validateMerchant(billFetchByClientIdRequest.getMid());
Optional<BillInitiate> billInitiate = billIntiateRepository.findByReqId(clientReqId);
if (billInitiate.isEmpty()) {
throw new CustomException(BBPSConstant.NO_BILL_FOUND);
}
String fullUrl = agentDtaUrl + BBPSConstant.BILL_VALIDATE_BY_CLIENT_REQ_ID + billInitiate.get().getTxnId();
helper.validateMerchant(billFetchByClientIdRequest.getMid());
InboundTraceLog inboundLog = helper.createInboundLog(reqId, txnId, apiName, billFetchByClientIdRequest.getMid(),
BBPSConstant.HTTP_GET, null);
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, reqId, apiName, fullUrl, BBPSConstant.HTTP_GET,
null);
@@ -109,7 +109,6 @@ public class MasterDataServiceImpl implements MasterDataService {
String requestId = masterRequest.getReqId();
String mid = masterRequest.getMid();
LOGGER.info("[{}] START | reqId={} | mid={}", apiName, requestId, mid);
// Merchant Validation
helper.validateMerchant(mid);
String txnID = helper.generateTxnId(15);
@@ -228,7 +227,7 @@ public class MasterDataServiceImpl implements MasterDataService {
throw new CustomException("Invalid JSON received from API");
}
}
@Override
public ResponseModel getCustomerParamByBillerId(CustomParamRequest customerParamRequest) {
String apiName = BBPSConstant.API_GET_CUSTOMER_PARAM_BY_BILLER_ID;
@@ -478,6 +477,7 @@ public class MasterDataServiceImpl implements MasterDataService {
if (entities != null) {
dispositionRepository.saveAll(entities);
} else {
LOGGER.warn("No disposition found in response to save.");
}
@@ -105,7 +105,9 @@ public class PaymentServiceImpl implements PaymentService {
String requestJson = helper.convertObjectToJson(billPaymentRequest);
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnId, apiName, billPaymentRequest.getMid(), BBPSConstant.HTTP_POST, requestJson);
LOGGER.debug("Inbound log created for api={} | reqId={} | txnId={}", apiName, requestId, txnId);
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, requestId, apiName, url, BBPSConstant.HTTP_POST, forwardjson);
LOGGER.debug("Outbound log created for api={} | reqId={} | txnId={}", apiName, requestId, txnId);
try {
LOGGER.info("Calling BBPS payment URL: {}", url);
@@ -114,6 +116,7 @@ public class PaymentServiceImpl implements PaymentService {
LOGGER.info("Payment API Response: {}", responseData);
helper.updateOutboundLogResponse(outboundLog, responseData);
LOGGER.debug("Outbound log response updated for txnId={}", txnId);
if (responseData == null || responseData.isEmpty()) {
helper.updateInboundLogFailure(inboundLog, BBPSConstant.EMPTY_RESPONSE_FROM_BBPS, BBPSConstant.FAILED_STR);
@@ -155,6 +158,7 @@ public class PaymentServiceImpl implements PaymentService {
LOGGER.warn("Thread interrupted during payment delay: {}", e.getMessage());
}
LOGGER.info("Checking transaction status for txnId={}", billPaymentResponse.getTxnId());
LOGGER.info("[{}] END | reqId={} | txnId={}", apiName, requestId, txnId);
return checkTrasactionStatus(transactionStatusRequest, inboundLog);
} catch (JsonProcessingException e) {
@@ -169,6 +173,9 @@ public class PaymentServiceImpl implements PaymentService {
String txnId = helper.generateTxnId(15);
String requestId = transactionStatusRequest.getReqId();
// START log for internal transaction status check
LOGGER.info("[{}] START (internal) | checkTxnId={} | reqId={} | bankTxnId={}", apiName, txnId, requestId, transactionStatusRequest.getTxnId());
String url = paymentUrl + BBPSConstant.CHECK_TRANSACTION_URL + transactionStatusRequest.getTxnId();
LOGGER.info("Checking transaction status (internal) for txnId={} and reqId={}", transactionStatusRequest.getTxnId(), requestId);
@@ -177,12 +184,14 @@ public class PaymentServiceImpl implements PaymentService {
HttpHeaders headers = helper.buildHeaders(headersData);
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, requestId, apiName, url, BBPSConstant.HTTP_GET, null);
LOGGER.debug("Outbound log created for internal status check | txnId={} | reqId={}", txnId, requestId);
Map<String, String> responseMap = httpService.getRequest(url, headers);
String responseData = responseMap.get(BBPSConstant.RESPONSE_DATA_KEY);
LOGGER.info("Transaction status response: {}", responseData);
helper.updateOutboundLogResponse(outboundLog, responseData);
LOGGER.debug("Outbound log response updated for internal status check | txnId={}", txnId);
try {
Map<String, Object> dataMap = objectMapper.readValue(responseData, new TypeReference<Map<String, Object>>() {});
@@ -223,6 +232,7 @@ public class PaymentServiceImpl implements PaymentService {
);
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
LOGGER.info("[{}] END (internal) | checkTxnId={} | reqId={} | status={}", apiName, txnId, requestId, generalResp.getStatus());
return responseModel;
} catch (JsonProcessingException e) {
@@ -238,6 +248,7 @@ public class PaymentServiceImpl implements PaymentService {
String txnID = helper.generateTxnId(15);
String apiName = BBPSConstant.API_CHECK_TRANSACTION_PUBLIC;
String requestId = transactionStatusRequest.getReqId();
LOGGER.info("[{}] START (public) | reqId={} | mid={} | checkBankTxnId={}", apiName, requestId, transactionStatusRequest.getMid(), transactionStatusRequest.getTxnId());
String requestJson = helper.convertObjectToJson(transactionStatusRequest);
String url = paymentUrl + BBPSConstant.CHECK_TRANSACTION_URL + transactionStatusRequest.getTxnId();
@@ -247,12 +258,15 @@ public class PaymentServiceImpl implements PaymentService {
HttpHeaders headers = helper.buildHeaders(headersData);
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnID, apiName, transactionStatusRequest.getMid(), BBPSConstant.HTTP_POST, requestJson);
LOGGER.debug("Inbound log created for public status check | reqId={} | txnId={}", requestId, txnID);
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, url, BBPSConstant.HTTP_GET, null);
LOGGER.debug("Outbound log created for public status check | reqId={} | txnId={}", requestId, txnID);
Map<String, String> responseMap = httpService.getRequest(url, headers);
String responseData = responseMap.get(BBPSConstant.RESPONSE_DATA_KEY);
LOGGER.info("Transaction status response data: {}", responseData);
helper.updateOutboundLogResponse(outboundLog, responseData);
LOGGER.debug("Outbound log response updated for public status check | reqId={} | txnId={}", requestId, txnID);
try {
Map<String, Object> dataMap = objectMapper.readValue(responseData, new TypeReference<Map<String, Object>>() {});
@@ -281,6 +295,7 @@ public class PaymentServiceImpl implements PaymentService {
);
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
LOGGER.info("[{}] END (public) | reqId={} | txnId={} | status={}", apiName, requestId, txnID, generalResp.getStatus());
return responseModel;
} catch (JsonProcessingException e) {
@@ -292,7 +307,6 @@ public class PaymentServiceImpl implements PaymentService {
@Override
public ResponseModel checkTrasactionStatusByClientReqId(TrasactionStatusByClientReqIdRequest transactionStatusRequest) {
helper.validateMerchant(transactionStatusRequest.getMid());
String txnID = helper.generateTxnId(15);
@@ -301,7 +315,7 @@ public class PaymentServiceImpl implements PaymentService {
String clientReqId = transactionStatusRequest.getClientReqId();
String requestJson = helper.convertObjectToJson(transactionStatusRequest);
LOGGER.info("Checking transaction status for clientReqId={} and reqId={}", clientReqId, requestId);
LOGGER.info("[{}] START | reqId={} | mid={} | clientReqId={}", apiName, requestId, transactionStatusRequest.getMid(), clientReqId);
Optional<PaymentInitiate> paymentInitiate = paymentIntiateRepository.findByReqId(clientReqId);
if (paymentInitiate.isEmpty()) {
@@ -315,9 +329,11 @@ public class PaymentServiceImpl implements PaymentService {
InboundTraceLog inboundLog = helper.createInboundLog(
requestId, txnID, apiName, transactionStatusRequest.getMid(), BBPSConstant.HTTP_POST, requestJson);
LOGGER.debug("Inbound log created for clientReqId check | reqId={} | txnId={}", requestId, txnID);
OutboundTraceLog outboundLog = helper.createOutboundLog(
txnID, requestId, apiName, url, BBPSConstant.HTTP_GET, null);
LOGGER.debug("Outbound log created for clientReqId check | reqId={} | txnId={}", requestId, txnID);
try {
LOGGER.info("Calling BBPS Transaction Status API URL={}", url);
@@ -327,6 +343,7 @@ public class PaymentServiceImpl implements PaymentService {
LOGGER.info("Transaction Status Response: {}", responseData);
helper.updateOutboundLogResponse(outboundLog, responseData);
LOGGER.debug("Outbound log response updated for clientReqId check | reqId={} | txnId={}", requestId, txnID);
Map<String, Object> dataMap = objectMapper.readValue(
responseData, new TypeReference<Map<String, Object>>() {});
@@ -353,6 +370,7 @@ public class PaymentServiceImpl implements PaymentService {
LOGGER.info("Transaction Status for clientReqId={} => {}", clientReqId, generalResp.getStatus());
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
LOGGER.info("[{}] END | reqId={} | clientReqId={} | status={}", apiName, requestId, clientReqId, generalResp.getStatus());
return new ResponseModel(
generalResp.getMessage(),
generalResp.getStatus(),
@@ -370,18 +388,20 @@ public class PaymentServiceImpl implements PaymentService {
@Override
public ResponseModel handlePaymentIntiateCallback(TransactionStatusResponse transactionStatusResponse) {
LOGGER.info("Recived Call Back from FetchBillValidateResponse: {}", transactionStatusResponse);
String apiName = "HANDLE_PAYMENT_INITIATE_CALLBACK";
LOGGER.info("[{}] START | payload={} ", apiName, transactionStatusResponse);
LOGGER.info("Received Call Back: {}", transactionStatusResponse);
if (transactionStatusResponse.getGeneralResp().getStatusCode().equals(BBPSConstant.SUCCESS_CODE_STR)) {
LOGGER.info("Callback indicates SUCCESS with status={}", transactionStatusResponse.getGeneralResp().getStatus());
} else {
LOGGER.info("Bill Fetch Callback Failed with Status: {}", transactionStatusResponse.getGeneralResp().getStatus());
LOGGER.info("Callback indicates FAILURE with status={}", transactionStatusResponse.getGeneralResp().getStatus());
}
LOGGER.info("[{}] END | callback processed", apiName);
return new ResponseModel(BBPSConstant.CALLBACK_RECEIVED_SUCCESS,
BBPSConstant.SUCCESS_CODE_STR,
BBPSConstant.HTTP_OK_INT,
"");
}
}
}
@@ -20,9 +20,9 @@ swagger.server.description=Local Development Server
# DataSource
spring.datasource.url=jdbc:postgresql://localhost:5432/BBPS
spring.datasource.username=postgres
spring.datasource.password=UAT@DB_2025
#spring.datasource.password=UAT@DB_2025
#spring.datasource.password=himanshu@123
spring.datasource.password=himanshu@123
spring.datasource.driver-class-name=org.postgresql.Driver
spring.datasource.type=com.zaxxer.hikari.HikariDataSource