@Transactional(propagation = Propagation.REQUIRED) public PaymentLog sendTransactionReceivedMessageAndSavePaymentLog(PaymentLog paymentLog, BigDecimal amountInMainUnit, String transactionUrl) { messageService.send(new TransactionReceivedEmailMessage( MessageDTOHelper.build(paymentLog.getInvestor()), amountInMainUnit, paymentLog.getCurrency(), transactionUrl)); paymentLog.setTransactionReceivedMessageSent(true); return paymentLogService.updateProcessedDateAndSave(paymentLog); }
private PaymentLog createRefundEntryForAmount( PaymentLog paymentLog, RefundReason reason, BigInteger cryptocurrencyAmount, BigDecimal usdAmount) throws RefundEntryAlreadyExistsException { EligibleForRefund refund = eligibleForRefundService.save( new EligibleForRefund(reason, cryptocurrencyAmount, usdAmount, paymentLog.getCurrency(), paymentLog.getInvestor(), paymentLog.getTransactionId())); paymentLog.setEligibleForRefund(refund); return paymentLog; }
@Transactional(propagation = Propagation.REQUIRED) public PaymentLog sendAllocationMessageAndSavePaymentLog(PaymentLog paymentLog, BigDecimal amountInMainUnit, String transactionUrl) { messageService.send(new TokensAllocatedEmailMessage( MessageDTOHelper.build(paymentLog.getInvestor()), amountInMainUnit, paymentLog.getCurrency(), transactionUrl, convertTomicsToTokens(paymentLog.getAllocatedTomics()))); paymentLog.setAllocationMessageSent(true); return paymentLogService.updateProcessedDateAndSave(paymentLog); }
@Test public void testSaveAndExistsAndFind() { Investor i = createInvestor(1); PaymentLog p = paymentLogRepository.save(createPaymentLog(i, "1")); // assertTrue(paymentLogRepository.existsByTxIdentifierAndCurrency("1", CURRENCY_TYPE)); Optional<PaymentLog> oPaymentLog = paymentLogRepository.findOptionalByTransactionId("1"); assertTrue(oPaymentLog.isPresent()); assertTrue(oPaymentLog.filter((paymentLog) -> paymentLog.getInvestor().getEmail().equals("emailAddress1") ).isPresent()); assertTrue(oPaymentLog.filter((paymentLog) -> paymentLog.equals(p)).isPresent()); }