public async Task <PaymentRequestRefund> GetRefundInfoAsync(string walletAddress) { IReadOnlyList <IPaymentRequestTransaction> transactions = (await _transactionsService.GetByWalletAsync(walletAddress)).Where(x => x.IsRefund()).ToList(); if (!transactions.Any()) { return(null); } IEnumerable <string> transferIds = transactions.Unique(x => x.TransferId).ToList(); if (transferIds.MoreThanOne()) { throw new MultiTransactionRefundNotSupportedException(); } Transfer transfer = await _transferService.GetAsync(transferIds.Single()); IPaymentRequest paymentRequest = await FindAsync(walletAddress); return(new PaymentRequestRefund { Amount = transfer.Amounts.Sum(x => x.Amount ?? 0), Timestamp = transfer.CreatedOn, Address = transfer.Amounts.Unique(x => x.Destination).Single(), DueDate = transactions.OrderByDescending(x => x.DueDate).First().DueDate ?? paymentRequest.DueDate, Transactions = Mapper.Map <IEnumerable <PaymentRequestRefundTransaction> >(transactions) }); }