adding boolean setting config
This commit is contained in:
@@ -8,4 +8,5 @@ import java.util.UUID;
|
||||
|
||||
@Repository
|
||||
public interface SettingRepository extends JpaRepository<Setting, UUID> {
|
||||
Setting findBySettingName(String key);
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package zw.qantra.tm.domain.services;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import zw.qantra.tm.domain.models.Setting;
|
||||
import zw.qantra.tm.domain.repositories.SettingRepository;
|
||||
|
||||
@Service
|
||||
@@ -12,4 +13,17 @@ public class SettingService {
|
||||
public SettingRepository getSettingRepository() {
|
||||
return settingRepository;
|
||||
}
|
||||
|
||||
public Boolean getBooleanSetting(String key) {
|
||||
try {
|
||||
Setting setting = settingRepository.findBySettingName(key);
|
||||
if (setting != null) {
|
||||
return Boolean.parseBoolean(setting.getSettingValue());
|
||||
}
|
||||
return false;
|
||||
} catch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,7 @@ import org.springframework.stereotype.Service;
|
||||
import zw.qantra.tm.domain.dtos.SdkActionDto;
|
||||
import zw.qantra.tm.domain.enums.Status;
|
||||
import zw.qantra.tm.domain.models.Transaction;
|
||||
import zw.qantra.tm.domain.services.SettingService;
|
||||
import zw.qantra.tm.domain.services.TransactionService;
|
||||
import zw.qantra.tm.domain.services.processors.TransactionProcessorInterface;
|
||||
import zw.qantra.tm.rest.RestService;
|
||||
@@ -31,6 +32,7 @@ public class MPGSWebPaymentProcessor implements TransactionProcessorInterface {
|
||||
private final Logger logger = LoggerFactory.getLogger(MPGSWebPaymentProcessor.class);
|
||||
private final RestService restService;
|
||||
private final TransactionService transactionService;
|
||||
private final SettingService settingService;
|
||||
|
||||
@Value("${sbz.aggregator.encryption-key}")
|
||||
private String encryptionKey;
|
||||
@@ -128,10 +130,12 @@ public class MPGSWebPaymentProcessor implements TransactionProcessorInterface {
|
||||
LinkedHashMap body = (LinkedHashMap) response.get("body");
|
||||
|
||||
// todo: REMOVE THIS
|
||||
if(settingService.getBooleanSetting("SIMULATE_MPGS_SUCCESS")){
|
||||
body.put("status", "SUCCESS");
|
||||
LinkedHashMap hashMap = new LinkedHashMap();
|
||||
hashMap.put("creditReference", RandomStringUtils.randomNumeric(10));
|
||||
body.put("transaction", hashMap);
|
||||
}
|
||||
|
||||
// only update tran status if polling returns a success
|
||||
if(!body.get("status").equals("SUCCESS")){
|
||||
|
||||
Reference in New Issue
Block a user