Example #1
0
        public async Task <PaymentResult> UseBank(BankTransactionRequest request, PaymentType type)
        {
            if (type != PaymentType.Deposit && type != PaymentType.Withdrawal)
            {
                return new PaymentResult()
                       {
                           Status = PaymentStatus.Failed, Message = "Payment type is not supported"
                       }
            }
            ;

            Wallet wallet = await DataContext.Store.GetByIdAsync <Wallet>(request.User._Wallet);

            await CreateTransaction(wallet, request.Amount, type, ChannelType.Bank, Status.Pending, request.Meta);

            return(new PaymentResult()
            {
                Status = PaymentStatus.Pending
            });
        }

        #endregion

        #region Transactions
        async Task <bool> CreateTransaction(Wallet wallet, decimal amount,
                                            PaymentType type, ChannelType channelType,
                                            Status status, UserTransactionMetadata meta = null)
        {
            Transaction transaction = new Transaction()
            {
                AddedAtUtc      = DateTime.UtcNow,
                Amount          = amount,
                Status          = status,
                PaymentType     = type,
                _PaymentChannel = (int)channelType,
            };

            if (meta != null)
            {
                transaction.Meta = meta;
            }

            await transaction.InitializeAsync();

            await wallet.ProcessTransaction(transaction);

            return(true);
        }

        #endregion

        #endregion
    }
Example #2
0
 public void LocalInit()
 {
     bankTransactionRequest = Api.BankTransactionRequest; // Api is declared on TestBase
 }