diff --git a/src/main/java/org/mifos/connector/channel/api/definition/TransferApi.java b/src/main/java/org/mifos/connector/channel/api/definition/TransferApi.java index f01040ca..4f3e9332 100644 --- a/src/main/java/org/mifos/connector/channel/api/definition/TransferApi.java +++ b/src/main/java/org/mifos/connector/channel/api/definition/TransferApi.java @@ -2,6 +2,7 @@ import static org.mifos.connector.channel.camel.config.CamelProperties.BATCH_ID_HEADER; import static org.mifos.connector.channel.camel.config.CamelProperties.CLIENTCORRELATIONID; +import static org.mifos.connector.channel.camel.config.CamelProperties.PAYEE_DFSP_ID; import static org.mifos.connector.channel.camel.config.CamelProperties.REGISTERING_INSTITUTION_ID; import com.fasterxml.jackson.core.JsonProcessingException; @@ -21,6 +22,7 @@ GsmaP2PResponseDto transfer(@RequestHeader(value = "Platform-TenantId") String t @RequestHeader(value = BATCH_ID_HEADER, required = false) String batchId, @RequestHeader(value = CLIENTCORRELATIONID, required = false) String correlationId, @RequestHeader(value = REGISTERING_INSTITUTION_ID, required = false) String registeringInstitutionId, + @RequestHeader(value = PAYEE_DFSP_ID, required = false) String payeeDfspId, @RequestBody TransactionChannelRequestDTO requestBody) throws JsonProcessingException; @GetMapping("/channel/transfer/{transactionId}") diff --git a/src/main/java/org/mifos/connector/channel/api/implementation/TransferApiController.java b/src/main/java/org/mifos/connector/channel/api/implementation/TransferApiController.java index 906b9080..d31a1f28 100644 --- a/src/main/java/org/mifos/connector/channel/api/implementation/TransferApiController.java +++ b/src/main/java/org/mifos/connector/channel/api/implementation/TransferApiController.java @@ -2,6 +2,7 @@ import static org.mifos.connector.channel.camel.config.CamelProperties.BATCH_ID; import static org.mifos.connector.channel.camel.config.CamelProperties.CLIENTCORRELATIONID; +import static org.mifos.connector.channel.camel.config.CamelProperties.PAYEE_DFSP_ID; import static org.mifos.connector.channel.camel.config.CamelProperties.REGISTERING_INSTITUTION_ID; import com.fasterxml.jackson.core.JsonProcessingException; @@ -34,9 +35,10 @@ public class TransferApiController implements TransferApi { @Override public GsmaP2PResponseDto transfer(String tenant, String batchId, String correlationId, String registeringInstitutionId, - TransactionChannelRequestDTO requestBody) throws JsonProcessingException { + String payeeDfspId, TransactionChannelRequestDTO requestBody) throws JsonProcessingException { Headers headers = new Headers.HeaderBuilder().addHeader("Platform-TenantId", tenant).addHeader(BATCH_ID, batchId) - .addHeader(CLIENTCORRELATIONID, correlationId).addHeader(REGISTERING_INSTITUTION_ID, registeringInstitutionId).build(); + .addHeader(CLIENTCORRELATIONID, correlationId).addHeader(REGISTERING_INSTITUTION_ID, registeringInstitutionId) + .addHeader(PAYEE_DFSP_ID, payeeDfspId).build(); Exchange exchange = SpringWrapperUtil.getDefaultWrappedExchange(producerTemplate.getCamelContext(), headers, objectMapper.writeValueAsString(requestBody)); logger.info("Client correlation id: " + correlationId); diff --git a/src/main/java/org/mifos/connector/channel/camel/config/CamelProperties.java b/src/main/java/org/mifos/connector/channel/camel/config/CamelProperties.java index d5ff6567..544bebb7 100644 --- a/src/main/java/org/mifos/connector/channel/camel/config/CamelProperties.java +++ b/src/main/java/org/mifos/connector/channel/camel/config/CamelProperties.java @@ -13,5 +13,6 @@ private CamelProperties() {} public static final String PAYMENT_SCHEME_HEADER = "X-Payment-Scheme"; public static final String REGISTERING_INSTITUTION_ID = "X-Registering-Institution-ID"; public static final String PARTY_LOOKUP_FSP_ID = "partyLookupFspId"; + public static final String PAYEE_DFSP_ID = "X-PayeeDFSP-ID"; } diff --git a/src/main/java/org/mifos/connector/channel/camel/routes/ChannelRouteBuilder.java b/src/main/java/org/mifos/connector/channel/camel/routes/ChannelRouteBuilder.java index f535ccc1..dd583f24 100644 --- a/src/main/java/org/mifos/connector/channel/camel/routes/ChannelRouteBuilder.java +++ b/src/main/java/org/mifos/connector/channel/camel/routes/ChannelRouteBuilder.java @@ -6,6 +6,7 @@ import static org.mifos.connector.channel.camel.config.CamelProperties.AUTH_TYPE; import static org.mifos.connector.channel.camel.config.CamelProperties.BATCH_ID; import static org.mifos.connector.channel.camel.config.CamelProperties.CLIENTCORRELATIONID; +import static org.mifos.connector.channel.camel.config.CamelProperties.PAYEE_DFSP_ID; import static org.mifos.connector.channel.camel.config.CamelProperties.PAYMENT_SCHEME_HEADER; import static org.mifos.connector.channel.camel.config.CamelProperties.REGISTERING_INSTITUTION_ID; import static org.mifos.connector.channel.zeebe.ZeebeMessages.OPERATOR_MANUAL_RECOVERY; @@ -311,9 +312,10 @@ private void transferRoutes() { extraVariables.put(BATCH_ID, batchIdHeader); String tenantId = exchange.getIn().getHeader("Platform-TenantId", String.class); + String payeeDfspId = exchange.getIn().getHeader(PAYEE_DFSP_ID, String.class); String registeringInstitutionId = exchange.getIn().getHeader("X-Registering-Institution-ID", String.class); String clientCorrelationId = exchange.getIn().getHeader("X-CorrelationID", String.class); - logger.info("## CHANNEL Client Correlation Id: " + clientCorrelationId); + logger.info("## CHANNEL Client Correlation Id: {}", clientCorrelationId); if (tenantId == null || !dfspIds.contains(tenantId)) { throw new RuntimeException("Requested tenant " + tenantId + " not configured in the connector!"); } @@ -326,7 +328,12 @@ private void transferRoutes() { transactionType.setInitiatorType(CONSUMER); transactionType.setScenario(TRANSFER); channelRequest.setTransactionType(transactionType); - channelRequest.getPayer().getPartyIdInfo().setFspId(destinationDfspId); + channelRequest.getPayer().getPartyIdInfo().setFspId(tenantId); + if (payeeDfspId == null || payeeDfspId.isBlank()) { + channelRequest.getPayee().getPartyIdInfo().setFspId(destinationDfspId); + } else { + channelRequest.getPayee().getPartyIdInfo().setFspId(payeeDfspId); + } String customDataString = String.valueOf(channelRequest.getCustomData()); String currency = channelRequest.getAmount().getCurrency(); @@ -339,6 +346,7 @@ private void transferRoutes() { new FspMoneyData(channelRequest.getAmount().getAmountDecimal(), channelRequest.getAmount().getCurrency())); extraVariables.put("clientCorrelationId", clientCorrelationId); extraVariables.put("initiatorFspId", channelRequest.getPayer().getPartyIdInfo().getFspId()); + extraVariables.put("destinationFspId", channelRequest.getPayee().getPartyIdInfo().getFspId()); String tenantSpecificBpmn; String bpmn = getWorkflowForTenant(tenantId, "payment-transfer"); if (channelRequest.getPayer().getPartyIdInfo().getPartyIdentifier().startsWith("6666")) {