Ejemplo n.º 1
0
        public async Task Save(NotificationTransaction transaction)
        {
            if (transaction.Debit > await transactionCalculator.RefundLimit(transaction.NotificationId))
            {
                throw new InvalidOperationException("Transaction cannot refund more than has already been paid");
            }

            var balance = await transactionCalculator.Balance(transaction.NotificationId)
                          - transaction.Credit.GetValueOrDefault()
                          + transaction.Debit.GetValueOrDefault();

            var transactions = (await transactionRepository.GetTransactions(transaction.NotificationId)).ToList();

            transactions.Add(transaction);

            var paymentDate = CalculatePaymentReceivedDate(transactions, balance);

            await UpdatePaymentReceivedDate(paymentDate, transaction.NotificationId);

            transactionRepository.Add(transaction);
        }
Ejemplo n.º 2
0
 public async Task <decimal> HandleAsync(GetRefundLimit message)
 {
     return(await transactionCalculator.RefundLimit(message.NotificationId));
 }