improved code and added logs in paymentserviceimpl
This commit is contained in:
@@ -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,
|
||||
"");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user