From 1bf845bd7bb0bf0b50e7b0fdbfe4701293a0b3b0 Mon Sep 17 00:00:00 2001 From: Bishwajeet Kumar Rajak Date: Mon, 29 Jun 2026 16:02:32 +0530 Subject: [PATCH] added logger for account creation --- .../CreateDepositAccountOkRequest.java | 4 +-- .../main/ipks/dto/cif/CifCreateRequest.java | 2 +- .../ipks/service/CbsIntegrationService.java | 34 +++++++++++++------ 3 files changed, 27 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/main/ipks/dto/account/CreateDepositAccountOkRequest.java b/src/main/java/com/main/ipks/dto/account/CreateDepositAccountOkRequest.java index 85d479a..6922a22 100644 --- a/src/main/java/com/main/ipks/dto/account/CreateDepositAccountOkRequest.java +++ b/src/main/java/com/main/ipks/dto/account/CreateDepositAccountOkRequest.java @@ -33,7 +33,7 @@ public class CreateDepositAccountOkRequest { @JsonProperty("DefInt22") private int defInt22 = 11; @JsonProperty("DefInt23") private int defInt23 = 1; @JsonProperty("DefInt24") private int defInt24 = 10; - @JsonProperty("DefInt25") private int defInt25 = 0; + @JsonProperty("DefInt25") private int defInt25 = 1; @JsonProperty("Intpcode1") private String intpcode1 = "R"; @JsonProperty("AcctNum2") private int acctNum2 = 0; @@ -149,7 +149,7 @@ public class CreateDepositAccountOkRequest { @JsonProperty("TypeofGold") private String typeofGold = ""; @JsonProperty("DfltStr48") private String dfltStr48 = ""; - @JsonProperty("MortgageOffsetInd") private String mortgageOffsetInd = ""; + @JsonProperty("MortgageOffsetInd") private String mortgageOffsetInd = "N"; @JsonProperty("NomiFlag") private String nomiFlag = ""; // --- Getters/Setters for 6 dynamic fields (others optional) --- diff --git a/src/main/java/com/main/ipks/dto/cif/CifCreateRequest.java b/src/main/java/com/main/ipks/dto/cif/CifCreateRequest.java index 0af0915..8ce1162 100644 --- a/src/main/java/com/main/ipks/dto/cif/CifCreateRequest.java +++ b/src/main/java/com/main/ipks/dto/cif/CifCreateRequest.java @@ -271,7 +271,7 @@ public class CifCreateRequest { private String countryCode = "IN"; @JsonProperty("StateCode") - private String stateCode = "32"; + private String stateCode = "44"; @JsonProperty("VoterIdNum") private String voterIdNum = ""; diff --git a/src/main/java/com/main/ipks/service/CbsIntegrationService.java b/src/main/java/com/main/ipks/service/CbsIntegrationService.java index 602db79..c74b839 100644 --- a/src/main/java/com/main/ipks/service/CbsIntegrationService.java +++ b/src/main/java/com/main/ipks/service/CbsIntegrationService.java @@ -46,6 +46,7 @@ public class CbsIntegrationService { public CifApiResponse createCustomer(IpksCustomerRequest in) { try { // Token + headers (TokenFetchException handled globally -> 503) + log.info("Fetching Token for BankID: {} ",in.getBankId()); String token = tokenService.getToken(in.getBankId()); HttpHeaders headers = buildHeaders(token); @@ -56,14 +57,17 @@ public class CbsIntegrationService { HttpEntity entity = new HttpEntity<>(req, headers); ResponseEntity response; + String url = cifUrl + "/" + in.getBankId(); + log.info("Calling CIF API for bank {}. url={}", in.getBankId(), url); + try { - response = restTemplate.exchange(cifUrl + "/" + in.getBankId(), HttpMethod.POST, entity, String.class); + response = restTemplate.exchange(url, HttpMethod.POST, entity, String.class); } catch (HttpStatusCodeException ex) { if (ex.getStatusCode() == HttpStatus.UNAUTHORIZED || ex.getStatusCode() == HttpStatus.FORBIDDEN) { - log.warn("[C-EDGE] CIF call unauthorized. Refreshing token and retrying once..."); + log.warn("[C-EDGE] CIF call unauthorized. Refreshing token and retrying once...URL:{}",url); HttpEntity retryEntity = new HttpEntity<>(req, buildHeaders(tokenService.refreshToken(in.getBankId()))); - response = restTemplate.exchange(cifUrl + "/" + in.getBankId(), HttpMethod.POST, retryEntity, String.class); + response = restTemplate.exchange(url, HttpMethod.POST, retryEntity, String.class); } else { // If upstream provided a JSON body, propagate it to client (as 502) String raw = ex.getResponseBodyAsString(); @@ -88,6 +92,7 @@ public class CbsIntegrationService { CifApiResponse body = om.readValue(bodyStr, CifApiResponse.class); if (body.getResponse() != null) { log.info("CIF Created..."); + log.info("Full CIF Creation Response: {}", om.writeValueAsString(body)); } return body; } else { @@ -113,7 +118,9 @@ public class CbsIntegrationService { // ---------------- Account Creation (API-1 + API-2) ---------------- public AccountCreationResponse createAccount(IpksAccountRequest reqDto) { try { - log.info("BANK-ID- {}",reqDto.getBankId()); + log.info("Account Creation Request For BANK-ID- {}",reqDto.getBankId()); + log.info("Fetching Token for BankID: {} ",reqDto.getBankId()); + String token = tokenService.getToken(reqDto.getBankId()); HttpHeaders headers = buildHeaders(token); @@ -125,15 +132,17 @@ public class CbsIntegrationService { log.debug("[C-EDGE] API-1 for Account Creation: Request JSON: {}", safeJson(api1Req)); ResponseEntity api1Raw; + String url = accountUrl + "/" + reqDto.getBankId(); + log.info("Calling 1st API of Account Creation for bank {}. url={}", reqDto.getBankId(), url); try { - api1Raw = restTemplate.exchange(accountUrl + "/" + reqDto.getBankId(), HttpMethod.POST, api1Entity, String.class); + api1Raw = restTemplate.exchange(url, HttpMethod.POST, api1Entity, String.class); } catch (HttpStatusCodeException ex) { if (ex.getStatusCode() == HttpStatus.UNAUTHORIZED || ex.getStatusCode() == HttpStatus.FORBIDDEN) { - log.warn("[C-EDGE] API-1 unauthorized. Refresh + retry once"); + log.warn("[C-EDGE] API-1 unauthorized. Refresh + retry once URL:{}",url); HttpEntity retryEntity = new HttpEntity<>(api1Req, buildHeaders(tokenService.refreshToken(reqDto.getBankId()))); - api1Raw = restTemplate.exchange(accountUrl + "/" + reqDto.getBankId(), HttpMethod.POST, retryEntity, String.class); + api1Raw = restTemplate.exchange(url, HttpMethod.POST, retryEntity, String.class); } else { String raw = ex.getResponseBodyAsString(); if (raw != null && !raw.isBlank() && looksJson(raw)) { @@ -181,15 +190,19 @@ public class CbsIntegrationService { // --- API-2 --- HttpEntity api2Entity = new HttpEntity<>(api2Req, headers); + ResponseEntity api2Raw; + String url2 = accountOkUrl + "/" + reqDto.getBankId(); + log.info("Calling 2nd API of Account Creation for bank {}. url={}", reqDto.getBankId(), url2); + try { - api2Raw = restTemplate.exchange(accountOkUrl + "/" + reqDto.getBankId(), HttpMethod.POST, api2Entity, String.class); + api2Raw = restTemplate.exchange(url2, HttpMethod.POST, api2Entity, String.class); } catch (HttpStatusCodeException ex) { if (ex.getStatusCode() == HttpStatus.UNAUTHORIZED || ex.getStatusCode() == HttpStatus.FORBIDDEN) { - log.warn("[C-EDGE] API-2 unauthorized. Refresh + retry once"); + log.warn("[C-EDGE] API-2 unauthorized. Refresh + retry once URL: {}",url2); HttpEntity retryEntity = new HttpEntity<>(api2Req, buildHeaders(tokenService.refreshToken(reqDto.getBankId()))); - api2Raw = restTemplate.exchange(accountOkUrl + "/" + reqDto.getBankId(), HttpMethod.POST, retryEntity, String.class); + api2Raw = restTemplate.exchange(url2, HttpMethod.POST, retryEntity, String.class); } else { String raw = ex.getResponseBodyAsString(); if (raw != null && !raw.isBlank() && looksJson(raw)) { @@ -216,6 +229,7 @@ public class CbsIntegrationService { // Success -> map final AccountCreationResponse finalResp = om.readValue(api2Str, AccountCreationResponse.class); log.info("Account Created..."); + log.info("Full Account Creation Response: {}", om.writeValueAsString(finalResp)); return finalResp;