/** * Fetches the payment log corresponding to the given transaction id if it is in status * {@link TransactionStatus#PENDING}. If successful it also updates the payment log status to * {@link TransactionStatus#BUILDING} before returning it. * @param transactionId The transaction id for which the corresponding payment log should be * retrieved. * @return the payment log for given transaction id if it is in status * {@link TransactionStatus#PENDING}. Null otherwise. * @throws PaymentLogNotFoundException if no payment log exists for the given transaction id. */ @Transactional(propagation = Propagation.REQUIRED) public PaymentLog getPendingPaymentLogForProcessing(String transactionId) throws PaymentLogNotFoundException { try { PaymentLog paymentLog = paymentLogService.getPaymentLog(transactionId); if (paymentLog.getTransactionStatus() != TransactionStatus.PENDING) { return null; } else { paymentLog.setTransactionStatus(TransactionStatus.BUILDING); return paymentLogService.updateProcessedDateAndSave(paymentLog); } } catch (OptimisticLockingFailureException e) { // If payment log was just now updated by another monitor instance // the payment log does not need to be reprocessed. return null; } }
PaymentLog paymentLog = paymentLogService.getPaymentLog(transactionId); boolean confirmationMailSent = paymentLog.isTransactionReceivedMessageSent(); boolean notPending = paymentLog.getTransactionStatus() != TransactionStatus.PENDING; boolean recentlyChanged = paymentLog.getProcessedDate().getTime() > new Date().getTime() - appConfig.getTransactionProcessingTime();
boolean pending = paymentLog.getTransactionStatus() == TransactionStatus.PENDING; boolean allocationMailSent = paymentLog.isAllocationMessageSent(); boolean refundEntryExists = paymentLog.getEligibleForRefund() == null;