update code
This commit is contained in:
@@ -9,7 +9,6 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import com.billpaymentservice.bbps.dto.ResponseModel;
|
import com.billpaymentservice.bbps.dto.ResponseModel;
|
||||||
import com.billpaymentservice.bbps.dto.request.BillFetchbyClientIdRequest;
|
|
||||||
import com.billpaymentservice.bbps.dto.request.BillPaymentRequest;
|
import com.billpaymentservice.bbps.dto.request.BillPaymentRequest;
|
||||||
import com.billpaymentservice.bbps.dto.request.TransactionStatusRequest;
|
import com.billpaymentservice.bbps.dto.request.TransactionStatusRequest;
|
||||||
import com.billpaymentservice.bbps.service.PaymentService;
|
import com.billpaymentservice.bbps.service.PaymentService;
|
||||||
@@ -44,12 +43,6 @@ public class PaymentController {
|
|||||||
return ResponseEntity.ok(response);
|
return ResponseEntity.ok(response);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping(value = "/billFetchbyClientId", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
|
|
||||||
public ResponseEntity<ResponseModel> checkBillFetchbyClientId(
|
|
||||||
@Validated @RequestBody BillFetchbyClientIdRequest transactionStatusRequest) {
|
|
||||||
|
|
||||||
ResponseModel response = paymentService.checkBillFetchbyClientId(transactionStatusRequest);
|
|
||||||
return ResponseEntity.ok(response);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,14 +0,0 @@
|
|||||||
package com.billpaymentservice.bbps.dto.request;
|
|
||||||
|
|
||||||
import jakarta.validation.constraints.NotBlank;
|
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.Setter;
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
public class BillFetchbyClientIdRequest extends BaseClass{
|
|
||||||
|
|
||||||
@NotBlank(message = "client Req Id is not be null")
|
|
||||||
private String clientReqId;
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
package com.billpaymentservice.bbps.service;
|
package com.billpaymentservice.bbps.service;
|
||||||
|
|
||||||
import com.billpaymentservice.bbps.dto.ResponseModel;
|
import com.billpaymentservice.bbps.dto.ResponseModel;
|
||||||
import com.billpaymentservice.bbps.dto.request.BillFetchbyClientIdRequest;
|
|
||||||
import com.billpaymentservice.bbps.dto.request.BillPaymentRequest;
|
import com.billpaymentservice.bbps.dto.request.BillPaymentRequest;
|
||||||
import com.billpaymentservice.bbps.dto.request.TransactionStatusRequest;
|
import com.billpaymentservice.bbps.dto.request.TransactionStatusRequest;
|
||||||
|
|
||||||
@@ -11,6 +10,5 @@ public interface PaymentService {
|
|||||||
|
|
||||||
public ResponseModel checkTrasactionStatus(TransactionStatusRequest transactionStatusRequest);
|
public ResponseModel checkTrasactionStatus(TransactionStatusRequest transactionStatusRequest);
|
||||||
|
|
||||||
public ResponseModel checkBillFetchbyClientId(BillFetchbyClientIdRequest transactionStatusRequest);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ import org.springframework.stereotype.Service;
|
|||||||
|
|
||||||
import com.billpaymentservice.bbps.dto.GeneralResp;
|
import com.billpaymentservice.bbps.dto.GeneralResp;
|
||||||
import com.billpaymentservice.bbps.dto.ResponseModel;
|
import com.billpaymentservice.bbps.dto.ResponseModel;
|
||||||
import com.billpaymentservice.bbps.dto.request.BillFetchbyClientIdRequest;
|
|
||||||
import com.billpaymentservice.bbps.dto.request.BillPaymentRequest;
|
import com.billpaymentservice.bbps.dto.request.BillPaymentRequest;
|
||||||
import com.billpaymentservice.bbps.dto.request.TransactionStatusRequest;
|
import com.billpaymentservice.bbps.dto.request.TransactionStatusRequest;
|
||||||
import com.billpaymentservice.bbps.dto.response.BillPaymentResponse;
|
import com.billpaymentservice.bbps.dto.response.BillPaymentResponse;
|
||||||
@@ -302,72 +301,6 @@ public class PaymentServiceImpl implements PaymentService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public ResponseModel checkBillFetchbyClientId(BillFetchbyClientIdRequest transactionStatusRequest) {
|
|
||||||
helper.validateMerchant(transactionStatusRequest.getMid());
|
|
||||||
String txnID = helper.generateTxnId(15);
|
|
||||||
String apiName = "checkTrasactionStatus";
|
|
||||||
String requestId = transactionStatusRequest.getReqId();
|
|
||||||
String requestJson = helper.convertObjectToJson(transactionStatusRequest);
|
|
||||||
String url = paymentUrl + BBPSConstant.CHECK_TRANSACTION_BY_CLIENT_URL
|
|
||||||
+ transactionStatusRequest.getClientReqId();
|
|
||||||
|
|
||||||
LOGGER.info("Checking transaction status (public) for txnId={} and reqId={}",
|
|
||||||
transactionStatusRequest.getClientReqId(), requestId);
|
|
||||||
|
|
||||||
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId("ORG001");
|
|
||||||
HttpHeaders headers = new HttpHeaders();
|
|
||||||
headers.set("x-digiledge-key", headersData.getXDigiledgeKey());
|
|
||||||
headers.set("agentId", headersData.getAgentId());
|
|
||||||
headers.set("tenantId", headersData.getTenantId());
|
|
||||||
headers.setContentType(MediaType.APPLICATION_JSON);
|
|
||||||
|
|
||||||
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnID, apiName,
|
|
||||||
transactionStatusRequest.getMid(), "POST", requestJson);
|
|
||||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, url, "GET", null);
|
|
||||||
ObjectMapper objectMapper = new ObjectMapper();
|
|
||||||
|
|
||||||
//String saveDummyToDatabase = mapperHelper.saveDummyToDatabase();
|
|
||||||
//LOGGER.info("Return Status"+ saveDummyToDatabase);
|
|
||||||
Map<String, String> responseMap = httpService.getRequest(url, headers);
|
|
||||||
String responseData = responseMap.get("data");
|
|
||||||
LOGGER.info("Transaction status response data: {}", responseData);
|
|
||||||
helper.updateOutboundLogResponse(outboundLog, responseData);
|
|
||||||
|
|
||||||
try {
|
|
||||||
Map<String, Object> dataMap = objectMapper.readValue(responseData,
|
|
||||||
new TypeReference<Map<String, Object>>() {
|
|
||||||
});
|
|
||||||
if (!dataMap.containsKey("generalResp")) {
|
|
||||||
helper.updateInboundLogFailure(inboundLog, responseData, String.valueOf(dataMap.get("status")));
|
|
||||||
LOGGER.warn("Invalid transaction status response for txnId={} from BBPS",
|
|
||||||
transactionStatusRequest.getClientReqId());
|
|
||||||
throw new CustomException(String.valueOf(dataMap.get("message")), String.valueOf(dataMap.get("status")),
|
|
||||||
Integer.parseInt(String.valueOf(dataMap.get("statusCode"))),
|
|
||||||
String.valueOf(dataMap.get("remarks")));
|
|
||||||
}
|
|
||||||
|
|
||||||
ClientReqIdResponse responseWrapper = objectMapper.convertValue(dataMap, ClientReqIdResponse.class);
|
|
||||||
GeneralResp generalResp = responseWrapper.getGenericResponse();
|
|
||||||
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
|
|
||||||
mapperHelper.storeClientReqIdResponse(responseWrapper,requestId,txnID);
|
|
||||||
|
|
||||||
String status = generalResp.getStatus();
|
|
||||||
LOGGER.info("Current transaction status: {}", status);
|
|
||||||
|
|
||||||
ResponseModel responseModel = new ResponseModel(generalResp.getMessage(), generalResp.getStatus(),
|
|
||||||
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return responseModel;
|
|
||||||
|
|
||||||
} catch (JsonProcessingException e) {
|
|
||||||
LOGGER.error("Error parsing responseData JSON: {}", e.getMessage(), e);
|
|
||||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), "JSON_ERROR");
|
|
||||||
throw new CustomException("Invalid JSON received from API");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
Reference in New Issue
Block a user