public async Task <ActionResult> TransferMoney(TransferMoneyDialogViewModel vm) { var destinationaddress = _walletlist.Wallets.FirstOrDefault(w => w.Address == vm.SelectedWallet); if (!string.IsNullOrEmpty(vm.ManualWalletAddress)) { destinationaddress = new LykkePayWalletSettings() { Address = vm.ManualWalletAddress } } ; try { if (vm.SelectedPaymentRequests.Count == 0) { return(this.JsonFailResult("Error: needs to select payment request", ErrorMessageAnchor)); } var request = new BtcFreeTransferRequest(); request.DestAddress = destinationaddress.Address; var sources = new List <BtcTransferSourceInfo>(); foreach (var item in vm.SelectedPaymentRequests) { var sourceinfo = new BtcTransferSourceInfo(); sourceinfo.Address = item.PaymentRequest.WalletAddress; sourceinfo.Amount = Convert.ToDecimal(item.Amount); sources.Add(sourceinfo); } request.Sources = sources; await _payInternalClient.BtcFreeTransferAsync(request); return(this.JsonRequestResult("#transfersList", Url.Action("TransfersList"), new TransfersPageViewModel() { SelectedMerchant = vm.SelectedMerchant, SelectedAsset = "None" })); } catch (DefaultErrorResponseException ex) { if (ex.InnerException != null) { var content = JsonConvert.DeserializeObject <ErrorResponse>(((Refit.ApiException)ex.InnerException).Content); return(this.JsonFailResult(content.ErrorMessage, ErrorMessageAnchor)); } else { return(this.JsonFailResult(ex.Message, ErrorMessageAnchor)); } } }
public async Task <IActionResult> BtcFreeTransferAsync([FromBody] BtcFreeTransferRequest request) { try { string transactionId = await _btcTransferService.ExecuteAsync(Mapper.Map <BtcTransfer>(request)); return(Ok(new BtcTransferResponse { TransactionId = transactionId })); } catch (TransferException e) { _log.ErrorWithDetails(e, new { e.Code }); return(BadRequest(ErrorResponse.Create(e.Message))); } }
public async Task <IActionResult> BtcFreeTransferAsync([FromBody] BtcFreeTransferRequest request) { try { string transactionId = await _btcTransferService.ExecuteAsync(Mapper.Map <BtcTransfer>(request)); return(Ok(new BtcTransferResponse { TransactionId = transactionId })); } catch (Exception ex) { await _log.WriteErrorAsync(nameof(TransfersController), nameof(BtcFreeTransferAsync), ex); if (ex is TransferException btcException) { return(StatusCode((int)HttpStatusCode.InternalServerError, ErrorResponse.Create(btcException.Message))); } } return(StatusCode((int)HttpStatusCode.InternalServerError)); }
public Task <BtcTransferResponse> BtcFreeTransferAsync(BtcFreeTransferRequest request) { return(_runner.RunWithDefaultErrorHandlingAsync(() => _paymentRequestsApi.BtcFreeTransferAsync(request))); }