added logger for account creation

This commit is contained in:
2026-06-29 16:02:32 +05:30
parent b418ea6fe2
commit 1bf845bd7b
3 changed files with 27 additions and 13 deletions
@@ -33,7 +33,7 @@ public class CreateDepositAccountOkRequest {
@JsonProperty("DefInt22") private int defInt22 = 11; @JsonProperty("DefInt22") private int defInt22 = 11;
@JsonProperty("DefInt23") private int defInt23 = 1; @JsonProperty("DefInt23") private int defInt23 = 1;
@JsonProperty("DefInt24") private int defInt24 = 10; @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("Intpcode1") private String intpcode1 = "R";
@JsonProperty("AcctNum2") private int acctNum2 = 0; @JsonProperty("AcctNum2") private int acctNum2 = 0;
@@ -149,7 +149,7 @@ public class CreateDepositAccountOkRequest {
@JsonProperty("TypeofGold") private String typeofGold = ""; @JsonProperty("TypeofGold") private String typeofGold = "";
@JsonProperty("DfltStr48") private String dfltStr48 = ""; @JsonProperty("DfltStr48") private String dfltStr48 = "";
@JsonProperty("MortgageOffsetInd") private String mortgageOffsetInd = ""; @JsonProperty("MortgageOffsetInd") private String mortgageOffsetInd = "N";
@JsonProperty("NomiFlag") private String nomiFlag = ""; @JsonProperty("NomiFlag") private String nomiFlag = "";
// --- Getters/Setters for 6 dynamic fields (others optional) --- // --- Getters/Setters for 6 dynamic fields (others optional) ---
@@ -271,7 +271,7 @@ public class CifCreateRequest {
private String countryCode = "IN"; private String countryCode = "IN";
@JsonProperty("StateCode") @JsonProperty("StateCode")
private String stateCode = "32"; private String stateCode = "44";
@JsonProperty("VoterIdNum") @JsonProperty("VoterIdNum")
private String voterIdNum = ""; private String voterIdNum = "";
@@ -46,6 +46,7 @@ public class CbsIntegrationService {
public CifApiResponse createCustomer(IpksCustomerRequest in) { public CifApiResponse createCustomer(IpksCustomerRequest in) {
try { try {
// Token + headers (TokenFetchException handled globally -> 503) // Token + headers (TokenFetchException handled globally -> 503)
log.info("Fetching Token for BankID: {} ",in.getBankId());
String token = tokenService.getToken(in.getBankId()); String token = tokenService.getToken(in.getBankId());
HttpHeaders headers = buildHeaders(token); HttpHeaders headers = buildHeaders(token);
@@ -56,14 +57,17 @@ public class CbsIntegrationService {
HttpEntity<CifCreateRequest> entity = new HttpEntity<>(req, headers); HttpEntity<CifCreateRequest> entity = new HttpEntity<>(req, headers);
ResponseEntity<String> response; ResponseEntity<String> response;
String url = cifUrl + "/" + in.getBankId();
log.info("Calling CIF API for bank {}. url={}", in.getBankId(), url);
try { try {
response = restTemplate.exchange(cifUrl + "/" + in.getBankId(), HttpMethod.POST, entity, String.class); response = restTemplate.exchange(url, HttpMethod.POST, entity, String.class);
} catch (HttpStatusCodeException ex) { } catch (HttpStatusCodeException ex) {
if (ex.getStatusCode() == HttpStatus.UNAUTHORIZED || ex.getStatusCode() == HttpStatus.FORBIDDEN) { 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<CifCreateRequest> retryEntity = HttpEntity<CifCreateRequest> retryEntity =
new HttpEntity<>(req, buildHeaders(tokenService.refreshToken(in.getBankId()))); 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 { } else {
// If upstream provided a JSON body, propagate it to client (as 502) // If upstream provided a JSON body, propagate it to client (as 502)
String raw = ex.getResponseBodyAsString(); String raw = ex.getResponseBodyAsString();
@@ -88,6 +92,7 @@ public class CbsIntegrationService {
CifApiResponse body = om.readValue(bodyStr, CifApiResponse.class); CifApiResponse body = om.readValue(bodyStr, CifApiResponse.class);
if (body.getResponse() != null) { if (body.getResponse() != null) {
log.info("CIF Created..."); log.info("CIF Created...");
log.info("Full CIF Creation Response: {}", om.writeValueAsString(body));
} }
return body; return body;
} else { } else {
@@ -113,7 +118,9 @@ public class CbsIntegrationService {
// ---------------- Account Creation (API-1 + API-2) ---------------- // ---------------- Account Creation (API-1 + API-2) ----------------
public AccountCreationResponse createAccount(IpksAccountRequest reqDto) { public AccountCreationResponse createAccount(IpksAccountRequest reqDto) {
try { 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()); String token = tokenService.getToken(reqDto.getBankId());
HttpHeaders headers = buildHeaders(token); HttpHeaders headers = buildHeaders(token);
@@ -125,15 +132,17 @@ public class CbsIntegrationService {
log.debug("[C-EDGE] API-1 for Account Creation: Request JSON: {}", safeJson(api1Req)); log.debug("[C-EDGE] API-1 for Account Creation: Request JSON: {}", safeJson(api1Req));
ResponseEntity<String> api1Raw; ResponseEntity<String> api1Raw;
String url = accountUrl + "/" + reqDto.getBankId();
log.info("Calling 1st API of Account Creation for bank {}. url={}", reqDto.getBankId(), url);
try { try {
api1Raw = restTemplate.exchange(accountUrl + "/" + reqDto.getBankId(), HttpMethod.POST, api1Entity, String.class); api1Raw = restTemplate.exchange(url, HttpMethod.POST, api1Entity, String.class);
} catch (HttpStatusCodeException ex) { } catch (HttpStatusCodeException ex) {
if (ex.getStatusCode() == HttpStatus.UNAUTHORIZED || ex.getStatusCode() == HttpStatus.FORBIDDEN) { 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<CreateAccountRequest> retryEntity = HttpEntity<CreateAccountRequest> retryEntity =
new HttpEntity<>(api1Req, buildHeaders(tokenService.refreshToken(reqDto.getBankId()))); 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 { } else {
String raw = ex.getResponseBodyAsString(); String raw = ex.getResponseBodyAsString();
if (raw != null && !raw.isBlank() && looksJson(raw)) { if (raw != null && !raw.isBlank() && looksJson(raw)) {
@@ -181,15 +190,19 @@ public class CbsIntegrationService {
// --- API-2 --- // --- API-2 ---
HttpEntity<CreateDepositAccountOkRequest> api2Entity = new HttpEntity<>(api2Req, headers); HttpEntity<CreateDepositAccountOkRequest> api2Entity = new HttpEntity<>(api2Req, headers);
ResponseEntity<String> api2Raw; ResponseEntity<String> api2Raw;
String url2 = accountOkUrl + "/" + reqDto.getBankId();
log.info("Calling 2nd API of Account Creation for bank {}. url={}", reqDto.getBankId(), url2);
try { try {
api2Raw = restTemplate.exchange(accountOkUrl + "/" + reqDto.getBankId(), HttpMethod.POST, api2Entity, String.class); api2Raw = restTemplate.exchange(url2, HttpMethod.POST, api2Entity, String.class);
} catch (HttpStatusCodeException ex) { } catch (HttpStatusCodeException ex) {
if (ex.getStatusCode() == HttpStatus.UNAUTHORIZED || ex.getStatusCode() == HttpStatus.FORBIDDEN) { 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<CreateDepositAccountOkRequest> retryEntity = HttpEntity<CreateDepositAccountOkRequest> retryEntity =
new HttpEntity<>(api2Req, buildHeaders(tokenService.refreshToken(reqDto.getBankId()))); 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 { } else {
String raw = ex.getResponseBodyAsString(); String raw = ex.getResponseBodyAsString();
if (raw != null && !raw.isBlank() && looksJson(raw)) { if (raw != null && !raw.isBlank() && looksJson(raw)) {
@@ -216,6 +229,7 @@ public class CbsIntegrationService {
// Success -> map final // Success -> map final
AccountCreationResponse finalResp = om.readValue(api2Str, AccountCreationResponse.class); AccountCreationResponse finalResp = om.readValue(api2Str, AccountCreationResponse.class);
log.info("Account Created..."); log.info("Account Created...");
log.info("Full Account Creation Response: {}", om.writeValueAsString(finalResp));
return finalResp; return finalResp;