Skip to content

Commit ca584d7

Browse files
authored
added response object necessary fields (#23)
1 parent 6aaa963 commit ca584d7

File tree

1 file changed

+24
-9
lines changed

1 file changed

+24
-9
lines changed

src/main/java/org/mifos/connector/ams/pesacore/camel/route/PesaRouteBuilder.java

+24-9
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ public void configure() {
6262
.setBody(e -> {
6363
String body=e.getIn().getBody(String.class);
6464
logger.debug("Body : {}",body);
65-
e.setProperty("dfspId",e.getProperty("dfspId"));
65+
String accountHoldingInstitutionId= String.valueOf(e.getIn().getHeader("accountHoldingInstitutionId"));
66+
e.setProperty("accountHoldingInstitutionId",accountHoldingInstitutionId);
6667
return body;
6768
})
6869
.to("direct:transfer-validation-base")
@@ -73,8 +74,12 @@ public void configure() {
7374
// Building the response
7475
JSONObject responseObject=new JSONObject();
7576
responseObject.put("reconciled", e.getProperty(PARTY_LOOKUP_FAILED).equals(false));
76-
responseObject.put("AMS", "roster");
77-
responseObject.put("transaction_id", transactionId);
77+
responseObject.put("amsName", "roster");
78+
responseObject.put("accountHoldingInstitutionId", e.getProperty("accountHoldingInstitutionId"));
79+
responseObject.put(TRANSACTION_ID, e.getProperty(TRANSACTION_ID));
80+
responseObject.put("amount", e.getProperty("amount"));
81+
responseObject.put("currency", e.getProperty("currency"));
82+
responseObject.put("msisdn", e.getProperty("msisdn"));
7883
logger.debug("response object "+responseObject);
7984
e.getIn().setBody(responseObject.toString());
8085
});
@@ -89,15 +94,23 @@ public void configure() {
8994
.process(exchange -> {
9095
// processing success case
9196
exchange.setProperty(PARTY_LOOKUP_FAILED, false);
92-
exchange.setProperty("dfspId",exchange.getProperty("dfspId"));
97+
exchange.setProperty("accountHoldingInstitutionId", exchange.getProperty("accountHoldingInstitutionId"));
98+
exchange.setProperty(TRANSACTION_ID, exchange.getProperty(TRANSACTION_ID));
99+
exchange.setProperty("amount", exchange.getProperty("amount"));
100+
exchange.setProperty("currency", exchange.getProperty("currency"));
101+
exchange.setProperty("msisdn", exchange.getProperty("msisdn"));
93102
logger.debug("Pesacore Validation Success");
94103
})
95104
.otherwise()
96105
.log(LoggingLevel.ERROR, "Validation unsuccessful")
97106
.process(exchange -> {
98107
// processing unsuccessful case
99108
exchange.setProperty(PARTY_LOOKUP_FAILED, true);
100-
exchange.setProperty("dfspId",exchange.getProperty("dfspId"));
109+
exchange.setProperty("accountHoldingInstitutionId", exchange.getProperty("accountHoldingInstitutionId"));
110+
exchange.setProperty(TRANSACTION_ID, exchange.getProperty(TRANSACTION_ID));
111+
exchange.setProperty("amount", exchange.getProperty("amount"));
112+
exchange.setProperty("currency", exchange.getProperty("currency"));
113+
exchange.setProperty("msisdn", exchange.getProperty("msisdn"));
101114
logger.debug("Pesacore Validation Failure");
102115
});
103116

@@ -122,10 +135,12 @@ public void configure() {
122135
JSONObject paybillRequest = new JSONObject(exchange.getIn().getBody(String.class));
123136
PesacoreRequestDTO pesacoreRequestDTO = PesacoreUtils.convertPaybillPayloadToAmsPesacorePayload(paybillRequest);
124137

125-
String transactionId = pesacoreRequestDTO.getRemoteTransactionId();
126-
log.info(pesacoreRequestDTO.toString());
127-
exchange.setProperty(TRANSACTION_ID, transactionId);
128-
exchange.setProperty("dfspId",exchange.getProperty("dfspId"));
138+
log.debug(pesacoreRequestDTO.toString());
139+
exchange.setProperty(TRANSACTION_ID, pesacoreRequestDTO.getRemoteTransactionId());
140+
exchange.setProperty("amount", pesacoreRequestDTO.getAmount());
141+
exchange.setProperty("currency", pesacoreRequestDTO.getCurrency());
142+
exchange.setProperty("msisdn", pesacoreRequestDTO.getPhoneNumber());
143+
exchange.setProperty("accountHoldingInstitutionId", exchange.getProperty("accountHoldingInstitutionId"));
129144
logger.debug("Validation request DTO: \n\n\n" + pesacoreRequestDTO);
130145
return pesacoreRequestDTO;
131146
}

0 commit comments

Comments
 (0)