|
1 | | -//package org.mifos.processor.bulk.kafka; |
2 | | -// |
3 | | -//import static org.mifos.connector.common.mojaloop.type.InitiatorType.CONSUMER; |
4 | | -//import static org.mifos.connector.common.mojaloop.type.Scenario.TRANSFER; |
5 | | -//import static org.mifos.connector.common.mojaloop.type.TransactionRole.PAYER; |
6 | | -//import static org.mifos.processor.bulk.zeebe.ZeebeVariables.BATCH_ID; |
7 | | -//import static org.mifos.processor.bulk.zeebe.ZeebeVariables.GSMA_CHANNEL_REQUEST; |
8 | | -//import static org.mifos.processor.bulk.zeebe.ZeebeVariables.INITIATOR_FSPID; |
9 | | -//import static org.mifos.processor.bulk.zeebe.ZeebeVariables.IS_RTP_REQUEST; |
10 | | -//import static org.mifos.processor.bulk.zeebe.ZeebeVariables.PARTY_ID; |
11 | | -//import static org.mifos.processor.bulk.zeebe.ZeebeVariables.PARTY_ID_TYPE; |
12 | | -//import static org.mifos.processor.bulk.zeebe.ZeebeVariables.PARTY_LOOKUP_FSPID; |
13 | | -//import static org.mifos.processor.bulk.zeebe.ZeebeVariables.TENANT_ID; |
14 | | -//import static org.mifos.processor.bulk.zeebe.ZeebeVariables.TRANSACTION_TYPE; |
15 | | -// |
16 | | -//import com.fasterxml.jackson.core.JsonProcessingException; |
17 | | -//import com.fasterxml.jackson.databind.ObjectMapper; |
18 | | -//import java.util.HashMap; |
19 | | -//import java.util.Map; |
20 | | -//import lombok.extern.slf4j.Slf4j; |
21 | | -//import org.mifos.connector.common.channel.dto.TransactionChannelRequestDTO; |
22 | | -//import org.mifos.connector.common.gsma.dto.GSMATransaction; |
23 | | -//import org.mifos.connector.common.gsma.dto.GsmaParty; |
24 | | -//import org.mifos.connector.common.mojaloop.dto.MoneyData; |
25 | | -//import org.mifos.connector.common.mojaloop.dto.Party; |
26 | | -//import org.mifos.connector.common.mojaloop.dto.PartyIdInfo; |
27 | | -//import org.mifos.connector.common.mojaloop.dto.TransactionType; |
28 | | -//import org.mifos.connector.common.mojaloop.type.IdentifierType; |
29 | | -//import org.mifos.processor.bulk.schema.TransactionOlder; |
30 | | -//import org.mifos.processor.bulk.zeebe.ZeebeProcessStarter; |
31 | | -//import org.springframework.beans.factory.annotation.Autowired; |
32 | | -//import org.springframework.beans.factory.annotation.Value; |
33 | | -//import org.springframework.kafka.annotation.KafkaListener; |
34 | | -//import org.springframework.stereotype.Service; |
35 | | -// |
36 | | -//@Service |
37 | | -//@Slf4j |
38 | | -//public class Consumers { |
39 | | -// |
40 | | -// @Value("${bpmn.flows.international-remittance-payer}") |
41 | | -// private String internationalRemittancePayer; |
42 | | -// |
43 | | -// @Autowired |
44 | | -// private ObjectMapper objectMapper; |
45 | | -// |
46 | | -// @Autowired |
47 | | -// private ZeebeProcessStarter zeebeProcessStarter; |
48 | | -// |
49 | | -// @KafkaListener(topics = "${kafka.topic.gsma.name}", groupId = "group_id") |
50 | | -// public void listenTopicGsma(String message) throws JsonProcessingException { |
51 | | -// log.debug("Received Message in topic GSMA and group group_id: {}", message); |
52 | | -// TransactionOlder transaction = objectMapper.readValue(message, TransactionOlder.class); |
53 | | -// String tenantId = "ibank-usa"; |
54 | | -// |
55 | | -// GSMATransaction gsmaChannelRequest = new GSMATransaction(); |
56 | | -// gsmaChannelRequest.setAmount(transaction.getAmount()); |
57 | | -// gsmaChannelRequest.setCurrency(transaction.getCurrency()); |
58 | | -// gsmaChannelRequest.setRequestingLei("ibank-usa"); |
59 | | -// gsmaChannelRequest.setReceivingLei("ibank-india"); |
60 | | -// GsmaParty creditParty = new GsmaParty(); |
61 | | -// creditParty.setKey("msisdn"); |
62 | | -// creditParty.setValue(transaction.getAccountNumber()); |
63 | | -// GsmaParty debitParty = new GsmaParty(); |
64 | | -// debitParty.setKey("msisdn"); |
65 | | -// debitParty.setValue(transaction.getAccountNumber()); |
66 | | -// gsmaChannelRequest.setCreditParty(new GsmaParty[] { creditParty }); |
67 | | -// gsmaChannelRequest.setDebitParty(new GsmaParty[] { debitParty }); |
68 | | -// // gsmaChannelRequest.setInternationalTransferInformation().setReceivingAmount(gsmaChannelRequest.getAmount()); |
69 | | -// |
70 | | -// TransactionChannelRequestDTO channelRequest = new TransactionChannelRequestDTO(); // Fineract Object |
71 | | -// Party payee = new Party(new PartyIdInfo(IdentifierType.MSISDN, transaction.getAccountNumber())); |
72 | | -// Party payer = new Party(new PartyIdInfo(IdentifierType.MSISDN, "7543010")); |
73 | | -// |
74 | | -// MoneyData moneyData = new MoneyData(); |
75 | | -// moneyData.setAmount(transaction.getAmount()); |
76 | | -// moneyData.setCurrency(transaction.getCurrency()); |
77 | | -// |
78 | | -// channelRequest.setPayer(payer); |
79 | | -// channelRequest.setPayee(payee); |
80 | | -// channelRequest.setAmount(moneyData); |
81 | | -// |
82 | | -// TransactionType transactionType = new TransactionType(); |
83 | | -// transactionType.setInitiator(PAYER); |
84 | | -// transactionType.setInitiatorType(CONSUMER); |
85 | | -// transactionType.setScenario(TRANSFER); |
86 | | -// |
87 | | -// Map<String, Object> extraVariables = new HashMap<>(); |
88 | | -// extraVariables.put(IS_RTP_REQUEST, false); |
89 | | -// extraVariables.put(TRANSACTION_TYPE, "inttransfer"); |
90 | | -// extraVariables.put(TENANT_ID, tenantId); |
91 | | -// |
92 | | -// extraVariables.put(BATCH_ID, transaction.getBatchId()); |
93 | | -// |
94 | | -// String tenantSpecificBpmn = internationalRemittancePayer.replace("{dfspid}", tenantId); |
95 | | -// channelRequest.setTransactionType(transactionType); |
96 | | -// |
97 | | -// PartyIdInfo requestedParty = (boolean) extraVariables.get(IS_RTP_REQUEST) ? channelRequest.getPayer().getPartyIdInfo() |
98 | | -// : channelRequest.getPayee().getPartyIdInfo(); |
99 | | -// extraVariables.put(PARTY_ID_TYPE, requestedParty.getPartyIdType()); |
100 | | -// extraVariables.put(PARTY_ID, requestedParty.getPartyIdentifier()); |
101 | | -// |
102 | | -// extraVariables.put(GSMA_CHANNEL_REQUEST, objectMapper.writeValueAsString(gsmaChannelRequest)); |
103 | | -// extraVariables.put(PARTY_LOOKUP_FSPID, gsmaChannelRequest.getReceivingLei()); |
104 | | -// extraVariables.put(INITIATOR_FSPID, gsmaChannelRequest.getRequestingLei()); |
105 | | -// |
106 | | -// String transactionId = zeebeProcessStarter.startZeebeWorkflow(tenantSpecificBpmn, objectMapper.writeValueAsString(channelRequest), |
107 | | -// extraVariables); |
108 | | -// |
109 | | -// log.debug("GSMA Transaction Started with:{} ", transactionId); |
110 | | -// } |
111 | | -// |
112 | | -// @KafkaListener(topics = "${kafka.topic.slcb.name}", groupId = "group_id") |
113 | | -// public void listenTopicSlcb(String message) { |
114 | | -// log.debug("Received Message in topic SLCB and group group_id:{} ", message); |
115 | | -// } |
116 | | -//} |
| 1 | +package org.mifos.processor.bulk.kafka; |
| 2 | + |
| 3 | +import static org.mifos.connector.common.mojaloop.type.InitiatorType.CONSUMER; |
| 4 | +import static org.mifos.connector.common.mojaloop.type.Scenario.TRANSFER; |
| 5 | +import static org.mifos.connector.common.mojaloop.type.TransactionRole.PAYER; |
| 6 | +import static org.mifos.processor.bulk.zeebe.ZeebeVariables.BATCH_ID; |
| 7 | +import static org.mifos.processor.bulk.zeebe.ZeebeVariables.GSMA_CHANNEL_REQUEST; |
| 8 | +import static org.mifos.processor.bulk.zeebe.ZeebeVariables.INITIATOR_FSPID; |
| 9 | +import static org.mifos.processor.bulk.zeebe.ZeebeVariables.IS_RTP_REQUEST; |
| 10 | +import static org.mifos.processor.bulk.zeebe.ZeebeVariables.PARTY_ID; |
| 11 | +import static org.mifos.processor.bulk.zeebe.ZeebeVariables.PARTY_ID_TYPE; |
| 12 | +import static org.mifos.processor.bulk.zeebe.ZeebeVariables.PARTY_LOOKUP_FSPID; |
| 13 | +import static org.mifos.processor.bulk.zeebe.ZeebeVariables.TENANT_ID; |
| 14 | +import static org.mifos.processor.bulk.zeebe.ZeebeVariables.TRANSACTION_TYPE; |
| 15 | + |
| 16 | +import com.fasterxml.jackson.core.JsonProcessingException; |
| 17 | +import com.fasterxml.jackson.databind.ObjectMapper; |
| 18 | +import java.util.HashMap; |
| 19 | +import java.util.Map; |
| 20 | +import lombok.extern.slf4j.Slf4j; |
| 21 | +import org.mifos.connector.common.channel.dto.TransactionChannelRequestDTO; |
| 22 | +import org.mifos.connector.common.gsma.dto.GSMATransaction; |
| 23 | +import org.mifos.connector.common.gsma.dto.GsmaParty; |
| 24 | +import org.mifos.connector.common.mojaloop.dto.MoneyData; |
| 25 | +import org.mifos.connector.common.mojaloop.dto.Party; |
| 26 | +import org.mifos.connector.common.mojaloop.dto.PartyIdInfo; |
| 27 | +import org.mifos.connector.common.mojaloop.dto.TransactionType; |
| 28 | +import org.mifos.connector.common.mojaloop.type.IdentifierType; |
| 29 | +import org.mifos.processor.bulk.schema.TransactionOlder; |
| 30 | +import org.mifos.processor.bulk.zeebe.ZeebeProcessStarter; |
| 31 | +import org.springframework.beans.factory.annotation.Autowired; |
| 32 | +import org.springframework.beans.factory.annotation.Value; |
| 33 | +import org.springframework.kafka.annotation.KafkaListener; |
| 34 | +import org.springframework.stereotype.Service; |
| 35 | + |
| 36 | +@Service |
| 37 | +@Slf4j |
| 38 | +public class Consumers { |
| 39 | + |
| 40 | + @Value("${bpmn.flows.international-remittance-payer}") |
| 41 | + private String internationalRemittancePayer; |
| 42 | + |
| 43 | + @Autowired |
| 44 | + private ObjectMapper objectMapper; |
| 45 | + |
| 46 | + @Autowired |
| 47 | + private ZeebeProcessStarter zeebeProcessStarter; |
| 48 | + |
| 49 | + @KafkaListener(topics = "${kafka.topic.gsma.name}", groupId = "group_id") |
| 50 | + public void listenTopicGsma(String message) throws JsonProcessingException { |
| 51 | + log.debug("Received Message in topic GSMA and group group_id: {}", message); |
| 52 | + TransactionOlder transaction = objectMapper.readValue(message, TransactionOlder.class); |
| 53 | + String tenantId = "ibank-usa"; |
| 54 | + |
| 55 | + GSMATransaction gsmaChannelRequest = new GSMATransaction(); |
| 56 | + gsmaChannelRequest.setAmount(transaction.getAmount()); |
| 57 | + gsmaChannelRequest.setCurrency(transaction.getCurrency()); |
| 58 | + gsmaChannelRequest.setRequestingLei("ibank-usa"); |
| 59 | + gsmaChannelRequest.setReceivingLei("ibank-india"); |
| 60 | + GsmaParty creditParty = new GsmaParty(); |
| 61 | + creditParty.setKey("msisdn"); |
| 62 | + creditParty.setValue(transaction.getAccountNumber()); |
| 63 | + GsmaParty debitParty = new GsmaParty(); |
| 64 | + debitParty.setKey("msisdn"); |
| 65 | + debitParty.setValue(transaction.getAccountNumber()); |
| 66 | + gsmaChannelRequest.setCreditParty(new GsmaParty[] { creditParty }); |
| 67 | + gsmaChannelRequest.setDebitParty(new GsmaParty[] { debitParty }); |
| 68 | + // gsmaChannelRequest.setInternationalTransferInformation().setReceivingAmount(gsmaChannelRequest.getAmount()); |
| 69 | + |
| 70 | + TransactionChannelRequestDTO channelRequest = new TransactionChannelRequestDTO(); // Fineract Object |
| 71 | + Party payee = new Party(new PartyIdInfo(IdentifierType.MSISDN, transaction.getAccountNumber())); |
| 72 | + Party payer = new Party(new PartyIdInfo(IdentifierType.MSISDN, "7543010")); |
| 73 | + |
| 74 | + MoneyData moneyData = new MoneyData(); |
| 75 | + moneyData.setAmount(transaction.getAmount()); |
| 76 | + moneyData.setCurrency(transaction.getCurrency()); |
| 77 | + |
| 78 | + channelRequest.setPayer(payer); |
| 79 | + channelRequest.setPayee(payee); |
| 80 | + channelRequest.setAmount(moneyData); |
| 81 | + |
| 82 | + TransactionType transactionType = new TransactionType(); |
| 83 | + transactionType.setInitiator(PAYER); |
| 84 | + transactionType.setInitiatorType(CONSUMER); |
| 85 | + transactionType.setScenario(TRANSFER); |
| 86 | + |
| 87 | + Map<String, Object> extraVariables = new HashMap<>(); |
| 88 | + extraVariables.put(IS_RTP_REQUEST, false); |
| 89 | + extraVariables.put(TRANSACTION_TYPE, "inttransfer"); |
| 90 | + extraVariables.put(TENANT_ID, tenantId); |
| 91 | + |
| 92 | + extraVariables.put(BATCH_ID, transaction.getBatchId()); |
| 93 | + |
| 94 | + String tenantSpecificBpmn = internationalRemittancePayer.replace("{dfspid}", tenantId); |
| 95 | + channelRequest.setTransactionType(transactionType); |
| 96 | + |
| 97 | + PartyIdInfo requestedParty = (boolean) extraVariables.get(IS_RTP_REQUEST) ? channelRequest.getPayer().getPartyIdInfo() |
| 98 | + : channelRequest.getPayee().getPartyIdInfo(); |
| 99 | + extraVariables.put(PARTY_ID_TYPE, requestedParty.getPartyIdType()); |
| 100 | + extraVariables.put(PARTY_ID, requestedParty.getPartyIdentifier()); |
| 101 | + |
| 102 | + extraVariables.put(GSMA_CHANNEL_REQUEST, objectMapper.writeValueAsString(gsmaChannelRequest)); |
| 103 | + extraVariables.put(PARTY_LOOKUP_FSPID, gsmaChannelRequest.getReceivingLei()); |
| 104 | + extraVariables.put(INITIATOR_FSPID, gsmaChannelRequest.getRequestingLei()); |
| 105 | + |
| 106 | + String transactionId = zeebeProcessStarter.startZeebeWorkflow(tenantSpecificBpmn, objectMapper.writeValueAsString(channelRequest), |
| 107 | + extraVariables); |
| 108 | + |
| 109 | + log.debug("GSMA Transaction Started with:{} ", transactionId); |
| 110 | + } |
| 111 | + |
| 112 | + @KafkaListener(topics = "${kafka.topic.slcb.name}", groupId = "group_id") |
| 113 | + public void listenTopicSlcb(String message) { |
| 114 | + log.debug("Received Message in topic SLCB and group group_id:{} ", message); |
| 115 | + } |
| 116 | +} |
0 commit comments