protected void confirmTransaction(TransactionAdapter tx) { try { LOG.info("Setting status of transaction {} to confirmed.", tx.getTransactionId()); PaymentLog paymentLog = paymentLogService.getPaymentLog(tx.getTransactionId()); paymentLog.setTransactionStatus(TransactionStatus.CONFIRMED); paymentLogService.saveAndCommit(paymentLog); } catch (MissingTransactionInformationException e) { LOG.error("Couldn't set payment log status to confirmed because the transaction id " + "could not be retrieved from the {} transaction.", tx.getCurrencyType(), e); } catch (PaymentLogNotFoundException e) { try { LOG.error("No payment log existed for {} transaction {} when trying to set the " + "transaction status to CONFIRMED", tx.getCurrencyType(), tx.getTransactionId(), e); } catch (MissingTransactionInformationException ignore) { } } }
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); }