completed initial setup
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
package zw.qantra.tm.domain.services;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import zw.qantra.tm.domain.repositories.ConfirmTransactionRepository;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class ConfirmTransactionService {
|
||||
private final ConfirmTransactionRepository confirmTransactionRepository;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package zw.qantra.tm.domain.services;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import zw.qantra.tm.domain.repositories.CurrencyRepository;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class CurrencyService {
|
||||
private final CurrencyRepository currencyRepository;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package zw.qantra.tm.domain.services;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import zw.qantra.tm.domain.repositories.IntegrationProcessorRepository;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class IntegrationProcessorService {
|
||||
private final IntegrationProcessorRepository integrationProcessorRepository;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package zw.qantra.tm.domain.services;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import zw.qantra.tm.domain.repositories.PaymentProcessorRepository;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class PaymentProcessorService {
|
||||
private final PaymentProcessorRepository paymentProcessorRepository;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package zw.qantra.tm.domain.services;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import zw.qantra.tm.domain.repositories.ProviderRepository;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class ProviderService {
|
||||
private final ProviderRepository providerRepository;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package zw.qantra.tm.domain.services;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import zw.qantra.tm.domain.repositories.SettingRepository;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class SettingService {
|
||||
private final SettingRepository settingRepository;
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package zw.qantra.tm.domain.services;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import zw.qantra.tm.domain.models.PaymentProcessor;
|
||||
import zw.qantra.tm.domain.models.Transaction;
|
||||
import zw.qantra.tm.domain.repositories.TransactionRepository;
|
||||
import zw.qantra.tm.domain.services.factories.PaymentProcessorFactory;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class TransactionService {
|
||||
private final TransactionRepository transactionRepository;
|
||||
private final PaymentProcessorFactory paymentProcessorFactory;
|
||||
|
||||
private Transaction bootstrap(Transaction transaction) {
|
||||
String label = transaction.getType() + "_" + transaction.getPaymentProcessorLabel();
|
||||
// PaymentProcessor paymentProcessor = paymentProcessorFactory.getPaymentProcessor(label);
|
||||
return transaction;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package zw.qantra.tm.domain.services.factories;
|
||||
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.ApplicationContextAware;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
public class PaymentProcessorFactory implements ApplicationContextAware {
|
||||
private final Logger logger = LoggerFactory.getLogger(this.getClass().getName());
|
||||
|
||||
private ApplicationContext applicationContext;
|
||||
|
||||
@Override
|
||||
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
|
||||
this.applicationContext = applicationContext;
|
||||
}
|
||||
|
||||
public Object getPaymentProcessor(String paymentProcessorName) {
|
||||
Object paymentProcessor;
|
||||
|
||||
try {
|
||||
paymentProcessor = applicationContext.getBean(paymentProcessorName);
|
||||
} catch (NoSuchBeanDefinitionException exception) {
|
||||
logger.error("Couldn't find payment processor: {}", exception.getMessage());
|
||||
return null;
|
||||
} catch (BeansException e) {
|
||||
logger.error("Error retrieving payment processor bean: {}", e.getMessage());
|
||||
return null;
|
||||
}
|
||||
|
||||
return paymentProcessor;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package zw.qantra.tm.domain.services.processors;
|
||||
|
||||
import zw.qantra.tm.domain.models.Transaction;
|
||||
|
||||
public interface TransactionProcessorInterface {
|
||||
Object process(Transaction transaction);
|
||||
Object reverse(Transaction transaction);
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package zw.qantra.tm.domain.services.processors.confirmations;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import zw.qantra.tm.domain.models.Transaction;
|
||||
import zw.qantra.tm.domain.services.processors.TransactionProcessorInterface;
|
||||
import zw.qantra.tm.rest.RestService;
|
||||
|
||||
@Service("CONFIRM_POWERTEL_ZESA")
|
||||
@RequiredArgsConstructor
|
||||
public class ZesaConfirmationProcessor implements TransactionProcessorInterface {
|
||||
private final RestService restService;
|
||||
|
||||
|
||||
@Override
|
||||
public Object process(Transaction transaction) {
|
||||
|
||||
return transaction;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object reverse(Transaction transaction) {
|
||||
return transaction;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user