private PaymentLog updateBuildingPaymentLog(TransactionAdapter tx, PaymentLog paymentLog) throws RefundEntryAlreadyExistsException { if (paymentLog == null) return null; RefundReason reason = null; try { reason = RefundReason.TRANSACTION_VALUE_MISSING; paymentLog.setCryptocurrencyAmount(tx.getTransactionValue()); BigDecimal valueInMainUnit = tx.getTransactionValueInMainUnit(); reason = RefundReason.INVESTOR_MISSING; paymentLog.setInvestor(tx.getAssociatedInvestor()); reason = RefundReason.BLOCK_TIME_MISSING; paymentLog.setBlockTime(tx.getBlockTime()); reason = RefundReason.FX_RATE_MISSING; BigDecimal fxRate = getUSDExchangeRate(tx.getBlockTime().toInstant(), tx.getCurrencyType()); paymentLog.setUsdFxRate(fxRate); paymentLog.setUsdAmount(valueInMainUnit.multiply(fxRate)); } catch (MissingTransactionInformationException e) { monitorService.createRefundEntryForPaymentLogAndCommit(paymentLog, reason); return null; } return paymentLogService.saveAndCommit(paymentLog); }
protected void processPendingTransactions(TransactionAdapter tx) { try { if (!isAddressMonitored(tx.getReceivingAddress())) return; PaymentLog paymentLog; try { paymentLog = monitorService.getPendingPaymentLogForReprocessing(tx.getTransactionId()); } catch (PaymentLogNotFoundException e) { paymentLog = monitorService.createNewPaymentLog(tx, TransactionStatus.PENDING); } if (paymentLog == null) return; paymentLog.setCryptocurrencyAmount(tx.getTransactionValue()); paymentLog.setInvestor(tx.getAssociatedInvestor()); monitorService.sendTransactionReceivedMessageAndSavePaymentLog( paymentLog, tx.getTransactionValueInMainUnit(), tx.getTransactionUrl()); } catch (MissingTransactionInformationException e) { LOG.error("Error processing transaction", e); } }