Skip to content

Commit

Permalink
Publishing additional variables (#66)
Browse files Browse the repository at this point in the history
* added extra variables for publishing

* added extra variables for publishing

* added extra variables for publishing

* added extra variables for publishing

* added variables for publish
  • Loading branch information
truthfool authored Apr 20, 2023
1 parent 8c6b765 commit 148803a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,7 @@ public void configure() {
String mpesaTxnId = paybillResponseDTO.getTransactionId();
String clientCorrelationId = mpesaTxnId;
reconciledStore.put(clientCorrelationId, reconciled);

GsmaTransfer gsmaTransfer = mpesaUtils.createGsmaTransferDTO(paybillResponseDTO);
GsmaTransfer gsmaTransfer = mpesaUtils.createGsmaTransferDTO(paybillResponseDTO,clientCorrelationId);
e.getIn().removeHeaders("*");
e.getIn().setHeader(ACCOUNT_HOLDING_INSTITUTION_ID, paybillResponseDTO.getAccountHoldingInstitutionId());
e.getIn().setHeader(AMS_NAME, paybillResponseDTO.getAmsName());
Expand Down Expand Up @@ -196,11 +195,11 @@ public void configure() {
variables.put(CHANNEL_REQUEST, obj.toString());
variables.put("amount", paybillConfirmationRequestDTO.getTransactionAmount());
variables.put("accountId", paybillConfirmationRequestDTO.getBillRefNo());
variables.put("originDate", paybillConfirmationRequestDTO.getTransactionTime());
variables.put("originDate", Long.parseLong(paybillConfirmationRequestDTO.getTransactionTime()));
variables.put("phoneNumber", paybillConfirmationRequestDTO.getMsisdn());
logger.info("Workflow transaction id : {}", transactionId);
variables.put("mpesaTransactionId", mpesaTransactionId);
variables.put(TRANSACTION_ID, transactionId);
logger.info("Workflow transaction id : {}", transactionId);

if (transactionId != null) {
zeebeClient.newPublishMessageCommand()
Expand Down
23 changes: 20 additions & 3 deletions src/main/java/org/mifos/connector/mpesa/utility/MpesaUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ enum ams {
roster;
}

public GsmaTransfer createGsmaTransferDTO(PaybillResponseDTO paybillResponseDTO) {
public GsmaTransfer createGsmaTransferDTO(PaybillResponseDTO paybillResponseDTO, String clientCorrelationId) {
GsmaTransfer gsmaTransfer = new GsmaTransfer();

List<CustomData> customData = setCustomData(paybillResponseDTO);
List<CustomData> customData = setCustomData(paybillResponseDTO,clientCorrelationId);
String currentDateTime = getCurrentDateTime();

Party payer = new Party();
Expand Down Expand Up @@ -80,7 +80,7 @@ public GsmaTransfer createGsmaTransferDTO(PaybillResponseDTO paybillResponseDTO)
return gsmaTransfer;
}

private List<CustomData> setCustomData(PaybillResponseDTO paybillResponseDTO) {
private List<CustomData> setCustomData(PaybillResponseDTO paybillResponseDTO, String clientCorrelationId) {
CustomData reconciled = new CustomData();
reconciled.setKey("partyLookupFailed");
reconciled.setValue(!paybillResponseDTO.isReconciled());
Expand All @@ -90,10 +90,27 @@ private List<CustomData> setCustomData(PaybillResponseDTO paybillResponseDTO) {
CustomData mpesaTxnId = new CustomData();
mpesaTxnId.setKey("mpesaTxnId");
mpesaTxnId.setValue(paybillResponseDTO.getTransactionId());
CustomData ams = new CustomData();
ams.setKey("ams");
ams.setValue(paybillResponseDTO.getAmsName());
CustomData tenantId=new CustomData();
tenantId.setKey("tenantId");
tenantId.setValue(paybillResponseDTO.getAccountHoldingInstitutionId());
CustomData clientCorrelation=new CustomData();
clientCorrelation.setKey("clientCorrelationId");
clientCorrelation.setValue(clientCorrelationId);
CustomData currency = new CustomData();
currency.setKey("currency");
currency.setValue(paybillResponseDTO.getCurrency());

List<CustomData> customData = new ArrayList<>();
customData.add(reconciled);
customData.add(confirmationReceived);
customData.add(mpesaTxnId);
customData.add(ams);
customData.add(tenantId);
customData.add(clientCorrelation);
customData.add(currency);
return customData;
}

Expand Down

0 comments on commit 148803a

Please sign in to comment.