Пример #1
0
 protected override Transaction Deposit(Account account, Transfer transfer, string code, string description)
 {
     var payment = (CardPayment) transfer;
     var depositTransaction = account.Deposit(code, description, Settings.Location, new Money(transfer.Currency, transfer.Amount), MoneyConverter);
     var paymentLink = new PaymentTransactionLink(depositTransaction, payment.Order);
     _paymentTransactionLinkRepository.Create(paymentLink);
     return depositTransaction;
 }
Пример #2
0
 protected virtual IEnumerable<ApplicationEvent> WhenDepositFailed(Guid appOperationId, Transfer transfer)
 {
     transfer.Fail(string.Format(Messages.TransferFailed, transfer.Deposit.ErrorMessage));
     var transactionName = TransactionReferenceBook.CompensationFor(transfer.Withdrawal);
     var compensationTransaction = Compensate(transfer.From, transfer, transactionName.Code, transactionName.Description);
     TransactionRepository.Create(compensationTransaction);
     TransferRepository.Update(transfer);
     var transactionModel = compensationTransaction.ToModel<Transaction, TransactionModel>();
     return new List<ApplicationEvent>
     {
         new TransactionProgressEvent(appOperationId, transactionModel, transfer.Id)
     };
 }
Пример #3
0
 protected override Transaction Deposit(Account account, Transfer transfer, string code, string description)
 {
     var cardTransfer = (CardTransfer) transfer;
     return account.Deposit(cardTransfer.DestinationCard, code, description, Settings.Location,
         new Money(transfer.Currency, transfer.Amount), this.MoneyConverter);
 }
Пример #4
0
 protected virtual IEnumerable<ApplicationEvent> WhenWithdrawalCompleted(Guid appOperationId, Transfer transfer)
 {
     var transactionName = TransactionReferenceBook.ForOperation(transfer);
     var depositTransaction = Deposit(transfer.To, transfer, transactionName.Code, transactionName.Description);
     transfer.SetDepositTransaction(depositTransaction);
     var transactionModel = depositTransaction.ToModel<Transaction, TransactionModel>();
     TransferRepository.Update(transfer);
     return new List<ApplicationEvent>()
     {
         new TransactionProgressEvent(appOperationId, transactionModel, transfer.Id)
     };
 }
Пример #5
0
 protected virtual IEnumerable<ApplicationEvent> WhenDepositCompleted(Guid appOperationId, Transfer transfer)
 {
     transfer.Complete();
     TransferRepository.Update(transfer);
     return Enumerable.Empty<ApplicationEvent>();
 }
Пример #6
0
 protected abstract Transaction Deposit(Account account, Transfer transfer, string code, string description);
Пример #7
0
 protected abstract Transaction Compensate(Account account, Transfer transfer, string code, string description);
Пример #8
0
 private IEnumerable<ApplicationEvent> WhenStateIsInvalid(Guid appOperationId, Transfer transfer)
 {
     transfer.Fail(string.Format(Messages.TransferFailedUnknownReason, transfer.Id));
     TransferRepository.Update(transfer);
     Logger.Error("Transfer #{0} is in invalid state.", transfer.Id);
     return Enumerable.Empty<ApplicationEvent>();
 }
Пример #9
0
 protected virtual IEnumerable<ApplicationEvent> WhenWithdrawalPending(Guid appOperationId, Transfer transfer)
 {
     var transactionModel = transfer.Withdrawal.ToModel<Transaction, TransactionModel>();
     return new List<ApplicationEvent>()
     {
         new TransactionProgressEvent(appOperationId, transactionModel, transfer.Id)
     };
 }
Пример #10
0
 protected virtual IEnumerable<ApplicationEvent> WhenWithdrawalFailed(Guid appOperationId, Transfer transfer)
 {
     transfer.Fail(string.Format(Messages.TransferFailed, transfer.Withdrawal.ErrorMessage));
     TransferRepository.Update(transfer);
     return Enumerable.Empty<ApplicationEvent>();
 }
Пример #11
0
 protected override IEnumerable<ApplicationEvent> WhenWithdrawalPending(Guid appOperationId, Transfer transfer)
 {
     Task.Delay(TimeSpan.FromSeconds(DelaySecons)).Wait();
     return base.WhenWithdrawalPending(appOperationId, transfer);
 }