package com.dat.digipay.digiposgateway.backoffice.gateway; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.http.HttpEntity; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Controller; import org.springframework.util.LinkedMultiValueMap; import org.springframework.util.MultiValueMap; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.client.RestTemplate; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.dat.digipay.digiposgateway.backoffice.domain.*; import com.dat.digipay.digiposgateway.backoffice.repository.*; import com.dat.digipay.digiposgateway.backoffice.repository.search.*; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.FileInputStream; import java.io.OutputStream; import java.time.Instant; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Date; import java.util.Map; //import javax.transaction.Transactional; import org.springframework.stereotype.Component; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; //import java.io.*; import org.jpos.iso.*; import org.jpos.util.*; import org.jpos.iso.channel.*; import org.jpos.iso.packager.*; /** * A class to test interactions with the MySQL database using the UserDao class. * * @author Philippe MONSAN */ @Service @Transactional public class ServiceUtils { static Logger logger = LoggerFactory.getLogger(ServiceUtils.class); public Message createMessage(DpService dpService, MessageType messageType, String transactionid, Device device, Meansofpayment meansofpayment, Beneficiary beneficiary, double amount, String isoMessage, SecurityEndpoint securityEndpoint){ MessageStatus messageStatus = messageStatusDao.getOne(1L); String comment = ""; Message message = new Message(); message.setNumber(transactionid); message.setClientTransactionNumber(transactionid); message.setRegistrationDate(Instant.now()); message.setIsoMessage(isoMessage); message.setAmount(amount); //message.setFeesSupported(feesSupported); //message.setChangeFeesSupported(changeFeesSupported); //message.setTransactionFees(transactionFees); //message.setTransactionChangeFees(transactionChangeFees); message.setActive(true); message.setMessageDate(Instant.now()); message.setComment(comment); //message.setClientApplication(clientApplication); message.setDevice(device); message.setMessageStatus(messageStatus); message.setMeansofpayment(meansofPayment); message.setBeneficiary(beneficiary); message.setMessageType(messageType); message.setSecurityEndpoint(securityEndpoint); //message.setMessageEndpoint(messageEndpoint); message.setDpService(dpService); message = messageDao.save(message); return message; } /* entity Message(t_message) { number String, clientTransactionNumber String maxlength(20), otpNotification OtpNotification required, otp String, otpChecked Boolean required, fingerprintChecked Boolean required, faceChecked Boolean required, voiceChecked Boolean required, registrationDate Instant, messageDate Instant, otpCheckedDate Instant, isoMessage String, amount Double, feesSupported Boolean required, changeFeesSupported Boolean required, transactionFees Double min(0), transactionChangeFees Double min(0), active Boolean required, modificationDate Instant, sendDate Instant, comment String maxlength(255) } relationship ManyToOne { Message{clientApplication} to ClientApplication, Message{device} to Device, Message{messageStatus} to MessageStatus, Message{meansofpayment} to Meansofpayment, Message{beneficiary} to Beneficiary, Message{messageType} to MessageType, Message{securityEndpoint} to SecurityEndpoint, Message{messageEndpoint} to MessageEndpoint, Message{service} to DpService }*/ public Message createMessage(String service, String messageTypeLabel, String transactionid, String terminalId, String merchantId, String issuerCode, String meansofpaymentType, String meansofpayment, String beneficiaryType, String beneficiaryAccount, double amount, String isoMessage, SecurityEndpoint securityEndpoint){ MeansofpaymentType meansofPaymentType = meansofpaymentTypeDao.findByLabel(meansofpaymentType); DpService dpService = DpServiceDao.findByCode(service); Device device = deviceDao.findByCode(terminalId); BeneficiaryType benefType = beneficiaryTypeDao.findByLabel(beneficiaryType); MessageStatus messageStatus = messageStatusDao.getOne(1L); Meansofpayment meansofPayment = new Meansofpayment(); meansofPayment.setActive(true); meansofPayment.setMeansofpaymentType(meansofPaymentType); if ("Cash".equals(meansofpaymentType)){ } else if ("MoMo".equals(meansofpaymentType)){ meansofPayment.setMomoAccountNumber(meansofpayment); } else if ("BankAccount".equals(meansofpaymentType)){ //meansofPayment.setBaccBankCode(baccBankCode); //meansofPayment.setBaccAccountNumber(baccAccountNumber); //meansofPayment.setBaccRibKey(baccRibKey); } else if ("CB".equals(meansofpaymentType)){ //meansofPayment.setCardPan(cardPan); //meansofPayment.cardCvv2(cardCvv2); //meansofPayment.setCardValidityDate(cardValidityDate); } /*else{ return null; }*/ Beneficiary beneficiary = new Beneficiary(); beneficiary.setBeneficiaryType(benefType); if ("Cash".equals(beneficiaryType)){ } else if ("MoMo".equals(beneficiaryType)){ beneficiary.setMobileMoneyAccountNumber(beneficiaryAccount); } else if ("BankAccount".equals(beneficiaryType)){ //beneficiary.setBaccAccountNumber(baccAccountNumber); //beneficiary.setBaccBankCode(baccBankCode); //beneficiary.setBaccRibKey(baccRibKey); } else if ("CB".equals(beneficiaryType)){ //beneficiary.setCardPan(cardPan); //beneficiary.cardCvv2(cardCvv2); //beneficiary.setCardValidityDate(cardValidityDate); } Message message = new Message(); message.setNumber(transactionid); message.setActive(true); message.setAmount(amount); message.setMeansofpayment(meansofPayment); message.setBeneficiary(beneficiary); message.setIsoMessage(isoMessage); //message.setMessageType(messageType); message.setDevice(device); message.setMessageDate(Instant.now()); //message.setDpService(dpService); //message.setClientApplication(clientApplication); //message.setClientTransactionNumber(clientTransactionNumber); //message.setComment(comment); message.setMessageStatus(messageStatus); message.setRegistrationDate(Instant.now()); //message.setTransactionFees(transactionFees); message = messageDao.save(message); return message; } public MessageSetting getMessageSetting(String messageType, BeneficiaryType beneficiaryType){ return new MessageSetting(); } public MessageType getMessageType(String messageType){ return new MessageType(); } public Device getDevice(String deviceCode){ return new Device(); } public Meansofpayment getMeansofpayment(String meansofpayment){ return new Meansofpayment(); } public Beneficiary getBeneficiary(String beneficiary){ return new Beneficiary(); } public Meansofpayment getMerchantMeansofpayment(Merchant merchant){ return new Meansofpayment(); } public Beneficiary getAcquirerOperationAccount(Partner acquirer){ return new Beneficiary(); } public Message getMoneyTransfer(String remittancereferencecode, String remittancesecretcode){ return new Message(); } public Meansofpayment getMoneyTransferMeansofpayment(Beneficiary beneficiary){ return new Meansofpayment(); } public String generateIsoMessage(DpService dpService, Device device, Merchant merchant, Meansofpayment meansofpayment, Beneficiary beneficiary){ String isoMessage; if (dpService.getIsoMessage() == null){ return null; } ISO87APackager packager = new ISO87APackager(); ISOMsg m = new ISOMsg(); m.setMTI (dpService.getIsoMessage().getMessageCode()); //m.set (2, meansofpayment); //m.set (3, "20021"); //m.set (4, amount + ""); //m.set (11, "000001"); //m.set (32, issuerCode); //m.set (41, this.terminalid); m.set (42, merchant.getCode()); //m.set (60, "jPOS 6"); //m.set (70, "301"); logISOMsg(m); m.setPackager (packager); byte[] binaryImage = m.pack(); isoMessage = new String(binaryImage); return isoMessage; } @Autowired private DeviceRepository deviceDao; @Autowired private DpServiceRepository dpServiceDao; @Autowired private IsoSettingRepository isoSettingDao; @Autowired private IsoMessageRepository isoMessageDao; @Autowired private IsoMessageFieldRepository isoMessageFieldDao; @Autowired private MessageRepository messageDao; @Autowired private MessageStatusRepository messageStatusDao; @Autowired private MeansofpaymentRepository meansofpaymentDao; @Autowired private MeansofpaymentTypeRepository meansofpaymentTypeDao; @Autowired private BeneficiaryTypeRepository beneficiaryTypeDao; @Autowired private IsoServerRepository isoServerDao; @Autowired private DpServiceRepository DpServiceDao; }
We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy. Accept Learn more