minor fixes
This commit is contained in:
@@ -38,10 +38,15 @@ public class TransactionService {
|
|||||||
return BigDecimal.ZERO;
|
return BigDecimal.ZERO;
|
||||||
}
|
}
|
||||||
|
|
||||||
Currency currency = currencyService.findCurrencyByIsoCode(transaction.getCreditCurrency().name());
|
Currency debitCurrency = currencyService.findCurrencyByIsoCode(transaction.getDebitCurrency().name());
|
||||||
|
Currency creditCurrency = currencyService.findCurrencyByIsoCode(transaction.getCreditCurrency().name());
|
||||||
|
|
||||||
BigDecimal bankRate = new BigDecimal(currency.getBankRate());
|
BigDecimal debitBankRate = new BigDecimal(debitCurrency.getBankRate());
|
||||||
BigDecimal creditAmount = transaction.getAmount().multiply(bankRate).setScale(4, RoundingMode.HALF_EVEN);
|
BigDecimal creditBankRate = new BigDecimal(creditCurrency.getBankRate());
|
||||||
|
|
||||||
|
BigDecimal bankRate = creditBankRate.divide(debitBankRate, 4, RoundingMode.HALF_UP);
|
||||||
|
|
||||||
|
BigDecimal creditAmount = transaction.getAmount().multiply(bankRate).setScale(4, RoundingMode.HALF_UP);
|
||||||
|
|
||||||
transaction.setCreditAmount(creditAmount);
|
transaction.setCreditAmount(creditAmount);
|
||||||
return creditAmount;
|
return creditAmount;
|
||||||
|
|||||||
@@ -181,7 +181,7 @@ public class VelocityPaymentService {
|
|||||||
? "VMC" : transaction.getPaymentProcessorLabel();
|
? "VMC" : transaction.getPaymentProcessorLabel();
|
||||||
VelocityTransactionDto payload = VelocityTransactionDto.builder()
|
VelocityTransactionDto payload = VelocityTransactionDto.builder()
|
||||||
.salesOrderId(transaction.getOrderId())
|
.salesOrderId(transaction.getOrderId())
|
||||||
.amount(transaction.getTotalAmount())
|
.amount(transaction.getCreditAmount())
|
||||||
.debitPhone(transaction.getDebitPhone())
|
.debitPhone(transaction.getDebitPhone())
|
||||||
.debitRegion("ZW")
|
.debitRegion("ZW")
|
||||||
.type("REQUEST")
|
.type("REQUEST")
|
||||||
|
|||||||
@@ -69,11 +69,7 @@ public class ZesaConfirmationHotProcessor implements TransactionProcessorInterfa
|
|||||||
transaction.setCreditCurrency(CurrencyType.USD);
|
transaction.setCreditCurrency(CurrencyType.USD);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(transaction.getDebitCurrency().equals(CurrencyType.USD) && transaction.getCreditCurrency().equals(CurrencyType.ZWG)) {
|
|
||||||
transaction.setCreditAmount(transactionService.calculateCreditAmount(transaction));
|
transaction.setCreditAmount(transactionService.calculateCreditAmount(transaction));
|
||||||
}else {
|
|
||||||
transaction.setCreditAmount(transaction.getAmount());
|
|
||||||
}
|
|
||||||
|
|
||||||
// token should've been updated by checkCustomer
|
// token should've been updated by checkCustomer
|
||||||
if (!hotRechargeBalanceService.checkBalance(token, transaction.getCreditAmount(), accId)) {
|
if (!hotRechargeBalanceService.checkBalance(token, transaction.getCreditAmount(), accId)) {
|
||||||
@@ -85,6 +81,7 @@ public class ZesaConfirmationHotProcessor implements TransactionProcessorInterfa
|
|||||||
|
|
||||||
transaction.setStatus(Status.SUCCESS);
|
transaction.setStatus(Status.SUCCESS);
|
||||||
transaction.setResponseCode("00");
|
transaction.setResponseCode("00");
|
||||||
|
transaction.setCreditPhone(transaction.getDebitPhone());
|
||||||
|
|
||||||
List<Map<String, String>> additionalDataList = buildAdditionalData(customerData);
|
List<Map<String, String>> additionalDataList = buildAdditionalData(customerData);
|
||||||
transaction.setAdditionalData(additionalDataList);
|
transaction.setAdditionalData(additionalDataList);
|
||||||
|
|||||||
@@ -128,29 +128,7 @@ public class HotRechargeIntegrationProcessor implements TransactionProcessorInte
|
|||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
logger.info("Simulating HotRecharge success");
|
logger.info("Simulating HotRecharge success");
|
||||||
return Utils.fromJson("{\n" +
|
return getZesaPayload();
|
||||||
" \"successful\": true,\n" +
|
|
||||||
" \"rechargeId\": 1.9080854E8,\n" +
|
|
||||||
" \"amount\": 265.0,\n" +
|
|
||||||
" \"discount\": 1.2,\n" +
|
|
||||||
" \"balance\": {\n" +
|
|
||||||
" \"accountTypeId\": 2.0,\n" +
|
|
||||||
" \"name\": \"Utility ZWG\",\n" +
|
|
||||||
" \"balance\": 3306.32\n" +
|
|
||||||
" },\n" +
|
|
||||||
" \"message\": \"Transaction processed successfully\",\n" +
|
|
||||||
" \"rechargeData\": {\n" +
|
|
||||||
" \"Network\": \"ZESA\",\n" +
|
|
||||||
" \"Target\": \"07088597534\",\n" +
|
|
||||||
" \"Cost\": \"261.8200\",\n" +
|
|
||||||
" \"Token\": \"6616 0517 2063 6675 8254\",\n" +
|
|
||||||
" \"Units\": \"40.92\",\n" +
|
|
||||||
" \"NetAmount\": \"250\",\n" +
|
|
||||||
" \"TaxAmount\": \"0\",\n" +
|
|
||||||
" \"Levy\": \"15\",\n" +
|
|
||||||
" \"Arrears\": \"0\"\n" +
|
|
||||||
" }\n" +
|
|
||||||
"}", LinkedHashMap.class);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -262,6 +240,32 @@ public class HotRechargeIntegrationProcessor implements TransactionProcessorInte
|
|||||||
return additionalDataList;
|
return additionalDataList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private LinkedHashMap<String, Object> getZesaPayload() {
|
||||||
|
return Utils.fromJson("{\n" +
|
||||||
|
" \"successful\": true,\n" +
|
||||||
|
" \"rechargeId\": 1.9080854E8,\n" +
|
||||||
|
" \"amount\": 265.0,\n" +
|
||||||
|
" \"discount\": 1.2,\n" +
|
||||||
|
" \"balance\": {\n" +
|
||||||
|
" \"accountTypeId\": 2.0,\n" +
|
||||||
|
" \"name\": \"Utility ZWG\",\n" +
|
||||||
|
" \"balance\": 3306.32\n" +
|
||||||
|
" },\n" +
|
||||||
|
" \"message\": \"Transaction processed successfully\",\n" +
|
||||||
|
" \"rechargeData\": {\n" +
|
||||||
|
" \"Network\": \"ZESA\",\n" +
|
||||||
|
" \"Target\": \"07088597534\",\n" +
|
||||||
|
" \"Cost\": \"261.8200\",\n" +
|
||||||
|
" \"Token\": \"6616 0517 2063 6675 8254\",\n" +
|
||||||
|
" \"Units\": \"40.92\",\n" +
|
||||||
|
" \"NetAmount\": \"250\",\n" +
|
||||||
|
" \"TaxAmount\": \"0\",\n" +
|
||||||
|
" \"Levy\": \"15\",\n" +
|
||||||
|
" \"Arrears\": \"0\"\n" +
|
||||||
|
" }\n" +
|
||||||
|
"}", LinkedHashMap.class);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object reverse(Transaction transaction) {
|
public Object reverse(Transaction transaction) {
|
||||||
return transaction;
|
return transaction;
|
||||||
|
|||||||
Reference in New Issue
Block a user