public async Task Test_Idempotency_PayinsDirectDebitCreate() { string key = DateTime.Now.Ticks.ToString(); WalletDTO wallet = await this.GetJohnsWallet(); UserNaturalDTO user = await this.GetJohn(); PayInDirectDebitPostDTO payIn = new PayInDirectDebitPostDTO(user.Id, new Money { Amount = 10000, Currency = CurrencyIso.EUR }, new Money { Amount = 100, Currency = CurrencyIso.EUR }, wallet.Id, "http://www.mysite.com/returnURL/", CultureCode.FR, DirectDebitType.GIROPAY); payIn.TemplateURLOptions = new TemplateURLOptions { PAYLINE = "https://www.maysite.com/payline_template/" }; payIn.Tag = "DirectDebit test tag"; await Api.PayIns.CreateDirectDebit(key, payIn); var result = await Api.Idempotency.Get(key); Assert.IsInstanceOf <PayInDirectDebitDTO>(result.Resource); }
public async Task Test_Idempotency_PayinsMandateDirectDebitCreate() { string key = DateTime.Now.Ticks.ToString(); WalletDTO wallet = await this.GetJohnsWallet(); UserNaturalDTO user = await this.GetJohn(); string bankAccountId = this.GetJohnsAccount().Result.Id; string returnUrl = "http://test.test"; MandatePostDTO mandatePost = new MandatePostDTO(bankAccountId, CultureCode.EN, returnUrl); MandateDTO mandate = await this.Api.Mandates.Create(mandatePost); /* * ! IMPORTANT NOTE ! * * In order to make this test pass, at this place you have to set a breakpoint, * navigate to URL the mandate.RedirectURL property points to and click "CONFIRM" button. * */ PayInMandateDirectPostDTO payIn = new PayInMandateDirectPostDTO(user.Id, new Money { Amount = 10000, Currency = CurrencyIso.EUR }, new Money { Amount = 0, Currency = CurrencyIso.EUR }, wallet.Id, "http://test.test", mandate.Id); await Api.PayIns.CreateMandateDirectDebit(key, payIn); var result = await Api.Idempotency.Get(key); Assert.IsInstanceOf <PayInMandateDirectDTO>(result.Resource); }
public async Task PostInvalidAlgoId(AlgoInstanceType algoInstanceType) { WalletDTO walletDTO = null; if (algoInstanceType == AlgoInstanceType.Live) { walletDTO = await GetExistingWallet(); } // Create algo var algoData = await CreateAlgo(); // Build days offset DaysOffsetDTO daysOffsetDTO = BuildDaysOffsetByInstanceType(algoInstanceType); // Build InstanceParameters InstanceParameters instanceParameters = InstanceConfig.UseInvalidAlgoId; // Build instance request payload var instanceForAlgo = InstanceDataBuilder.BuildInstanceData(algoData, walletDTO, algoInstanceType, instanceParameters, daysOffsetDTO); var url = algoInstanceType == AlgoInstanceType.Live ? ApiPaths.ALGO_STORE_SAVE_ALGO_INSTANCE : ApiPaths.ALGO_STORE_FAKE_TRADING_INSTANCE_DATA; var postInstanceDataResponse = await Consumer.ExecuteRequest(url, Helpers.EmptyDictionary, JsonUtils.SerializeObject(instanceForAlgo), Method.POST); Assert.That(postInstanceDataResponse.Status, Is.EqualTo(HttpStatusCode.NotFound), "we should receive not found response code"); }
public async Task Test_Mandate_GetTransactionsForMandate() { try { var mandate = await GetNewMandate(); WalletDTO wallet = await GetJohnsWallet(); UserNaturalDTO user = await GetJohn(); PayInMandateDirectPostDTO payIn = new PayInMandateDirectPostDTO(user.Id, new Money { Amount = 10000, Currency = CurrencyIso.EUR }, new Money { Amount = 0, Currency = CurrencyIso.EUR }, wallet.Id, "http://test.test", mandate.Id); PayInDTO createPayIn = await this.Api.PayIns.CreateMandateDirectDebit(payIn); var pagination = new Pagination(1, 1); var filter = new FilterTransactions(); var sort = new Sort(); sort.AddField("CreationDate", SortDirection.desc); var transactions = await Api.Mandates.GetTransactionsForMandate(mandate.Id, pagination, filter, sort); Assert.IsTrue(transactions.Count > 0); } catch (Exception ex) { Assert.Fail(ex.Message); } }
public void Test_PayIns_Create_CardDirect() { try { WalletDTO johnWallet = this.GetJohnsWalletWithMoney(); WalletDTO beforeWallet = this.Api.Wallets.Get(johnWallet.Id); PayInDTO payIn = this.GetNewPayInCardDirect(); WalletDTO wallet = this.Api.Wallets.Get(johnWallet.Id); UserNaturalDTO user = this.GetJohn(); Assert.IsTrue(payIn.Id.Length > 0); Assert.AreEqual(wallet.Id, payIn.CreditedWalletId); Assert.AreEqual(PayInPaymentType.CARD, payIn.PaymentType); Assert.AreEqual(PayInExecutionType.DIRECT, payIn.ExecutionType); Assert.IsTrue(payIn.DebitedFunds is Money); Assert.IsTrue(payIn.CreditedFunds is Money); Assert.IsTrue(payIn.Fees is Money); Assert.AreEqual(user.Id, payIn.AuthorId); Assert.IsTrue(wallet.Balance.Amount == beforeWallet.Balance.Amount + payIn.CreditedFunds.Amount); Assert.AreEqual(TransactionStatus.SUCCEEDED, payIn.Status); Assert.AreEqual(TransactionType.PAYIN, payIn.Type); } catch (Exception ex) { Assert.Fail(ex.Message); } }
public async Task PostInvalidInstanceAssetPair(AlgoInstanceType algoInstanceType) { WalletDTO walletDTO = null; if (algoInstanceType == AlgoInstanceType.Live) { walletDTO = await GetExistingWallet(); } // Create algo var algoData = await CreateAlgo(); // Build days offset DaysOffsetDTO daysOffsetDTO = BuildDaysOffsetByInstanceType(algoInstanceType); // Build InstanceParameters InstanceParameters instanceParameters = InstanceConfig.InvalidInstanceAssetPair; // Build instance request payload var instanceForAlgo = InstanceDataBuilder.BuildInstanceData(algoData, walletDTO, algoInstanceType, instanceParameters, daysOffsetDTO); var url = algoInstanceType == AlgoInstanceType.Live ? ApiPaths.ALGO_STORE_SAVE_ALGO_INSTANCE : ApiPaths.ALGO_STORE_FAKE_TRADING_INSTANCE_DATA; var postInstanceDataResponse = await Consumer.ExecuteRequest(url, Helpers.EmptyDictionary, JsonUtils.SerializeObject(instanceForAlgo), Method.POST); AlgoErrorDTO postInstanceDataResponseDTO = JsonUtils.DeserializeJson <AlgoErrorDTO>(postInstanceDataResponse.ResponseJson); Assert.That(postInstanceDataResponse.Status, Is.EqualTo(HttpStatusCode.InternalServerError), "responce should equals internal server erorr"); Assert.That(postInstanceDataResponseDTO.ErrorMessage, Does.Contain("NotFound from asset service calling AssetPairGetWithHttpMessagesAsync"), "we should receive erorr for not found asset pair"); }
/// <summary>Creates PayIn Card Direct object.</summary> /// <param name="userId">User identifier.</param> /// <returns>PayIn Card Direct instance returned from API.</returns> protected PayInCardDirectDTO GetNewPayInCardDirect(String userId) { WalletDTO wallet = this.GetJohnsWalletWithMoney(); if (userId == null) { UserNaturalDTO user = this.GetJohn(); userId = user.Id; } CardRegistrationPostDTO cardRegistrationPost = new CardRegistrationPostDTO(userId, CurrencyIso.EUR); CardRegistrationDTO cardRegistration = this.Api.CardRegistrations.Create(cardRegistrationPost); CardRegistrationPutDTO cardRegistrationPut = new CardRegistrationPutDTO(); cardRegistrationPut.RegistrationData = this.GetPaylineCorrectRegistartionData(cardRegistration); cardRegistration = this.Api.CardRegistrations.Update(cardRegistrationPut, cardRegistration.Id); CardDTO card = this.Api.Cards.Get(cardRegistration.CardId); // create pay-in CARD DIRECT PayInCardDirectPostDTO payIn = new PayInCardDirectPostDTO(cardRegistration.UserId, cardRegistration.UserId, new Money { Amount = 10000, Currency = CurrencyIso.EUR }, new Money { Amount = 0, Currency = CurrencyIso.EUR }, wallet.Id, "http://test.com", card.Id); // payment type as CARD payIn.CardType = card.CardType; return(this.Api.PayIns.CreateCardDirect(payIn)); }
public void Test_PayIns_PreAuthorizedDirect() { try { CardPreAuthorizationDTO cardPreAuthorization = this.GetJohnsCardPreAuthorization(); WalletDTO wallet = this.GetJohnsWalletWithMoney(); UserNaturalDTO user = this.GetJohn(); // create pay-in PRE-AUTHORIZED DIRECT PayInPreauthorizedDirectPostDTO payIn = new PayInPreauthorizedDirectPostDTO(user.Id, new Money { Amount = 10000, Currency = CurrencyIso.EUR }, new Money { Amount = 0, Currency = CurrencyIso.EUR }, wallet.Id, cardPreAuthorization.Id); payIn.SecureModeReturnURL = "http://test.com"; PayInPreauthorizedDirectDTO createPayIn = this.Api.PayIns.CreatePreauthorizedDirect(payIn); Assert.IsTrue("" != createPayIn.Id); Assert.AreEqual(wallet.Id, createPayIn.CreditedWalletId); Assert.AreEqual(PayInPaymentType.PREAUTHORIZED, createPayIn.PaymentType); Assert.AreEqual(PayInExecutionType.DIRECT, createPayIn.ExecutionType); Assert.IsTrue(createPayIn.DebitedFunds is Money); Assert.IsTrue(createPayIn.CreditedFunds is Money); Assert.IsTrue(createPayIn.Fees is Money); Assert.AreEqual(user.Id, createPayIn.AuthorId); Assert.AreEqual(TransactionStatus.SUCCEEDED, createPayIn.Status); Assert.AreEqual(TransactionType.PAYIN, createPayIn.Type); } catch (Exception ex) { Assert.Fail(ex.Message); } }
public async Task <IActionResult> AddWallet([FromBody] WalletDTO model) { var user = await _userManager.GetUserAsync(User); if (user == null) { return(NotFound(ResponseMessage.Message("Not found", errors: new { message = "Could not access user" }))); } try { //do not create if wallet with this currency already exists Wallet wallet = new Wallet { WalletId = Guid.NewGuid().ToString(), ApplicationUserId = user.Id, WalletCurrency = model.WalletCurrency }; await _walletRepository.AddWallet(wallet); return(Ok(ResponseMessage.Message("Success", data: new { id = wallet.WalletId }))); } catch (Exception e) { _logger.LogError(e.Message); return(BadRequest(ResponseMessage.Message("Bad request", errors: new { message = "Failed to add wallet" }))); } }
public async Task Test_Idempotency_PayinsPreauthorizedDirectCreate() { string key = DateTime.Now.Ticks.ToString(); string okCode = "200"; CardPreAuthorizationDTO cardPreAuthorization = await this.GetJohnsCardPreAuthorization(); WalletDTO wallet = await this.GetJohnsWalletWithMoney(); UserNaturalDTO user = await this.GetJohn(); PayInPreauthorizedDirectPostDTO payIn = new PayInPreauthorizedDirectPostDTO(user.Id, new Money { Amount = 10000, Currency = CurrencyIso.EUR }, new Money { Amount = 0, Currency = CurrencyIso.EUR }, wallet.Id, cardPreAuthorization.Id); payIn.SecureModeReturnURL = "http://test.com"; await Api.PayIns.CreatePreauthorizedDirectAsync(key, payIn); var result = await Api.Idempotency.GetAsync(key); Assert.AreEqual(result.StatusCode, okCode); Assert.IsInstanceOf <PayInPreauthorizedDirectDTO>(result.Resource); }
public async Task <SyncPersonalWalletResponse> Handle(SyncPersonalWalletRequest request, CancellationToken cancellationToken) { var result = new SyncPersonalWalletResponse(); var wallet = await _context.Wallets .Where(x => x.WalletID == request.WalletID) .Include(x => x.Blockchain) .SingleOrDefaultAsync(cancellationToken); if (wallet == null) { throw new NotFoundException(nameof(Wallet), request.WalletID); } var cryptoWallet = new CryptoWallet(); var walletDTO = new WalletDTO(); if (wallet.Blockchain.Symbol == CurrencySymbol.BTC) { cryptoWallet = await _bitcoinService.GetBitcoinWalletAsync(wallet.Address); walletDTO = await WalletSynchronizer.ImportBalance(_context, _dateTimeOffset.Now, wallet, cryptoWallet, cancellationToken); } else if (wallet.Blockchain.Symbol == CurrencySymbol.ETH) { if (wallet.IsSynchronized) { walletDTO = await WalletSynchronizer.ImportEthereumTransactions(_context, _ethereumService, wallet, cancellationToken); } else { cryptoWallet = await _ethereumService.GetEthereumWalletAsync(wallet.Address); walletDTO = await WalletSynchronizer.ImportBalance(_context, _dateTimeOffset.Now, wallet, cryptoWallet, cancellationToken); } } else if (wallet.Blockchain.Symbol == CurrencySymbol.DOGE) { cryptoWallet = await _dogecoinService.GetDogecoinWalletAsync(wallet.Address); walletDTO = await WalletSynchronizer.ImportBalance(_context, _dateTimeOffset.Now, wallet, cryptoWallet, cancellationToken); } else if (wallet.Blockchain.Symbol == CurrencySymbol.STEEM) { cryptoWallet = await _steemService.GetSteemWalletAsync(wallet.Address); walletDTO = await WalletSynchronizer.ImportBalance(_context, _dateTimeOffset.Now, wallet, cryptoWallet, cancellationToken); } else if (wallet.Blockchain.Symbol == CurrencySymbol.HIVE) { cryptoWallet = await _hiveService.GetHiveWalletAsync(wallet.Address); walletDTO = await WalletSynchronizer.ImportBalance(_context, _dateTimeOffset.Now, wallet, cryptoWallet, cancellationToken); } result.IsSuccessful = true; result.Wallet = walletDTO; return(result); }
public void Test_PayIns_Get_PayPal() { try { PayInDTO payIn = null; WalletDTO wallet = TestHelper.GetJohnsWallet(); UserNaturalDTO user = TestHelper.GetJohn(); PayInPayPalPostDTO payInPost = new PayInPayPalPostDTO(user.Id, new Money { Amount = 1000, Currency = CurrencyIso.EUR }, new Money { Amount = 0, Currency = CurrencyIso.EUR }, wallet.Id, "http://test/test"); payIn = _objectToTest.CreatePayPal(payInPost).Result; Assert.True(payIn.Id.Length > 0); Assert.True(payIn.PaymentType == PayInPaymentType.PAYPAL); Assert.True(payIn.ExecutionType == PayInExecutionType.WEB); PayInPayPalDTO getPayIn = _objectToTest.GetPayPal(payIn.Id).Result; Assert.NotNull(getPayIn); Assert.True(getPayIn.Id == payIn.Id); } catch (Exception ex) { Assert.True(false, ex.Message); } }
public void Test_PayIns_BankWireDirect_Get() { try { WalletDTO wallet = TestHelper.GetJohnsWallet(); UserNaturalDTO user = TestHelper.GetJohn(); // create pay-in BANKWIRE DIRECT PayInBankWireDirectPostDTO payIn = new PayInBankWireDirectPostDTO(user.Id, wallet.Id, new Money { Amount = 10000, Currency = CurrencyIso.EUR }, new Money { Amount = 0, Currency = CurrencyIso.EUR }); payIn.CreditedWalletId = wallet.Id; payIn.AuthorId = user.Id; PayInBankWireDirectDTO createdPayIn = _objectToTest.CreateBankWireDirect(payIn).Result; System.Threading.Thread.Sleep(1000); PayInBankWireDirectDTO getPayIn = _objectToTest.GetBankWireDirect(createdPayIn.Id).Result; Assert.Equal(getPayIn.Id, createdPayIn.Id); Assert.Equal(PayInPaymentType.BANK_WIRE, getPayIn.PaymentType); Assert.Equal(PayInExecutionType.DIRECT, getPayIn.ExecutionType); Assert.Equal(user.Id, getPayIn.AuthorId); Assert.Equal(TransactionType.PAYIN, getPayIn.Type); Assert.NotNull(getPayIn.WireReference); Assert.Equal(BankAccountType.IBAN, getPayIn.BankAccount.Type); } catch (Exception ex) { Assert.True(false, ex.Message); } }
public void Test_PayIns_BankWireDirect_Create() { try { WalletDTO wallet = TestHelper.GetJohnsWallet(); UserNaturalDTO user = TestHelper.GetJohn(); // create pay-in BANKWIRE DIRECT PayInBankWireDirectPostDTO payIn = new PayInBankWireDirectPostDTO(user.Id, wallet.Id, new Money { Amount = 10000, Currency = CurrencyIso.EUR }, new Money { Amount = 0, Currency = CurrencyIso.EUR }); payIn.CreditedWalletId = wallet.Id; payIn.AuthorId = user.Id; PayInDTO createPayIn = _objectToTest.CreateBankWireDirect(payIn).Result; Assert.True(createPayIn.Id.Length > 0); Assert.Equal(wallet.Id, createPayIn.CreditedWalletId); Assert.Equal(PayInPaymentType.BANK_WIRE, createPayIn.PaymentType); Assert.Equal(PayInExecutionType.DIRECT, createPayIn.ExecutionType); Assert.Equal(user.Id, createPayIn.AuthorId); Assert.Equal(TransactionStatus.CREATED, createPayIn.Status); Assert.Equal(TransactionType.PAYIN, createPayIn.Type); Assert.NotNull(((PayInBankWireDirectDTO)createPayIn).WireReference); Assert.Equal(BankAccountType.IBAN, ((PayInBankWireDirectDTO)createPayIn).BankAccount.Type); } catch (Exception ex) { Assert.True(false, ex.Message); } }
public async Task LimitExceededOnMakingWithdrawalPaymentTransaction() { //Arrange decimal amount1 = 500000.0m; decimal amount2 = 200000.0m; decimal amount3 = 200000.0m; decimal amount4 = 200000.0m; WalletDTO wallet = await ArrangeWallet(); await _paymentTransactionService.MakeDepositPaymentTransaction(wallet.UniqueMasterCitizenNumber, wallet.Password, amount1); await _paymentTransactionService.MakeDepositPaymentTransaction(wallet.UniqueMasterCitizenNumber, wallet.Password, amount2); await _paymentTransactionService.MakeDepositPaymentTransaction(wallet.UniqueMasterCitizenNumber, wallet.Password, amount3); await _paymentTransactionService.MakeWithdrawalPaymentTransaction(wallet.UniqueMasterCitizenNumber, wallet.Password, amount1); await _paymentTransactionService.MakeWithdrawalPaymentTransaction(wallet.UniqueMasterCitizenNumber, wallet.Password, amount2); await _paymentTransactionService.MakeWithdrawalPaymentTransaction(wallet.UniqueMasterCitizenNumber, wallet.Password, amount3); //Act & Assert ExceptionAssert.Throws <LimitExceededException>(() => _paymentTransactionService.MakeWithdrawalPaymentTransaction(wallet.UniqueMasterCitizenNumber, wallet.Password, amount4).Wait() ); }
public async Task Test_Idempotency_TransfersCreate() { string key = DateTime.Now.Ticks.ToString(); WalletDTO walletWithMoney = await this.GetJohnsWalletWithMoney(); UserNaturalDTO user = await this.GetJohn(); WalletPostDTO walletPost = new WalletPostDTO(new List <string> { user.Id }, "WALLET IN EUR FOR TRANSFER", CurrencyIso.EUR); WalletDTO wallet = await this.Api.Wallets.Create(walletPost); TransferPostDTO transfer = new TransferPostDTO(user.Id, user.Id, new Money { Amount = 100, Currency = CurrencyIso.EUR }, new Money { Amount = 0, Currency = CurrencyIso.EUR }, walletWithMoney.Id, wallet.Id); transfer.Tag = "DefaultTag"; await Api.Transfers.Create(key, transfer); var result = await Api.Idempotency.Get(key); Assert.IsInstanceOf <TransferDTO>(result.Resource); }
public async Task <WalletDTO> GetNewWallet(CreateWalletModel model) { Wallet wallet = new Wallet(); bool isUserRegistered = await _commonContext.Users.AnyAsync(u => u.PhoneNumber == model.PhoneNumber); if (isUserRegistered) { throw new ValidationException("The entered mobile number is already registered."); } WalletDTO result = new WalletDTO { PublicKey = wallet.PublicKey, PrivateKey = wallet.KeyPair.GetPrivateKey() }; _commonContext.Users.Add(new User { Name = model.Name, PhoneNumber = model.PhoneNumber, Role = Role.Voter, PublicKey = result.PublicKey }); await _commonContext.SaveChangesAsync(); return(result); }
public void Test_PayIns_BankWireDirect_Get() { try { WalletDTO wallet = this.GetJohnsWallet(); UserNaturalDTO user = this.GetJohn(); // create pay-in BANKWIRE DIRECT PayInBankWireDirectPostDTO payIn = new PayInBankWireDirectPostDTO(user.Id, wallet.Id, new Money { Amount = 10000, Currency = CurrencyIso.EUR }, new Money { Amount = 0, Currency = CurrencyIso.EUR }); payIn.CreditedWalletId = wallet.Id; payIn.AuthorId = user.Id; PayInBankWireDirectDTO createdPayIn = this.Api.PayIns.CreateBankWireDirect(payIn); PayInBankWireDirectDTO getPayIn = this.Api.PayIns.GetBankWireDirect(createdPayIn.Id); Assert.AreEqual(getPayIn.Id, createdPayIn.Id); Assert.AreEqual(PayInPaymentType.BANK_WIRE, getPayIn.PaymentType); Assert.AreEqual(PayInExecutionType.DIRECT, getPayIn.ExecutionType); Assert.AreEqual(user.Id, getPayIn.AuthorId); Assert.AreEqual(TransactionType.PAYIN, getPayIn.Type); Assert.IsNotNull(getPayIn.WireReference); Assert.AreEqual(getPayIn.BankAccount.Type, BankAccountType.IBAN); } catch (Exception ex) { Assert.Fail(ex.Message); } }
public void Test_Payins_CardDirect_Create_WithBilling() { try { WalletDTO johnWallet = this.GetJohnsWalletWithMoney(); WalletDTO wallet = this.Api.Wallets.Get(johnWallet.Id); UserNaturalDTO user = this.GetJohn(); PayInCardDirectDTO payIn = this.GetNewPayInCardDirectWithBilling(); Assert.IsTrue(payIn.Id.Length > 0); Assert.AreEqual(wallet.Id, payIn.CreditedWalletId); Assert.AreEqual(PayInPaymentType.CARD, payIn.PaymentType); Assert.AreEqual(PayInExecutionType.DIRECT, payIn.ExecutionType); Assert.IsTrue(payIn.DebitedFunds is Money); Assert.IsTrue(payIn.CreditedFunds is Money); Assert.IsTrue(payIn.Fees is Money); Assert.AreEqual(user.Id, payIn.AuthorId); Assert.AreEqual(TransactionStatus.SUCCEEDED, payIn.Status); Assert.AreEqual(TransactionType.PAYIN, payIn.Type); Assert.IsNotNull(payIn.Billing); Assert.IsNotNull(payIn.SecurityInfo); Assert.IsNotNull(payIn.SecurityInfo.AVSResult); Assert.AreEqual(payIn.SecurityInfo.AVSResult, AVSResult.NO_CHECK); } catch (Exception ex) { Assert.Fail(ex.Message); } }
public IActionResult Post([FromBody] WalletDTO dto) { var id = GetTokenId.getId(User); var currentAmount = _walletService.InsertTransaction(dto, id); return(Ok(currentAmount)); }
public void Test_PayIns_Create_PayPal() { try { PayInDTO payIn = null; WalletDTO wallet = this.GetJohnsWallet(); UserNaturalDTO user = this.GetJohn(); PayInPayPalPostDTO payInPost = new PayInPayPalPostDTO(user.Id, new Money { Amount = 1000, Currency = CurrencyIso.EUR }, new Money { Amount = 0, Currency = CurrencyIso.EUR }, wallet.Id, "http://test/test"); payIn = this.Api.PayIns.CreatePayPal(payInPost); Assert.IsTrue(payIn.Id.Length > 0); Assert.IsTrue(payIn.PaymentType == PayInPaymentType.PAYPAL); Assert.IsTrue(payIn.ExecutionType == PayInExecutionType.WEB); } catch (Exception ex) { Assert.Fail(ex.Message); } }
public async Task PostInvalidInstanceTradedAsset(AlgoInstanceType algoInstanceType) { WalletDTO walletDTO = null; if (algoInstanceType == AlgoInstanceType.Live) { walletDTO = await GetExistingWallet(); } // Create algo var algoData = await CreateAlgo(); // Build days offset DaysOffsetDTO daysOffsetDTO = BuildDaysOffsetByInstanceType(algoInstanceType); // Build InstanceParameters InstanceParameters instanceParameters = InstanceConfig.InvalidInstanceTradedAsset; // Build instance request payload var instanceForAlgo = InstanceDataBuilder.BuildInstanceData(algoData, walletDTO, algoInstanceType, instanceParameters, daysOffsetDTO); var url = algoInstanceType == AlgoInstanceType.Live ? ApiPaths.ALGO_STORE_SAVE_ALGO_INSTANCE : ApiPaths.ALGO_STORE_FAKE_TRADING_INSTANCE_DATA; var postInstanceDataResponse = await Consumer.ExecuteRequest(url, Helpers.EmptyDictionary, JsonUtils.SerializeObject(instanceForAlgo), Method.POST); AlgoErrorDTO postInstanceDataResponseDTO = JsonUtils.DeserializeJson <AlgoErrorDTO>(postInstanceDataResponse.ResponseJson); Assert.That(postInstanceDataResponse.Status, Is.EqualTo(HttpStatusCode.BadRequest), "should be bad response erorr code"); Assert.That(postInstanceDataResponseDTO.ErrorMessage, Does.Contain("ValidationError Message:Asset <USD> is not valid for asset pair <BTCEUR>"), "we should receive erorr for the invalid traded asset"); }
protected async Task <TransferDTO> GetNewTransfer(WalletDTO walletIn = null) { WalletDTO walletWithMoney = walletIn; if (walletWithMoney == null) { walletWithMoney = await this.GetJohnsWalletWithMoney(); } UserNaturalDTO user = await this.GetJohn(); WalletPostDTO walletPost = new WalletPostDTO(new List <string> { user.Id }, "WALLET IN EUR FOR TRANSFER", CurrencyIso.EUR); WalletDTO wallet = await this.Api.Wallets.CreateAsync(walletPost); TransferPostDTO transfer = new TransferPostDTO(user.Id, user.Id, new Money { Amount = 100, Currency = CurrencyIso.EUR }, new Money { Amount = 0, Currency = CurrencyIso.EUR }, walletWithMoney.Id, wallet.Id); transfer.Tag = "DefaultTag"; return(await this.Api.Transfers.CreateAsync(transfer)); }
/// <summary> /// Metoda koja pravi wallet /// </summary> /// <param name="walletDTO"></param> /// <returns>Id</returns> public async Task <WalletDTO> CreateWallet(WalletDTO walletDTO) { var result = await UnitOfWork.WalletRepository.GetFirstOrDefaultWithIncludes(m => m.JMBG == walletDTO.JMBG); if (result != null) { throw new WalletServiceException("Novcanik sa ovim JMBG-om vec postoji!", "CreateWallet: Duplicate JMBG"); } bool isValid = await BankService.CheckStatus(walletDTO.JMBG, walletDTO.PIN); if (!isValid) { new WalletServiceException("PIN nije validan!", "CreateWallet: Invalid PIN"); } string pass = PassService.GeneratePASS(); Wallet newWallet = new Wallet(walletDTO.FirstName, walletDTO.LastName, walletDTO.JMBG, walletDTO.Bank, walletDTO.PIN, walletDTO.BankAccount, pass); await UnitOfWork.WalletRepository.Insert(newWallet); await UnitOfWork.SaveChangesAsync(); return(new WalletDTO(newWallet)); }
public async Task Test_Idempotency_PayoutsBankwireCreate() { string key = DateTime.Now.Ticks.ToString(); WalletDTO wallet = await this.GetJohnsWallet(); UserNaturalDTO user = await this.GetJohn(); BankAccountDTO account = await this.GetJohnsAccount(); PayOutBankWirePostDTO payOut = new PayOutBankWirePostDTO(user.Id, wallet.Id, new Money { Amount = 10, Currency = CurrencyIso.EUR }, new Money { Amount = 5, Currency = CurrencyIso.EUR }, account.Id, "Johns bank wire ref"); payOut.Tag = "DefaultTag"; payOut.CreditedUserId = user.Id; await Api.PayOuts.CreateBankWire(key, payOut); var result = await Api.Idempotency.Get(key); Assert.IsInstanceOf <PayOutBankWireDTO>(result.Resource); }
public void Test_Payins_CardDirect_Create_WithBilling() { try { WalletDTO johnWallet = TestHelper.GetJohnsWalletWithMoney(); WalletDTO wallet = TestHelper.WalletsApi.Get(johnWallet.Id).Result; UserNaturalDTO user = TestHelper.GetJohn(); PayInCardDirectDTO payIn = TestHelper.GetNewPayInCardDirectWithBilling(); Assert.True(payIn.Id.Length > 0); Assert.Equal(wallet.Id, payIn.CreditedWalletId); Assert.Equal(PayInPaymentType.CARD, payIn.PaymentType); Assert.Equal(PayInExecutionType.DIRECT, payIn.ExecutionType); Assert.True(payIn.DebitedFunds is Money); Assert.True(payIn.CreditedFunds is Money); Assert.True(payIn.Fees is Money); Assert.Equal(user.Id, payIn.AuthorId); Assert.Equal(TransactionStatus.SUCCEEDED, payIn.Status); Assert.Equal(TransactionType.PAYIN, payIn.Type); Assert.NotNull(payIn.Billing); Assert.NotNull(payIn.SecurityInfo); Assert.Equal(AVSResult.ADDRESS_MATCH_ONLY, payIn.SecurityInfo.AVSResult); } catch (Exception ex) { Assert.True(false, ex.Message); } }
public async Task ExistingWalletExceptionOnCreatingWallet(string uniqueMasterCitizenNumber, string postalIndexNumber, string firstName, string lastName, int supportedBankId) { //Arrange WalletDTO wallet = await _walletService.CreateNewWallet(uniqueMasterCitizenNumber, postalIndexNumber, supportedBankId, firstName, lastName); //Act && Assert ExceptionAssert.Throws <ExistingWalletException>(() => _walletService.CreateNewWallet(uniqueMasterCitizenNumber, postalIndexNumber, supportedBankId, firstName, lastName).Wait()); }
public async Task InvalidWalletStatusOnActivatingWallet() { //Arrange WalletDTO wallet = await ArrangeWallet(); //Act & Assert ExceptionAssert.Throws <WalletStatusException>(() => _walletService.ActivateWallet(wallet.Id).Wait()); }
public async Task InvalidNewPassword(string newPassword) { //Arrange WalletDTO wallet = await ArrangeWallet(); //Act & Assert ExceptionAssert.Throws <InvalidNewPasswordException>(() => _walletService.ChangePassword(wallet.UniqueMasterCitizenNumber, wallet.Password, newPassword).Wait()); }
public void Test_Wallets_Create() { UserNaturalDTO john = this.GetJohn(); WalletDTO wallet = this.GetJohnsWallet(); Assert.IsTrue(wallet.Id.Length > 0); Assert.IsTrue(wallet.Owners.Contains(john.Id)); }