Skip to content

Commit

Permalink
VRP initiation flow implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
kalpanakanagasabai committed Jan 11, 2024
1 parent dd2276f commit d29df11
Show file tree
Hide file tree
Showing 4 changed files with 470 additions and 256 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,13 @@ public class ErrorConstants {
public static final String PAYLOAD_FORMAT_ERROR_VALID_FROM_DATE = "Request Payload is not in correct JSON format" +
" for valid from date";
public static final String PAYLOAD_FORMAT_ERROR_PERIODIC_LIMITS = "Invalid periodic limits";
public static final String PAYLOAD_FORMAT_ERROR_PERIODIC_LIMITS_ALIGNMENT = "Value is empty or the value passed " +
"in is not a string";
public static final String PAYLOAD_FORMAT_ERROR_PERIODIC_LIMITS_PERIOD_TYPE = "Value of period type is empty or " +
"the value passed in is not a string";
public static final String PAYLOAD_FORMAT_ERROR_MAXIMUM_INDIVIDUAL_AMOUNT = "Invalid maximum individual amount";

public static final String MISSING_MAXIMUM_INDIVIDUAL_AMOUNT = "Missing parameter maximum individual amount";
public static final String PAYLOAD_FORMAT_ERROR_MAXIMUM_INDIVIDUAL_CURRENCY = "Invalid maximum individual amount" +
"currency";
public static final String PAYLOAD_FORMAT_ERROR_INITIATION = "Request Payload is not in correct JSON format" +
Expand Down Expand Up @@ -248,37 +253,16 @@ public class ErrorConstants {
public static final String FIELD_INVALID_DATE = "OB.Field.InvalidDate";
public static final String EXPIRED_DATE_ERROR = "The ExpirationDateTime value has to be a future date.";
// VRP error constants
public static final String MAXIMUM_INDIVIDUAL_AMOUNT_IS_MISSING = "Mandatory parameter MaximumIndividualAmount" +
" Amount is missing in the payload.";
public static final String MAXIMUM_INDIVIDUAL_AMOUNT_CURRENCY_IS_MISSING = "Mandatory parameter" +
"Currency in MaximumIndividualAmount is missing in the payload";
public static final String INVALID_AMOUNT = "Missing required parameter Amount";
public static final String INVALID_CURRENCY = "Missing required parameter Currency";
public static final String INVALID_PERIOD_ALIGNMENT = "Invalid value for period alignment in PeriodicLimits";
public static final String INVALID_PERIOD_TYPE = "Invalid value for period type in PeriodicLimits";
public static final String MISSING_PERIOD_TYPE = "Missing required parameter Period type";
public static final String INVALID_VALID_TO_DATE = "Valid to Date specified in the request is invalid";

// new error constants

public static final String INVALID_INITIATION_PAYLOAD = "Consent validation failed due to invalid" +
" initiation payload";
public static final String INVALID_PARAMETER = "Parameter passed in is null , " +
"empty or not a JSONObject";
public static final String INVALID_CLIENT_ID_MATCH = "Consent validation failed due to client ID mismatch";
public static final String INVALID_PARAMETER_DEBTOR_ACC = "Parameter passed in is null , " +
"empty or not a JSONObject in debtor account";
public static final String INVALID_PARAMETER_CREDITOR_ACC = "Parameter passed in is null , " +
"empty or not a JSONObject in debtor account";
public static final String INVALID_PARAMETER_AMOUNT = "Parameter passed in is null , " +
"empty or not a JSONObject in amount";
public static final String INVALID_PARAMETER_INITIATION = "Parameter passed in is null , " +
"empty or not a JSONObject in initiation";
public static final String INVALID_PARAMETER_CONTROL_PARAMETERS = "Parameter passed in is null , " +
"empty or not a JSONObject in control parameter";
public static final String INVALID_PARAMETER_MAXIMUM_INDIVIDUAL_AMOUNT = "Parameter passed in is null , " +
"empty or not a JSONObject in maximum individual amount";
public static final String INVALID_DATE_TIME_FORMAT = "Date and Time is not in correct JSON " +
"ISO-8601 date-time format";
public static final String MISSING_DATE_TIME_FORMAT = "The value is empty or the value is not a string";
public static final String MISSING_DATE_TIME = "Missing parameter";
public static final String INVALID_PARAMETER_PERIODIC_LIMITS = "Parameter passed in is null , " +
"empty or not a JSONArray";
public static final String MISSING_PERIOD_LIMITS = "Mandatory parameter " +
Expand All @@ -287,18 +271,14 @@ public class ErrorConstants {
public static final String PATH_VALID_TO_DATE = "Data.ControlParameters.ValidToDateTime";
public static final String PATH_VALID_FROM_DATE = "Data.ControlParameters.ValidFromDateTime";
public static final String PATH_MAXIMUM_INDIVIDUAL_AMOUNT = "Data.ControlParameters.MaximumIndividualAmount";
public static final String PATH_MAXIMUM_INDIVIDUAL_AMOUNT_AMOUNT = "Data.ControlParameters." +
"MaximumIndividualAmount.Amount";
public static final String PATH_MAXIMUM_INDIVIDUAL_AMOUNT_CURRENCY = "Data.ControlParameters." +
"MaximumIndividualAmount.Currency";

public static final String PATH_PERIOD_LIMIT = "Data.ControlParameters.PeriodicLimits";
public static final String PATH_PERIOD_LIMIT_AMOUNT = "Data.ControlParameters.PeriodicLimits.Amount";
public static final String PATH_PERIOD_LIMIT_CURRENCY = "Data.ControlParameters.PeriodicLimits.Currency";
public static final String PATH_PERIOD_TYPE = "Data.ControlParameters.PeriodicLimits.PeriodType";
public static final String PATH_PERIOD_ALIGNMENT = "Data.ControlParameters.PeriodLimits.PeriodAlignment";
public static final String PERIODIC_LIMIT_CURRENCY_IS_MISSING = "Mandatory parameter Currency in Periodic limits" +
" is missing in the payload";
public static final String MISSING_PERIOD_ALIGNMENT = "Missing periodic alignment";
public static final String PATH_PERIOD_ALIGNMENT = "Data.ControlParameters.PeriodicLimits.PeriodAlignment";

public static final String MISSING_PERIOD_ALIGNMENT = "Missing periodic alignment in periodic limits";

public static final String INVALID_PARAMETER_MESSAGE = "Parameter '%s' passed in is null, empty, or not a %s";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
* under the License.
*/
package com.wso2.openbanking.accelerator.consent.extensions.common;
;

/**
* Constant class for consent extension module.
Expand Down Expand Up @@ -173,12 +172,12 @@ public class ConsentExtensionConstants {
public static final String AUTH_TYPE_AUTHORIZATION = "authorization";
public static final String CONTROL_PARAMETERS = "ControlParameters";
public static final String MAXIMUM_INDIVIDUAL_AMOUNT = "MaximumIndividualAmount";
public static final String PERIOD_ALIGNMENT = "PeriodicAlignment";
public static final String PERIOD_ALIGNMENT = "PeriodAlignment";
public static final String PERIODIC_LIMITS = "PeriodicLimits";
public static final String PERIOD_TYPE = "PeriodType";
public static final String PERIOD_AMOUNT_LIMIT = "Amount";
public static final String CONSENT = "consent-periodicAlignment";
public static final String CALENDER = "calender-periodicAlignment";
public static final String CONSENT = "Consent";
public static final String CALENDAR = "Calendar";
public static final String DAY = "Day";
public static final String WEEK = "Week";
public static final String FORTNIGHT = "Fortnight";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ public class VRPConsentRequestHandler implements ConsentManageRequestHandler {
/**
* This method is responsible for processing a Variable Recurring Payment Consent Manage POST request.
* It validates the payment request, checks for the existence of an idempotency key.
*
* @param consentManageData Object
*/
@Override
public void handleConsentManagePost(ConsentManageData consentManageData) {
Expand Down Expand Up @@ -152,6 +154,7 @@ public void handleConsentManageDelete(ConsentManageData consentManageData) {
* - Sets the response status to Created.
*
* @param consentManageData Object containing request details, including client ID, request payload, headers.
* @param request Object
*/
public void handlePaymentPost(ConsentManageData consentManageData, Object request)
throws ConsentManagementException {
Expand Down Expand Up @@ -189,9 +192,10 @@ public void handlePaymentPost(ConsentManageData consentManageData, Object reques
get(ConsentExtensionConstants.AMOUNT).toString());
consentAttributes.put(ConsentExtensionConstants.PERIOD_ALIGNMENT, ((JSONObject) ((JSONArray)
(controlParameters).get(ConsentExtensionConstants.PERIODIC_LIMITS)).get(0))
//TODO: Improve the logic of storing the PERIODIC_LIMITS
.get(ConsentExtensionConstants.PERIOD_ALIGNMENT).toString());
consentAttributes.put(ConsentExtensionConstants.PERIOD_TYPE, ((JSONObject) ((JSONArray) (controlParameters)
//TODO: Improve the logic of storing the PERIODIC_LIMITS
consentAttributes.put(ConsentExtensionConstants.PERIOD_TYPE,
((JSONObject) ((JSONArray) (controlParameters)
.get(ConsentExtensionConstants.PERIODIC_LIMITS)).get(0)).get(ConsentExtensionConstants.PERIOD_TYPE)
.toString());
consentAttributes.put(ConsentExtensionConstants.PERIOD_AMOUNT_LIMIT, ((JSONObject)
Expand Down
Loading

0 comments on commit d29df11

Please sign in to comment.