Example #1
0
        public async void Test_Transfer()
        {
            string currency = "GBP";
            var    accounts = await _accountApiClient.GetAccounts();

            GetAccountResp accountResp1 = null;
            GetAccountResp accountResp2 = null;

            try
            {
                accountResp1 = accounts.Where(x => x.Currency == currency).First();
                accounts.Remove(accountResp1);
                accountResp2 = accounts.Where(x => x.Currency == currency).First();
            }
            catch (InvalidOperationException ex)
            {
                throw new Exception($"Missing account with {currency} currency");
            }

            TransferReq req = new TransferReq
            {
                RequestId       = DateTimeOffset.Now.ToUnixTimeMilliseconds().ToString(),
                SourceAccountId = accountResp1.Id,
                TargetAccountId = accountResp2.Id,
                Amount          = 100,
                Currency        = currency
            };

            var resp = await _paymentClient.CreateTransfer(req);

            Assert.NotNull(resp);
        }
 public TrasferReqModelTest()
 {
     // filled with valid data
     BASE_MODEL = new TransferReq
     {
         RequestId       = "111",
         SourceAccountId = "source",
         TargetAccountId = "target",
         Amount          = 1.0,
         Currency        = "123",
         Description     = "description"
     };
 }
Example #3
0
        public async void Test_Transfer_InSameCurrencys()
        {
            var currency = "EUR";
            var accounts = (await _accountApiClient.GetAccounts()).ToList();

            GetAccountResp accountInCurrencyMain     = null;
            GetAccountResp accounInCurrencySecondary = null;

            try
            {
                accountInCurrencyMain = accounts.FirstOrDefault(x => x.Currency == currency);
                if (accountInCurrencyMain == null)
                {
                    throw new Exception($"Account in currency is missing, you need to create a new one");
                }

                accounInCurrencySecondary =
                    accounts.FirstOrDefault(x => x.Currency == currency && x.Id != accountInCurrencyMain.Id);
                if (accounInCurrencySecondary == null)
                {
                    throw new Exception($"account Not InCurrency is missing, you need to create a new one");
                }

                await Task.Delay(200);
            }
            catch (InvalidOperationException ex)
            {
                throw new Exception($"Missing account with {currency} currency - {ex.Message}");
            }

            var req = new TransferReq
            {
                RequestId       = DateTimeOffset.Now.ToUnixTimeMilliseconds().ToString(),
                SourceAccountId = accountInCurrencyMain.Id,
                TargetAccountId = accounInCurrencySecondary.Id,
                Amount          = 100,
                Currency        = currency
            };

            var resp = await _paymentClient.CreateTransfer(req);

            Assert.NotNull(resp);
        }
        /// <summary>
        /// Transfers the async.
        /// </summary>
        /// <returns>The async.</returns>
        /// <param name="assetId">Asset identifier.</param>
        /// <param name="opponentId">Opponent identifier.</param>
        /// <param name="amount">Amount.</param>
        /// <param name="pin">Pin.</param>
        /// <param name="traceId">Trace identifier.</param>
        /// <param name="memo">Memo.</param>
        public async Task <Transfer> TransferAsync(string assetId, string opponentId, string amount, string pin, string traceId, string memo)
        {
            const string req = "/transfers";

            var pinBlock = GenEncrypedPin(pin);

            TransferReq p = new TransferReq
            {
                asset_id    = assetId,
                opponent_id = opponentId,
                amount      = amount,
                trace_id    = traceId,
                pin         = pinBlock,
                memo        = memo
            };

            var rz = await doPostRequestAsync(req, p, true);

            return(JsonConvert.DeserializeObject <Transfer>(rz));
        }
Example #5
0
        public async Task <Result <TransferResp> > CreateTransfer(TransferReq req)
        {
            string endpoint = "/transfer";

            return(await _apiClient.Post <TransferResp>(endpoint, req));
        }