updated code
This commit is contained in:
@@ -0,0 +1,116 @@
|
||||
package com.billpaymentservice.bbps.config;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import jakarta.servlet.FilterChain;
|
||||
import jakarta.servlet.ServletException;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.filter.OncePerRequestFilter;
|
||||
import com.billpaymentservice.bbps.util.BBPSConstant;
|
||||
import com.billpaymentservice.bbps.dto.ResponseModel;
|
||||
|
||||
import io.github.resilience4j.ratelimiter.RateLimiter;
|
||||
import io.github.resilience4j.ratelimiter.RateLimiterRegistry;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
@Component
|
||||
@Order(1)
|
||||
public class RateLimitingFilter extends OncePerRequestFilter {
|
||||
|
||||
private final RateLimiterRegistry rateLimiterRegistry;
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(RateLimitingFilter.class);
|
||||
|
||||
// Har MID ke liye alag limiter
|
||||
private final Map<String, RateLimiter> limiterCache = new ConcurrentHashMap<>();
|
||||
|
||||
private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
|
||||
|
||||
public RateLimitingFilter(RateLimiterRegistry rateLimiterRegistry) {
|
||||
this.rateLimiterRegistry = rateLimiterRegistry;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doFilterInternal(HttpServletRequest request,
|
||||
HttpServletResponse response,
|
||||
FilterChain filterChain)
|
||||
throws ServletException, IOException {
|
||||
String mid = request.getHeader("mid");
|
||||
if(mid == null) {
|
||||
mid = "GLOBAL";
|
||||
}
|
||||
|
||||
// Validate MID
|
||||
if (mid == null || mid.isBlank()) {
|
||||
response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
|
||||
response.setContentType("application/json");
|
||||
|
||||
ResponseModel<Object> apiResponse = new ResponseModel<>("mid cannot be null or blank", "FAILURE", HttpServletResponse.SC_BAD_REQUEST, null);
|
||||
response.getWriter().write(OBJECT_MAPPER.writeValueAsString(apiResponse));
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
RateLimiter rateLimiter = limiterCache.computeIfAbsent(
|
||||
mid,
|
||||
key -> rateLimiterRegistry.rateLimiter("default")
|
||||
);
|
||||
|
||||
// Rate limit check
|
||||
if (!rateLimiter.acquirePermission()) {
|
||||
|
||||
// Prefer existing constant if it maps to 429, otherwise fallback to literal 429
|
||||
int tooManyRequestsStatus =429;
|
||||
|
||||
response.setStatus(tooManyRequestsStatus);
|
||||
response.setContentType("application/json");
|
||||
|
||||
ResponseModel<Object> apiResponse = new ResponseModel<>("Rate limit exceeded for MID: " + mid, "FAILURE", tooManyRequestsStatus, null);
|
||||
response.getWriter().write(OBJECT_MAPPER.writeValueAsString(apiResponse));
|
||||
return;
|
||||
}
|
||||
|
||||
// Proceed with the chain and catch downstream exceptions to return consistent model
|
||||
try {
|
||||
filterChain.doFilter(request, response);
|
||||
} catch (Exception ex) {
|
||||
LOGGER.error("Unhandled exception in filter chain for MID: {}", mid, ex);
|
||||
if (!response.isCommitted()) {
|
||||
response.reset();
|
||||
response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
|
||||
response.setContentType("application/json");
|
||||
ResponseModel<Object> apiResponse = new ResponseModel<>("Internal server error", "FAILURE", HttpServletResponse.SC_INTERNAL_SERVER_ERROR, null);
|
||||
response.getWriter().write(OBJECT_MAPPER.writeValueAsString(apiResponse));
|
||||
}
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("Error while rate limiting request", e);
|
||||
if (!response.isCommitted()) {
|
||||
response.reset();
|
||||
response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
|
||||
response.setContentType("application/json");
|
||||
ResponseModel<Object> apiResponse = new ResponseModel<>("Internal server error", "FAILURE", HttpServletResponse.SC_INTERNAL_SERVER_ERROR, null);
|
||||
response.getWriter().write(OBJECT_MAPPER.writeValueAsString(apiResponse));
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean shouldNotFilter(HttpServletRequest request) {
|
||||
|
||||
String path = request.getRequestURI();
|
||||
|
||||
return path.startsWith("/swagger")
|
||||
|| path.startsWith("/v3/api-docs")
|
||||
|| path.startsWith("/actuator");
|
||||
}
|
||||
}
|
||||
@@ -46,7 +46,6 @@ public class PaymentController {
|
||||
@ApiDocCommonResponses
|
||||
public ResponseEntity<ResponseModel> requestBillFetch(
|
||||
@RequestBody BillPaymentRequest billPaymentRequest) {
|
||||
|
||||
ResponseModel response = paymentService.initiatePayment(billPaymentRequest);
|
||||
return ResponseEntity.ok(response);
|
||||
}
|
||||
|
||||
@@ -66,9 +66,12 @@ public class TransactionDTO {
|
||||
private String planType;
|
||||
|
||||
// ✅ Date fields as String (for JSON compatibility)
|
||||
private String creationDate;
|
||||
private String modifiedDate;
|
||||
|
||||
private Long createdEpochDate;
|
||||
private Long modifiedEpochDate;
|
||||
@JsonProperty("creationDate")
|
||||
private String creationDateBank;
|
||||
@JsonProperty("modifiedDate")
|
||||
private String modifiedDateBank;
|
||||
@JsonProperty("createdEpochDate")
|
||||
private Long createdEpochDateBank;
|
||||
@JsonProperty("modifiedEpochDate")
|
||||
private Long modifiedEpochDateBank;
|
||||
}
|
||||
|
||||
@@ -47,9 +47,6 @@ public class PaymentStartRecord extends Auditable {
|
||||
@Column(name = "amount", nullable = false)
|
||||
private String amount;
|
||||
|
||||
@Column(name = "mid", nullable = false)
|
||||
private String mid;
|
||||
|
||||
@Column(name = "txn_id", unique = true, nullable = false)
|
||||
private String txnId;
|
||||
|
||||
|
||||
@@ -164,15 +164,15 @@ public class TransactionMaster extends Auditable {
|
||||
@Column(name = "plan_type")
|
||||
private String planType;
|
||||
|
||||
@Column(name = "creation_date")
|
||||
private String creationDate;
|
||||
@Column(name = "creation_date_bank")
|
||||
private String creationDateBank;
|
||||
|
||||
@Column(name = "modified_date")
|
||||
private String modifiedDate;
|
||||
@Column(name = "modified_date_bank")
|
||||
private String modifiedDateBank;
|
||||
|
||||
@Column(name = "created_epoch_date")
|
||||
private Long createdEpochDate;
|
||||
@Column(name = "created_epoch_date_bank")
|
||||
private Long createdEpochDateBank;
|
||||
|
||||
@Column(name = "modified_epoch_date")
|
||||
private Long modifiedEpochDate;
|
||||
@Column(name = "modified_epoch_date_bank")
|
||||
private Long modifiedEpochDateBank;
|
||||
}
|
||||
@@ -153,7 +153,7 @@ public class AgentServiceImpl implements AgentService {
|
||||
LOGGER.error("JSON Parsing Error: {}", e.getMessage(), e);
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), BBPSConstant.JSON_ERROR);
|
||||
// Use standardized user-facing message and status, keep internal details in remarks
|
||||
throw new CustomException(BBPSConstant.MSG_INVALID_JSON_FROM_UPSTREAM, "FAILED", BBPSConstant.INVALID_JSON_STATUS_CODE, e.getMessage());
|
||||
throw new CustomException(BBPSConstant.MSG_INVALID_JSON_FROM_UPSTREAM, BBPSConstant.FAILED_STATUS, BBPSConstant.INVALID_JSON_STATUS_CODE, e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -206,7 +206,7 @@ public class AgentServiceImpl implements AgentService {
|
||||
} catch (JsonProcessingException e) {
|
||||
LOGGER.error("Error parsing BillById JSON: {}", e.getMessage(), e);
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), BBPSConstant.JSON_ERROR);
|
||||
throw new CustomException(BBPSConstant.MSG_INVALID_JSON_FROM_UPSTREAM, "FAILED", BBPSConstant.INVALID_JSON_STATUS_CODE, e.getMessage());
|
||||
throw new CustomException(BBPSConstant.MSG_INVALID_JSON_FROM_UPSTREAM, BBPSConstant.FAILED_STATUS, BBPSConstant.INVALID_JSON_STATUS_CODE, e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -265,7 +265,7 @@ public class AgentServiceImpl implements AgentService {
|
||||
catch (JsonProcessingException e) {
|
||||
LOGGER.error("Error parsing responseData JSON for billId={} : {}", billId, e.getMessage(), e);
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), BBPSConstant.JSON_ERROR);
|
||||
throw new CustomException(BBPSConstant.MSG_INVALID_JSON_FROM_UPSTREAM, "FAILED", BBPSConstant.INVALID_JSON_STATUS_CODE, e.getMessage());
|
||||
throw new CustomException(BBPSConstant.MSG_INVALID_JSON_FROM_UPSTREAM, BBPSConstant.FAILED_STATUS, BBPSConstant.INVALID_JSON_STATUS_CODE, e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -349,7 +349,7 @@ public class AgentServiceImpl implements AgentService {
|
||||
} catch (JsonProcessingException e) {
|
||||
LOGGER.error("JSON Parsing Error: {}", e.getMessage(), e);
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), BBPSConstant.JSON_ERROR);
|
||||
throw new CustomException(BBPSConstant.MSG_INVALID_JSON_FROM_UPSTREAM, "FAILED", BBPSConstant.INVALID_JSON_STATUS_CODE, e.getMessage());
|
||||
throw new CustomException(BBPSConstant.MSG_INVALID_JSON_FROM_UPSTREAM, BBPSConstant.FAILED_STATUS ,BBPSConstant.INVALID_JSON_STATUS_CODE, e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -404,7 +404,7 @@ public class AgentServiceImpl implements AgentService {
|
||||
} catch (JsonProcessingException e) {
|
||||
LOGGER.error("Error parsing BillById JSON: {}", e.getMessage(), e);
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), BBPSConstant.JSON_ERROR);
|
||||
throw new CustomException(BBPSConstant.MSG_INVALID_JSON_FROM_UPSTREAM, "FAILED", BBPSConstant.INVALID_JSON_STATUS_CODE, e.getMessage());
|
||||
throw new CustomException(BBPSConstant.MSG_INVALID_JSON_FROM_UPSTREAM, BBPSConstant.FAILED_STATUS, BBPSConstant.INVALID_JSON_STATUS_CODE, e.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -465,7 +465,7 @@ public class AgentServiceImpl implements AgentService {
|
||||
} catch (com.fasterxml.jackson.core.JsonProcessingException e) {
|
||||
LOGGER.error("Error parsing ValidateByBillId JSON: {}", e.getMessage(), e);
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), BBPSConstant.JSON_ERROR);
|
||||
throw new CustomException(BBPSConstant.MSG_INVALID_JSON_FROM_UPSTREAM, "FAILED", BBPSConstant.INVALID_JSON_STATUS_CODE, e.getMessage());
|
||||
throw new CustomException(BBPSConstant.MSG_INVALID_JSON_FROM_UPSTREAM,BBPSConstant.FAILED_STATUS, BBPSConstant.INVALID_JSON_STATUS_CODE, e.getMessage());
|
||||
}
|
||||
}
|
||||
// ================================== Bill fetch and Bill Validate by Client Req
|
||||
@@ -536,7 +536,7 @@ public class AgentServiceImpl implements AgentService {
|
||||
|
||||
} catch (JsonProcessingException e) {
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), BBPSConstant.JSON_ERROR);
|
||||
throw new CustomException(BBPSConstant.MSG_INVALID_JSON_FROM_UPSTREAM, "FAILED", BBPSConstant.INVALID_JSON_STATUS_CODE, e.getMessage());
|
||||
throw new CustomException(BBPSConstant.MSG_INVALID_JSON_FROM_UPSTREAM, BBPSConstant.FAILED_STATUS, BBPSConstant.INVALID_JSON_STATUS_CODE, e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -598,7 +598,7 @@ public class AgentServiceImpl implements AgentService {
|
||||
|
||||
} catch (JsonProcessingException e) {
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), BBPSConstant.JSON_ERROR);
|
||||
throw new CustomException(BBPSConstant.MSG_INVALID_JSON_FROM_UPSTREAM, "FAILED", BBPSConstant.INVALID_JSON_STATUS_CODE, e.getMessage());
|
||||
throw new CustomException(BBPSConstant.MSG_INVALID_JSON_FROM_UPSTREAM, BBPSConstant.FAILED_STATUS, BBPSConstant.INVALID_JSON_STATUS_CODE, e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -135,7 +135,7 @@ public class ComplainServiceImpl implements ComplainService {
|
||||
|
||||
TransactionMaster transData = dataById.get();
|
||||
// Inject tenantId + agentId into request JSON
|
||||
String transactionCreatedDateString = transData.getCreationDate();
|
||||
String transactionCreatedDateString = transData.getCreationDateBank();
|
||||
LOGGER.info("Date is coming -:" + transactionCreatedDateString);
|
||||
LOGGER.info("Return Date Time After 24 Hours"
|
||||
+ BillerMapperHelper.isComplaintAllowed(transactionCreatedDateString));
|
||||
|
||||
@@ -165,7 +165,7 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
LOGGER.error("Error parsing responseData JSON: {}", e.getMessage());
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), BBPSConstant.JSON_ERROR);
|
||||
// Use user-friendly message constant and keep internal details in remarks
|
||||
throw new CustomException(BBPSConstant.MSG_INVALID_JSON_FROM_UPSTREAM, "FAILED", BBPSConstant.INVALID_JSON_STATUS_CODE, e.getMessage());
|
||||
throw new CustomException(BBPSConstant.MSG_INVALID_JSON_FROM_UPSTREAM, BBPSConstant.FAILED_STATUS, BBPSConstant.INVALID_JSON_STATUS_CODE, e.getMessage());
|
||||
|
||||
}
|
||||
|
||||
@@ -229,7 +229,7 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
LOGGER.error("Error parsing responseData JSON: {}", e.getMessage());
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), BBPSConstant.JSON_ERROR);
|
||||
// Unified constant for invalid JSON
|
||||
throw new CustomException(BBPSConstant.MSG_INVALID_JSON_FROM_UPSTREAM, "FAILED", BBPSConstant.INVALID_JSON_STATUS_CODE, e.getMessage());
|
||||
throw new CustomException(BBPSConstant.MSG_INVALID_JSON_FROM_UPSTREAM, BBPSConstant.FAILED_STATUS, BBPSConstant.INVALID_JSON_STATUS_CODE, e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -300,7 +300,7 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
} catch (JsonProcessingException e) {
|
||||
LOGGER.error("Error parsing responseData JSON: {}", e.getMessage());
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), BBPSConstant.JSON_ERROR);
|
||||
throw new CustomException(BBPSConstant.MSG_INVALID_JSON_FROM_UPSTREAM, "FAILED", BBPSConstant.INVALID_JSON_STATUS_CODE, e.getMessage());
|
||||
throw new CustomException(BBPSConstant.MSG_INVALID_JSON_FROM_UPSTREAM,BBPSConstant.FAILED_STATUS, BBPSConstant.INVALID_JSON_STATUS_CODE, e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -366,7 +366,7 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
} catch (JsonProcessingException e) {
|
||||
LOGGER.error("Error parsing responseData JSON: {}", e.getMessage());
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), BBPSConstant.JSON_ERROR);
|
||||
throw new CustomException(BBPSConstant.MSG_INVALID_JSON_FROM_UPSTREAM, "FAILED", BBPSConstant.INVALID_JSON_STATUS_CODE, e.getMessage());
|
||||
throw new CustomException(BBPSConstant.MSG_INVALID_JSON_FROM_UPSTREAM, BBPSConstant.FAILED_STATUS, BBPSConstant.INVALID_JSON_STATUS_CODE, e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -433,7 +433,7 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
} catch (JsonProcessingException e) {
|
||||
LOGGER.error("Error parsing responseData JSON: {}", e.getMessage());
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), BBPSConstant.JSON_ERROR);
|
||||
throw new CustomException(BBPSConstant.MSG_INVALID_JSON_FROM_UPSTREAM, "FAILED", BBPSConstant.INVALID_JSON_STATUS_CODE, e.getMessage());
|
||||
throw new CustomException(BBPSConstant.MSG_INVALID_JSON_FROM_UPSTREAM,BBPSConstant.FAILED_STATUS, BBPSConstant.INVALID_JSON_STATUS_CODE, e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -572,7 +572,7 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
} catch (JsonProcessingException e) {
|
||||
LOGGER.error("Error parsing responseData JSON: {}", e.getMessage());
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), BBPSConstant.JSON_ERROR);
|
||||
throw new CustomException(BBPSConstant.MSG_INVALID_JSON_FROM_UPSTREAM, "FAILED", BBPSConstant.INVALID_JSON_STATUS_CODE, e.getMessage());
|
||||
throw new CustomException(BBPSConstant.MSG_INVALID_JSON_FROM_UPSTREAM, BBPSConstant.FAILED_STATUS, BBPSConstant.INVALID_JSON_STATUS_CODE, e.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -638,7 +638,7 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
} catch (JsonProcessingException e) {
|
||||
LOGGER.error("Error parsing responseData JSON: {}", e.getMessage());
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), BBPSConstant.JSON_ERROR);
|
||||
throw new CustomException(BBPSConstant.MSG_INVALID_JSON_FROM_UPSTREAM, "FAILED", BBPSConstant.INVALID_JSON_STATUS_CODE, e.getMessage());
|
||||
throw new CustomException(BBPSConstant.MSG_INVALID_JSON_FROM_UPSTREAM, BBPSConstant.FAILED_STATUS, BBPSConstant.INVALID_JSON_STATUS_CODE, e.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -702,7 +702,7 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
} catch (JsonProcessingException e) {
|
||||
LOGGER.error("Error parsing responseData JSON: {}", e.getMessage());
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), BBPSConstant.JSON_ERROR);
|
||||
throw new CustomException(BBPSConstant.MSG_INVALID_JSON_FROM_UPSTREAM, "FAILED", BBPSConstant.INVALID_JSON_STATUS_CODE, e.getMessage());
|
||||
throw new CustomException(BBPSConstant.MSG_INVALID_JSON_FROM_UPSTREAM, BBPSConstant.FAILED_STATUS, BBPSConstant.INVALID_JSON_STATUS_CODE, e.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -759,7 +759,7 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
} catch (JsonProcessingException e) {
|
||||
LOGGER.error("Error parsing responseData JSON: {}", e.getMessage());
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), BBPSConstant.JSON_ERROR);
|
||||
throw new CustomException(BBPSConstant.MSG_INVALID_JSON_FROM_UPSTREAM, "FAILED", BBPSConstant.INVALID_JSON_STATUS_CODE, e.getMessage());
|
||||
throw new CustomException(BBPSConstant.MSG_INVALID_JSON_FROM_UPSTREAM,BBPSConstant.FAILED_STATUS , BBPSConstant.INVALID_JSON_STATUS_CODE, e.getMessage());
|
||||
|
||||
}
|
||||
}
|
||||
@@ -831,7 +831,7 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
} catch (JsonProcessingException e) {
|
||||
LOGGER.error("Error parsing responseData JSON: {}", e.getMessage());
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), BBPSConstant.JSON_ERROR);
|
||||
throw new CustomException(BBPSConstant.MSG_INVALID_JSON_FROM_UPSTREAM, "FAILED", BBPSConstant.INVALID_JSON_STATUS_CODE, e.getMessage());
|
||||
throw new CustomException(BBPSConstant.MSG_INVALID_JSON_FROM_UPSTREAM, BBPSConstant.FAILED_STATUS, BBPSConstant.INVALID_JSON_STATUS_CODE, e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -889,7 +889,7 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
} catch (JsonProcessingException e) {
|
||||
LOGGER.error("Error parsing responseData JSON: {} :: class :: method ", e.getMessage());
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), BBPSConstant.JSON_ERROR);
|
||||
throw new CustomException(BBPSConstant.MSG_INVALID_JSON_FROM_UPSTREAM, "FAILED", BBPSConstant.INVALID_JSON_STATUS_CODE, e.getMessage());
|
||||
throw new CustomException(BBPSConstant.MSG_INVALID_JSON_FROM_UPSTREAM,BBPSConstant.FAILED_STATUS, BBPSConstant.INVALID_JSON_STATUS_CODE, e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -188,7 +188,7 @@ public class PaymentServiceImpl implements PaymentService {
|
||||
} catch (JsonProcessingException e) {
|
||||
LOGGER.error("JSON Parsing Error in initiatePayment: {}", e.getMessage(), e);
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), BBPSConstant.JSON_ERROR);
|
||||
throw new CustomException(BBPSConstant.MSG_INVALID_JSON_FROM_UPSTREAM, "FAILED", BBPSConstant.INVALID_JSON_STATUS_CODE, e.getMessage());
|
||||
throw new CustomException(BBPSConstant.MSG_INVALID_JSON_FROM_UPSTREAM, BBPSConstant.FAILED_STATUS, BBPSConstant.INVALID_JSON_STATUS_CODE, e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -266,7 +266,7 @@ public class PaymentServiceImpl implements PaymentService {
|
||||
} catch (JsonProcessingException e) {
|
||||
LOGGER.error("Error parsing transaction status JSON: {}", e.getMessage(), e);
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), BBPSConstant.JSON_ERROR);
|
||||
throw new CustomException(BBPSConstant.MSG_INVALID_JSON_FROM_UPSTREAM, "FAILED", BBPSConstant.INVALID_JSON_STATUS_CODE, e.getMessage());
|
||||
throw new CustomException(BBPSConstant.MSG_INVALID_JSON_FROM_UPSTREAM, BBPSConstant.FAILED_STATUS, BBPSConstant.INVALID_JSON_STATUS_CODE, e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -332,7 +332,7 @@ public class PaymentServiceImpl implements PaymentService {
|
||||
} catch (JsonProcessingException e) {
|
||||
LOGGER.error("Error parsing responseData JSON: {}", e.getMessage(), e);
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), BBPSConstant.JSON_ERROR);
|
||||
throw new CustomException(BBPSConstant.MSG_INVALID_JSON_FROM_UPSTREAM, "FAILED", BBPSConstant.INVALID_JSON_STATUS_CODE, e.getMessage());
|
||||
throw new CustomException(BBPSConstant.MSG_INVALID_JSON_FROM_UPSTREAM,BBPSConstant.FAILED_STATUS, BBPSConstant.INVALID_JSON_STATUS_CODE, e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -415,7 +415,7 @@ public class PaymentServiceImpl implements PaymentService {
|
||||
} catch (JsonProcessingException e) {
|
||||
LOGGER.error("Error parsing JSON in transaction status API: {}", e.getMessage(), e);
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), BBPSConstant.JSON_ERROR);
|
||||
throw new CustomException(BBPSConstant.MSG_INVALID_JSON_FROM_UPSTREAM, "FAILED", BBPSConstant.INVALID_JSON_STATUS_CODE, e.getMessage());
|
||||
throw new CustomException(BBPSConstant.MSG_INVALID_JSON_FROM_UPSTREAM,BBPSConstant.FAILED_STATUS, BBPSConstant.INVALID_JSON_STATUS_CODE, e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,9 +19,9 @@ public class BBPSConstant extends BBPS_RESPONSE_COD_CONSTANT {
|
||||
public static final Long FRAUD_CODE = 1001L;
|
||||
public static final int BADREQUEST = 400;
|
||||
|
||||
public static final String SUCCESS_STATUS = "success";
|
||||
public static final String FAILED_STATUS = "failed";
|
||||
public static final String PENDING_STATUS = "pending";
|
||||
public static final String SUCCESS_STATUS = "SUCCESS";
|
||||
public static final String FAILED_STATUS = "FAILED";
|
||||
public static final String PENDING_STATUS = "PENDING";
|
||||
public static final String SENT_TO_PROCESSOR_STATUS = "txn sent to processor";
|
||||
|
||||
public static final String SUCCESS_REMARK = "200-Transaction process successfully";
|
||||
@@ -130,6 +130,7 @@ public class BBPSConstant extends BBPS_RESPONSE_COD_CONSTANT {
|
||||
public static final int HTTP_OK_INT = 200;
|
||||
public static final int HTTP_NOT_FOUND = 404;
|
||||
public static final int HTTP_INTERNAL_SERVER_ERROR = 500;
|
||||
public static final int HTTP_TO_MANY_REQUEST=429;
|
||||
|
||||
// Response and helper keys
|
||||
public static final String HTTP_SERVICE_ERROR_PREFIX = "HttpService Error";
|
||||
|
||||
@@ -1033,9 +1033,9 @@ public class BillerMapperHelper {
|
||||
dto.setPaymentInformation(transactionMaster.getPaymentInformation());
|
||||
dto.setPlanId(transactionMaster.getPlanId());
|
||||
dto.setPlanType(transactionMaster.getPlanType());
|
||||
dto.setCreationDate(transactionMaster.getCreationDate());
|
||||
dto.setModifiedDate(transactionMaster.getModifiedDate());
|
||||
dto.setCreatedEpochDate(transactionMaster.getCreatedEpochDate());
|
||||
dto.setCreationDate(transactionMaster.getCreationDateBank());
|
||||
dto.setModifiedDate(transactionMaster.getModifiedDateBank());
|
||||
dto.setCreatedEpochDate(transactionMaster.getCreatedEpochDateBank());
|
||||
dto.setModifiedEpochDate(transactionMaster.getModifiedEpochDate());
|
||||
return dto;
|
||||
}
|
||||
@@ -1048,7 +1048,7 @@ public class BillerMapperHelper {
|
||||
TransactionHistoryParticularDetailsDTO dto = new TransactionHistoryParticularDetailsDTO();
|
||||
dto.setBankTxnId(transactionMaster.getBankTxnId());
|
||||
dto.setTxnId(transactionMaster.getTxnId());
|
||||
dto.setCreationDate(transactionMaster.getCreationDate());
|
||||
dto.setCreationDate(transactionMaster.getCreationDateBank());
|
||||
dto.setBillerCategory(transactionMaster.getBillerCategory());
|
||||
dto.setBillerName(transactionMaster.getBillerName());
|
||||
dto.setStatus(transactionMaster.getStatus());
|
||||
@@ -1091,21 +1091,21 @@ public class BillerMapperHelper {
|
||||
record.setClientUserId(request.getClientUserId());
|
||||
record.setInternalTxnId(txnId);
|
||||
|
||||
if (apiResponse != null && apiResponse.getResponseData() != null) {
|
||||
record.setAmount(Optional.ofNullable(apiResponse.getResponseData().getAmount()).orElse("0.00"));
|
||||
record.setMid(Optional.ofNullable(apiResponse.getResponseData().getMid()).orElse("DUMMY_MID"));
|
||||
record.setTxnId(Optional.ofNullable(apiResponse.getResponseData().getTxnId()).orElse("DUMMY_TXN"));
|
||||
record.setQrString(Optional.ofNullable(apiResponse.getResponseData().getQrString()).orElse("NO_QR"));
|
||||
// parse createdOn string into LocalDateTime and set on Auditable
|
||||
LocalDateTime createdOn = parseToLocalDateTime(apiResponse.getResponseData().getCreatedOn());
|
||||
|
||||
record.setTxnStatus("PENDING");
|
||||
} else {
|
||||
record.setAmount("0.00");
|
||||
record.setMid(request.getMid());
|
||||
record.setTxnStatus("PENDING");
|
||||
}
|
||||
|
||||
if (apiResponse != null &&
|
||||
apiResponse.getResponseData() != null) {
|
||||
record.setAmount(Optional.ofNullable(apiResponse.getResponseData().getAmount(
|
||||
)).orElse("0.00"));
|
||||
|
||||
record.setTxnId(Optional.ofNullable(apiResponse.getResponseData().getTxnId())
|
||||
.orElse("DUMMY_TXN"));
|
||||
record.setQrString(Optional.ofNullable(apiResponse.getResponseData().
|
||||
getQrString()).orElse("NO_QR")); // parse createdOn string into LocalDateTime and set on Auditable
|
||||
LocalDateTime createdOn =parseToLocalDateTime(apiResponse.getResponseData().getCreatedOn());
|
||||
|
||||
record.setTxnStatus("PENDING"); } else { record.setAmount("0.00");
|
||||
record.setTxnStatus("PENDING"); }
|
||||
|
||||
|
||||
// store the original request body and raw response
|
||||
record.setRequestBody(requestJson);
|
||||
record.setResponseBody(rawResponse);
|
||||
|
||||
Reference in New Issue
Block a user