Skip to content

Commit

Permalink
VRP consent initiation flow implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
kalpanakanagasabai committed Nov 28, 2023
1 parent beb78fa commit 2c5e3a6
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ public static ConsentManageRequestHandler getConsentManageRequestValidator(Strin
consentManageRequestHandler = new PaymentConsentRequestHandler();
break;
case ConsentExtensionConstants.VRP_CONSENT_PATH:
case ConsentExtensionConstants.VRP_RESPONSE_PROCESS_PATH:
consentManageRequestHandler = new VRPConsentRequestHandler();
break;
default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,6 @@ public static JSONObject validateVRPInitiationPayload(JSONObject initiation) {
validationResponse.put(ConsentExtensionConstants.IS_VALID, true);
return validationResponse;
}

}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -693,9 +693,9 @@ public static JSONObject validateVRPDebtorAccount(JSONObject debtorAccount) {
return validationResponse;
}

Object schemeName = debtorAccount.get(ConsentExtensionConstants.SCHEME_NAME);
String schemeName = debtorAccount.getAsString(ConsentExtensionConstants.SCHEME_NAME);

if (StringUtils.isEmpty(schemeName.toString())) {
if (StringUtils.isEmpty(schemeName)) {
log.error(ErrorConstants.MISSING_DEBTOR_ACC_SCHEME_NAME);
validationResponse.put(ConsentExtensionConstants.IS_VALID, false);
validationResponse.put(ConsentExtensionConstants.HTTP_CODE, ResponseStatus.BAD_REQUEST);
Expand All @@ -704,8 +704,8 @@ public static JSONObject validateVRPDebtorAccount(JSONObject debtorAccount) {
}
//Validate Debtor Account Scheme name
if (!(schemeName instanceof String) ||
ConsentManageUtil.isDebtorAccSchemeNameValid((String) schemeName) ||
!ConsentManageUtil.validateDebtorAccSchemeNameLength((String) schemeName)) {
ConsentManageUtil.isDebtorAccSchemeNameValid(schemeName) ||
!ConsentManageUtil.validateDebtorAccSchemeNameLength(schemeName)) {
log.error(ErrorConstants.INVALID_DEBTOR_ACC_SCHEME_NAME);
validationResponse.put(ConsentExtensionConstants.IS_VALID, false);
validationResponse.put(ConsentExtensionConstants.HTTP_CODE, ResponseStatus.BAD_REQUEST);
Expand Down Expand Up @@ -753,9 +753,9 @@ public static JSONObject validateVRPDebtorAccount(JSONObject debtorAccount) {

//Validate Debtor Account Name

Object debtorAcc = debtorAccount.get(ConsentExtensionConstants.NAME);
String debtorAcc = debtorAccount.getAsString(ConsentExtensionConstants.NAME);

if (debtorAcc == null || StringUtils.isEmpty(debtorAcc.toString())) {
if (debtorAcc == null || StringUtils.isEmpty(debtorAcc)) {
log.error(ErrorConstants.FIELD_MISSING);
validationResponse.put(ConsentExtensionConstants.IS_VALID, false);
validationResponse.put(ConsentExtensionConstants.HTTP_CODE, ResponseStatus.BAD_REQUEST);
Expand Down Expand Up @@ -801,11 +801,11 @@ public static JSONObject validateVRPCreditorAccount(JSONObject creditorAccount)
return validationResponse;
}

Object schemeName = creditorAccount.get(ConsentExtensionConstants.SCHEME_NAME);
String schemeName = creditorAccount.getAsString(ConsentExtensionConstants.SCHEME_NAME);
//Validate Creditor Account Scheme name
if (!(schemeName instanceof String) ||
ConsentManageUtil.isDebtorAccSchemeNameValid((String) schemeName) ||
!ConsentManageUtil.validateDebtorAccSchemeNameLength((String) schemeName)) {
ConsentManageUtil.isDebtorAccSchemeNameValid(schemeName) ||
!ConsentManageUtil.validateDebtorAccSchemeNameLength(schemeName)) {
log.error(ErrorConstants.INVALID_CREDITOR_ACC_SCHEME_NAME);
validationResponse.put(ConsentExtensionConstants.IS_VALID, false);
validationResponse.put(ConsentExtensionConstants.HTTP_CODE, ResponseStatus.BAD_REQUEST);
Expand Down Expand Up @@ -855,9 +855,9 @@ public static JSONObject validateVRPCreditorAccount(JSONObject creditorAccount)
}

//Validate Creditor Account Name
Object creditorAcc = creditorAccount.get(ConsentExtensionConstants.NAME);
String creditorAcc = creditorAccount.getAsString(ConsentExtensionConstants.NAME);

if (creditorAcc == null || StringUtils.isEmpty(creditorAcc.toString())) {
if (creditorAcc == null || StringUtils.isEmpty(creditorAcc)) {
log.error(ErrorConstants.FIELD_MISSING);
validationResponse.put(ConsentExtensionConstants.IS_VALID, false);
validationResponse.put(ConsentExtensionConstants.HTTP_CODE, ResponseStatus.BAD_REQUEST);
Expand All @@ -876,11 +876,11 @@ public static JSONObject validateVRPCreditorAccount(JSONObject creditorAccount)
}

//Validate Creditor Account Secondary Identification
Object creditorAccSecondaryIdentification = creditorAccount.get(ConsentExtensionConstants
String creditorAccSecondaryIdentification = creditorAccount.getAsString(ConsentExtensionConstants
.SECONDARY_IDENTIFICATION);

if (creditorAccSecondaryIdentification == null || StringUtils.isEmpty
(creditorAccSecondaryIdentification.toString())) {
(creditorAccSecondaryIdentification)) {
log.error(ErrorConstants.FIELD_MISSING);
validationResponse.put(ConsentExtensionConstants.IS_VALID, false);
validationResponse.put(ConsentExtensionConstants.HTTP_CODE, ResponseStatus.BAD_REQUEST);
Expand Down

0 comments on commit 2c5e3a6

Please sign in to comment.