예제 #1
0
        private IUpdateTransactionCommand MapToUpdateCommand(
            UpdateOutTxCommand cmd,
            IPaymentRequestTransaction tx)
        {
            switch (tx.TransactionType)
            {
            case TransactionType.Payment:
                return(Mapper.Map <UpdatePaymentOutTxCommand>(cmd));

            case TransactionType.Refund:
                return(Mapper.Map <UpdateRefundOutTxCommand>(cmd,
                                                             opt => opt.Items["WalletAddress"] = tx.WalletAddress));

            case TransactionType.Exchange:
                return(Mapper.Map <UpdateExchangeOutTxCommand>(cmd));

            case TransactionType.Settlement:
                return(Mapper.Map <UpdateSettlementOutTxCommand>(cmd));

            case TransactionType.CashOut:
                return(Mapper.Map <UpdateCashoutTxCommand>(cmd));

            default:
                throw new UnexpectedTransactionTypeException(tx.TransactionType);
            }
        }
예제 #2
0
        public async Task UpdateOutgoingAsync(UpdateOutTxCommand cmd)
        {
            var txs = (await _transactionsService.GetByBcnIdentityAsync(
                           cmd.Blockchain,
                           cmd.IdentityType,
                           cmd.Identity)).ToList();

            if (!txs.Any())
            {
                throw new OutboundTransactionsNotFound(cmd.Blockchain, cmd.IdentityType, cmd.Identity);
            }

            foreach (var tx in txs)
            {
                _log.Info($"Outgoing transaction update [type = {tx.TransactionType}]", cmd.ToJson());

                IUpdateTransactionCommand updateCommand = MapToUpdateCommand(cmd, tx);

                await _transactionsService.UpdateAsync(updateCommand);

                if (tx.TransactionType == TransactionType.Payment || tx.TransactionType == TransactionType.Refund)
                {
                    await _paymentRequestService.UpdateStatusAsync(tx.WalletAddress);
                }
            }
        }