Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PHEE-699] Parallel Payee-Multi-Tenancy-Support in channel Transfer API #163

Merged
merged 1 commit into from
Jul 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";

}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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!");
}
Expand All @@ -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();

Expand All @@ -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")) {
Expand Down
Loading