public async Task <IWriterResult <bool> > CreateTransfer(CreateTransferModel model) { var result = await TradeService.QueueTransfer(model); if (result.HasError) { return(WriterResult <bool> .ErrorResult(result.Error)); } return(WriterResult <bool> .SuccessResult()); }
public async Task <ActionResult> Create(CreateTransferModel model) { if (model.TwoFactorType == TwoFactorType.None) { // If there is no tfa remove the Data field validation. ModelState.Remove("Data"); } if (!ModelState.IsValid) { return(View("CreateTransferModal", model)); } var user = await UserManager.FindByIdAsync(User.Id()); if (user == null) { return(Unauthorized()); } var recipient = await UserManager.FindByNameAsync(model.Recipient); if (recipient == null) { ModelState.AddModelError("Recipient", string.Format("UserName '{0}' not found.", model.Recipient)); return(View("CreateTransferModal", model)); } // Verify TwoFactor code. if (!await UserManager.VerifyUserTwoFactorCodeAsync(TwoFactorComponentType.Transfer, user.Id, model.Data)) { ModelState.AddModelError("Data", "Invalid TwoFactor code."); return(View("CreateTransferModal", model)); } model.UserId = user.Id; model.ToUser = recipient.Id; model.TransferType = TransferType.User; var result = await TransferWriter.CreateTransfer(model); if (!ModelState.IsWriterResultValid(result)) { return(View("CreateTransferModal", model)); } return(ViewMessageModal(new ViewMessageModel(ViewMessageType.Success, "Transfer Success", "Your transfer request has been sucessfully processed."))); }
public async Task <IActionResult> Index(CreateTransferModel transfer) { _vaspSessionService.CreateSessionRequest( transfer.BeneficiaryName, transfer.OriginatorName, new PostalAddress( transfer.PostalAddressStreetName, transfer.PostalAddressBuildingNumber, transfer.PostalAddressAddressLine, transfer.PostalAddressPostCode, transfer.PostalAddressTownName, Country.List.Single(x => x.Value.Name == transfer.PostalAddressCountry).Value), new PlaceOfBirth(transfer.DateOfBirth, transfer.PostalAddressTownName, Country.List.Single(x => x.Value.Name == transfer.PostalAddressCountry).Value), transfer.AssetType, transfer.TransactionAmount); ModelState.Clear(); return(View()); }
public async Task <ActionResult> Donate(CreateTransferModel model) { if (model.TwoFactorType == TwoFactorType.None) { // If there is no tfa remove the Data field validation. ModelState.Remove("Data"); } if (!ModelState.IsValid) { return(View("DonateModal", model)); } var user = await UserManager.FindByIdAsync(User.Id()); if (user == null) { return(Unauthorized()); } // Verify TwoFactor code. if (!await UserManager.VerifyUserTwoFactorCodeAsync(TwoFactorComponentType.Transfer, user.Id, model.Data)) { ModelState.AddModelError("Data", "Invalid TwoFactor code."); return(View("DonateModal", model)); } model.UserId = user.Id; model.ToUser = Constants.SystemFaucetUserId; model.TransferType = TransferType.Faucet; var result = await TransferWriter.CreateTransfer(model); if (!ModelState.IsWriterResultValid(result)) { return(View("DonateModal", model)); } return(ViewMessageModal(new ViewMessageModel(ViewMessageType.Success, "Donation Success", "Your donation has been sucessfully processed."))); }
public async Task <CreateTransferResponseModel> CreateTransfer(string userId, CreateTransferModel model, bool isApi) { try { var estimatedPrice = await BalanceEstimationService.GetNZDPerCoin(model.CurrencyId).ConfigureAwait(false); var estimatedTotal = model.Amount * estimatedPrice; var verificationResult = await UserVerificationReader.GetVerificationStatus(userId); if (verificationResult.Level != VerificationLevel.Legacy && model.TransferType != TransferType.Paytopia && (verificationResult.Current + estimatedTotal) > verificationResult.Limit) { return new CreateTransferResponseModel { Error = $"Transfer exceeds daily limit of ${verificationResult.Limit:F2} NZD." } } ; using (var tradeService = CreateService()) { var response = await tradeService.SubmitTransferAsync(new SubmitTransferRequest { Amount = model.Amount, CurrencyId = model.CurrencyId, UserId = new Guid(userId), UserTo = new Guid(model.Receiver), TransferType = model.TransferType, EstimatedPrice = estimatedTotal, IsApi = isApi }).ConfigureAwait(false); return(new CreateTransferResponseModel { Error = response.Error, TransferId = response.TransferId, Notifications = await ProcessTransferNotifications(response), }); } } catch (Exception) { return(new CreateTransferResponseModel { Error = "An Error occurred placing transfer, if problem persist please contact Cryptopia Support" }); } }