示例#1
0
        public async Task <IActionResult> SetAssetGeneralSettings([FromBody] UpdateAssetGeneralSettingsRequest request)
        {
            try
            {
                string lykkeAssetId = await _lykkeAssetsResolver.GetLykkeId(request.AssetDisplayId);

                Asset asset = await _assetsLocalCache.GetAssetByIdAsync(lykkeAssetId);

                if (asset == null)
                {
                    return(NotFound(ErrorResponse.Create($"Asset {request.AssetDisplayId} not found")));
                }

                await _assetSettingsService.SetGeneralAsync(Mapper.Map <AssetGeneralSettings>(request));

                return(NoContent());
            }
            catch (InvalidRowKeyValueException e)
            {
                _log.ErrorWithDetails(e, new
                {
                    e.Variable,
                    e.Value
                });

                return(NotFound(ErrorResponse.Create("Asset not found")));
            }
            catch (AssetUnknownException e)
            {
                _log.ErrorWithDetails(e, new { e.Asset });

                return(NotFound(ErrorResponse.Create($"Asset {e.Asset} can't be resolved")));
            }
        }
示例#2
0
        public async Task <IActionResult> CreateAsync([FromBody] CreateMerchantRequest request)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(new ErrorResponse().AddErrors(ModelState)));
            }

            try
            {
                var merchant = Mapper.Map <Merchant>(request);

                IMerchant createdMerchant = await _merchantService.CreateAsync(merchant);

                return(Ok(Mapper.Map <MerchantModel>(createdMerchant)));
            }
            catch (Exception exception) when(exception is DuplicateMerchantNameException ||
                                             exception is DuplicateMerchantApiKeyException)
            {
                await _log.WriteWarningAsync(nameof(MerchantsController), nameof(CreateAsync), request.ToJson(),
                                             exception);

                return(BadRequest(ErrorResponse.Create(exception.Message)));
            }
            catch (Exception exception)
            {
                await _log.WriteErrorAsync(nameof(MerchantsController), nameof(CreateAsync), request.ToJson(),
                                           exception);

                throw;
            }
        }
示例#3
0
        public async Task <IActionResult> GetForMerchant(string merchantId, string assetPairId)
        {
            IMerchant merchant = await _merchantService.GetAsync(merchantId);

            if (merchant == null)
            {
                return(NotFound(ErrorResponse.Create("Merchant not found")));
            }

            try
            {
                IMarkup markup = await _markupService.GetForMerchantAsync(merchantId, assetPairId);

                if (markup == null)
                {
                    return(NotFound(ErrorResponse.Create("Markup has not been set")));
                }

                return(Ok(Mapper.Map <MarkupResponse>(markup)));
            }
            catch (Exception ex)
            {
                await _log.WriteErrorAsync(nameof(MarkupsController), nameof(GetForMerchant), ex);

                throw;
            }
        }
示例#4
0
        public async Task <IActionResult> UpdateAsync([FromBody] UpdateMerchantRequest request)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(new ErrorResponse().AddErrors(ModelState)));
            }

            try
            {
                var merchant = Mapper.Map <Merchant>(request);

                await _merchantService.UpdateAsync(merchant);
            }
            catch (MerchantNotFoundException exception)
            {
                await _log.WriteWarningAsync(nameof(MerchantsController), nameof(UpdateAsync),
                                             request.ToJson(), exception.Message);

                return(NotFound(ErrorResponse.Create(exception.Message)));
            }
            catch (Exception exception)
            {
                await _log.WriteErrorAsync(nameof(MerchantsController), nameof(UpdateAsync), request.ToJson(), exception);

                throw;
            }

            return(NoContent());
        }
        public async Task <IActionResult> ResolveMarkupByMerchant(string merchantId, string assetPairId)
        {
            merchantId  = Uri.UnescapeDataString(merchantId);
            assetPairId = Uri.UnescapeDataString(assetPairId);

            try
            {
                IMarkup markup = await _markupService.ResolveAsync(merchantId, assetPairId);

                return(Ok(Mapper.Map <MarkupResponse>(markup)));
            }
            catch (InvalidRowKeyValueException e)
            {
                _log.ErrorWithDetails(e, new
                {
                    e.Variable,
                    e.Value
                });

                return(BadRequest(ErrorResponse.Create(e.Message)));
            }
            catch (MarkupNotFoundException e)
            {
                _log.ErrorWithDetails(e, new
                {
                    e.MerchantId,
                    e.AssetPairId
                });

                return(NotFound(ErrorResponse.Create(e.Message)));
            }
        }
示例#6
0
        public async Task <IActionResult> SetPublicKeyAsync(string merchantId, IFormFile file)
        {
            if (file == null || file.Length == 0)
            {
                return(BadRequest(ErrorResponse.Create("Empty file")));
            }

            try
            {
                var fileContent = await file.OpenReadStream().ToBytesAsync();

                string publicKey = Encoding.UTF8.GetString(fileContent, 0, fileContent.Length);

                await _merchantService.SetPublicKeyAsync(merchantId, publicKey);

                return(NoContent());
            }
            catch (MerchantNotFoundException exception)
            {
                await _log.WriteWarningAsync(nameof(MerchantsController), nameof(SetPublicKeyAsync),
                                             new { MerchantId = merchantId }.ToJson(), exception.Message);

                return(NotFound(ErrorResponse.Create(exception.Message)));
            }
            catch (Exception exception)
            {
                await _log.WriteErrorAsync(nameof(MerchantsController), nameof(SetPublicKeyAsync),
                                           new { MerchantId = merchantId }.ToJson(), exception);

                throw;
            }
        }
        public async Task <IActionResult> KycCompletedEvent([FromBody] TrackEventModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState.GetErrorMessage()));
            }

            if (!model.UserId.IsValidPartitionOrRowKey())
            {
                return(BadRequest(ErrorResponse.Create($"Invalid {nameof(model.UserId)} value")));
            }

            await _gaTrackerService.SendEventAsync(new TrackerInfo
            {
                UserId     = model.UserId,
                UserAgent  = model.UserAgent,
                ClientInfo = model.ClientInfo,
                Ip         = model.Ip,
                Cid        = model.Cid,
                Traffic    = model.Traffic
            },
                                                   TrackerCategories.Users, TrackerEvents.KycCompleted);

            return(Ok());
        }
示例#8
0
        public async Task <IActionResult> GetDetailsAsync(string merchantId, string paymentRequestId)
        {
            try
            {
                IPaymentRequest paymentRequest = await _paymentRequestService.GetAsync(merchantId, paymentRequestId);

                if (paymentRequest == null)
                {
                    return(NotFound(ErrorResponse.Create("Could not find payment request")));
                }

                PaymentRequestRefund refundInfo =
                    await _paymentRequestService.GetRefundInfoAsync(paymentRequest.WalletAddress);

                PaymentRequestDetailsModel model = await _paymentRequestDetailsBuilder.Build <
                    PaymentRequestDetailsModel,
                    PaymentRequestOrderModel,
                    PaymentRequestTransactionModel,
                    PaymentRequestRefundModel>(paymentRequest, refundInfo);

                return(Ok(model));
            }
            catch (Exception ex)
            {
                await _log.WriteErrorAsync(nameof(GetDetailsAsync),
                                           new
                {
                    MerchantId       = merchantId,
                    PaymentRequestId = paymentRequestId
                }.ToJson(), ex);

                throw;
            }
        }
        public async Task <IActionResult> TrackTrade([FromBody] TransactionModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState.GetErrorMessage()));
            }

            if (!model.UserId.IsValidPartitionOrRowKey())
            {
                return(BadRequest(ErrorResponse.Create($"Invalid {nameof(model.UserId)} value")));
            }

            await _gaTrackerService.SendTransactionAsync(new TransactionInfo {
                Id         = model.Id,
                UserId     = model.UserId,
                Amount     = model.Amount,
                AssetId    = model.AssetId,
                Name       = GaTransactionType.Trade,
                ClientInfo = model.ClientInfo,
                UserAgent  = model.UserAgent,
                Ip         = model.Ip
            });

            return(Ok());
        }
        public async Task <IActionResult> UserRegisteredEvent([FromBody] TrackEventModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ErrorResponse.Create(ModelState.GetErrorMessage())));
            }

            if (!model.UserId.IsValidPartitionOrRowKey())
            {
                return(BadRequest(ErrorResponse.Create($"Invalid {nameof(model.UserId)} value")));
            }

            if (!string.IsNullOrEmpty(model.Traffic))
            {
                var traffic = GaTraffic.Parse(model.UserId, model.Traffic);
                if (traffic != null)
                {
                    await _gaUserService.AddGaUserTrafficAsync(traffic);
                }
            }

            await _gaTrackerService.SendEventAsync(new TrackerInfo
            {
                UserId     = model.UserId,
                UserAgent  = model.UserAgent,
                ClientInfo = model.ClientInfo,
                Ip         = model.Ip,
                CreatedAt  = model.CreatedAt,
                Cid        = model.Cid,
                Traffic    = model.Traffic
            },
                                                   TrackerCategories.Users, TrackerEvents.UserRegistered);

            return(Ok());
        }
示例#11
0
        public async Task <IActionResult> GetForMerchant(string merchantId, string assetPairId)
        {
            merchantId  = Uri.UnescapeDataString(merchantId);
            assetPairId = Uri.UnescapeDataString(assetPairId);

            try
            {
                IMarkup markup = await _markupService.GetForMerchantAsync(merchantId, assetPairId);

                if (markup == null)
                {
                    return(NotFound(ErrorResponse.Create("Markup has not been set")));
                }

                return(Ok(Mapper.Map <MarkupResponse>(markup)));
            }
            catch (InvalidRowKeyValueException e)
            {
                _log.ErrorWithDetails(e, new
                {
                    e.Variable,
                    e.Value
                });

                return(NotFound(ErrorResponse.Create("Merchant or asset pair not found")));
            }
        }
示例#12
0
        public async Task <IActionResult> ResolveSettlementAssets(string merchantId)
        {
            IMerchant merchant = await _merchantService.GetAsync(merchantId);

            if (merchant == null)
            {
                return(NotFound(ErrorResponse.Create("Couldn't find merchant")));
            }

            try
            {
                IReadOnlyList <string> assets =
                    await _assetsAvailabilityService.ResolveSettlementAsync(merchantId);

                return(Ok(new AvailableAssetsResponseModel {
                    Assets = assets
                }));
            }
            catch (Exception ex)
            {
                await _log.WriteErrorAsync(nameof(MerchantsController), nameof(ResolveSettlementAssets), new
                {
                    merchantId
                }.ToJson(), ex);

                throw;
            }
        }
示例#13
0
        public async Task <IActionResult> SetDefault(string assetPairId, [FromBody] UpdateMarkupRequest request)
        {
            if (!string.IsNullOrEmpty(request.PriceAssetPairId))
            {
                AssetPair priceAssetPair = await _assetsLocalCache.GetAssetPairByIdAsync(request.PriceAssetPairId);

                if (priceAssetPair == null)
                {
                    return(NotFound(ErrorResponse.Create("Price asset pair doesn't exist")));
                }
            }

            try
            {
                await _markupService.SetDefaultAsync(Uri.UnescapeDataString(assetPairId), request.PriceAssetPairId,
                                                     request.PriceMethod, request);

                return(Ok());
            }
            catch (InvalidRowKeyValueException e)
            {
                _log.ErrorWithDetails(e, new
                {
                    e.Variable,
                    e.Value
                });

                return(NotFound(ErrorResponse.Create("Asset pair not found")));
            }
        }
示例#14
0
        public async Task <IActionResult> SetGeneralAssetsSettings([FromBody] UpdateAssetAvailabilityRequest request)
        {
            try
            {
                string lykkeAssetId = await _lykkeAssetsResolver.GetLykkeId(request.AssetId);

                Asset asset = await _assetsLocalCache.GetAssetByIdAsync(lykkeAssetId);

                if (asset == null)
                {
                    return(NotFound(ErrorResponse.Create($"Asset {request.AssetId} not found")));
                }

                await _assetsAvailabilityService.SetGeneralAsync(request.AssetId, request.AvailabilityType,
                                                                 request.Value);

                return(NoContent());
            }
            catch (AssetUnknownException assetEx)
            {
                await _log.WriteErrorAsync(nameof(AssetsController), nameof(SetGeneralAssetsSettings),
                                           new { assetEx.Asset }.ToJson(), assetEx);

                return(NotFound(ErrorResponse.Create($"Asset {assetEx.Asset} can't be resolved")));
            }
            catch (Exception ex)
            {
                await _log.WriteErrorAsync(nameof(AssetsController), nameof(SetGeneralAssetsSettings), ex);

                throw;
            }
        }
示例#15
0
        public async Task <IActionResult> SetForMerchant(string merchantId, string assetPairId,
                                                         [FromBody] UpdateMarkupRequest request)
        {
            IMerchant merchant = await _merchantService.GetAsync(merchantId);

            if (merchant == null)
            {
                return(NotFound(ErrorResponse.Create("Merchant not found")));
            }

            if (!string.IsNullOrEmpty(request.PriceAssetPairId))
            {
                AssetPair priceAssetPair = await _assetsLocalCache.GetAssetPairByIdAsync(request.PriceAssetPairId);

                if (priceAssetPair == null)
                {
                    return(NotFound(ErrorResponse.Create("Price asset pair doesn't exist")));
                }
            }

            try
            {
                await _markupService.SetForMerchantAsync(assetPairId, merchantId, request.PriceAssetPairId, request.PriceMethod, request);

                return(Ok());
            }
            catch (Exception ex)
            {
                await _log.WriteErrorAsync(nameof(MarkupsController), nameof(SetForMerchant), ex);

                throw;
            }
        }
示例#16
0
        public async Task <IActionResult> GetAsync(string merchantId, string paymentRequestId)
        {
            IPaymentRequest paymentRequest = await _paymentRequestService.GetAsync(merchantId, paymentRequestId);

            if (paymentRequest == null)
            {
                return(NotFound(ErrorResponse.Create("Couldn't find payment request")));
            }

            var model = Mapper.Map <PaymentRequestModel>(paymentRequest);

            return(Ok(model));
        }
示例#17
0
        public async Task <IActionResult> GetAsync(string merchantId)
        {
            IMerchant merchant = await _merchantService.GetAsync(merchantId);

            if (merchant == null)
            {
                return(NotFound(ErrorResponse.Create("Couldn't find merchant")));
            }

            var model = Mapper.Map <MerchantModel>(merchant);

            return(Ok(model));
        }
示例#18
0
        public async Task <IActionResult> GetByAddressAsync([Required, RowKey] string walletAddress)
        {
            IPaymentRequest paymentRequest = await _paymentRequestService.FindAsync(walletAddress);

            if (paymentRequest == null)
            {
                return(NotFound(ErrorResponse.Create("Couldn't find payment request by wallet address")));
            }

            var model = Mapper.Map <PaymentRequestModel>(paymentRequest);

            return(Ok(model));
        }
示例#19
0
        public async Task <IActionResult> ResolvePaymentAssets(string merchantId, [FromQuery] string settlementAssetId)
        {
            IMerchant merchant = await _merchantService.GetAsync(merchantId);

            if (merchant == null)
            {
                return(NotFound(ErrorResponse.Create("Couldn't find merchant")));
            }

            string lykkeAssetId = await _lykkeAssetsResolver.GetLykkeId(settlementAssetId);

            Asset asset = await _assetsLocalCache.GetAssetByIdAsync(lykkeAssetId);

            if (asset == null)
            {
                return(NotFound(ErrorResponse.Create("Couldn't find asset")));
            }

            try
            {
                IReadOnlyList <string> assets =
                    await _assetsAvailabilityService.ResolvePaymentAsync(merchantId, settlementAssetId);

                return(Ok(new AvailableAssetsResponseModel {
                    Assets = assets
                }));
            }
            catch (AssetUnknownException assetEx)
            {
                await _log.WriteErrorAsync(nameof(MerchantsController), nameof(ResolvePaymentAssets),
                                           new { assetEx.Asset }.ToJson(), assetEx);

                return(BadRequest(ErrorResponse.Create(assetEx.Message)));
            }
            catch (Exception ex)
            {
                await _log.WriteErrorAsync(nameof(MerchantsController), nameof(ResolvePaymentAssets), new
                {
                    merchantId,
                    settlementAssetId
                }.ToJson(), ex);

                throw;
            }
        }
示例#20
0
        public async Task <IActionResult> CreateAsync([FromBody] CreatePaymentRequestModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(new ErrorResponse().AddErrors(ModelState)));
            }

            try
            {
                IReadOnlyList <string> settlementAssets =
                    await _assetsAvailabilityService.ResolveSettlementAsync(model.MerchantId);

                if (!settlementAssets.Contains(model.SettlementAssetId))
                {
                    return(BadRequest(ErrorResponse.Create("Settlement asset is not available")));
                }

                IReadOnlyList <string> paymentAssets =
                    await _assetsAvailabilityService.ResolvePaymentAsync(model.MerchantId, model.SettlementAssetId);

                if (!paymentAssets.Contains(model.PaymentAssetId))
                {
                    return(BadRequest(ErrorResponse.Create("Payment asset is not available")));
                }

                var paymentRequest = Mapper.Map <PaymentRequest>(model);

                IPaymentRequest createdPaymentRequest = await _paymentRequestService.CreateAsync(paymentRequest);

                return(Ok(Mapper.Map <PaymentRequestModel>(createdPaymentRequest)));
            }
            catch (AssetUnknownException assetEx)
            {
                await _log.WriteErrorAsync(nameof(PaymentRequestsController), nameof(CreateAsync),
                                           new { assetEx.Asset }.ToJson(), assetEx);

                return(BadRequest(ErrorResponse.Create($"Asset {assetEx.Asset} can't be resolved")));
            }
            catch (Exception ex)
            {
                await _log.WriteErrorAsync(nameof(CreateAsync), model.ToJson(), ex);

                throw;
            }
        }
        public async Task <IActionResult> ResolvePaymentAssets(string merchantId, [FromQuery] string settlementAssetId)
        {
            merchantId = Uri.UnescapeDataString(merchantId);

            if (string.IsNullOrEmpty(settlementAssetId))
            {
                return(BadRequest(ErrorResponse.Create("Settlement asset id is invalid")));
            }

            try
            {
                string lykkeAssetId = await _lykkeAssetsResolver.GetLykkeId(settlementAssetId);

                Asset asset = await _assetsLocalCache.GetAssetByIdAsync(lykkeAssetId);

                if (asset == null)
                {
                    return(NotFound(ErrorResponse.Create("Couldn't find asset")));
                }

                IReadOnlyList <string> assets =
                    await _assetSettingsService.ResolvePaymentAsync(merchantId, settlementAssetId);

                return(Ok(new AvailableAssetsResponseModel {
                    Assets = assets
                }));
            }
            catch (InvalidRowKeyValueException e)
            {
                _log.ErrorWithDetails(e, new
                {
                    e.Variable,
                    e.Value
                });

                return(BadRequest(ErrorResponse.Create(e.Message)));
            }
            catch (AssetUnknownException e)
            {
                _log.ErrorWithDetails(e, new { e.Asset });

                return(BadRequest(ErrorResponse.Create(e.Message)));
            }
        }
示例#22
0
        public async Task <IActionResult> GetSettings()
        {
            var employeeId = User.GetEmployeeId();
            var merchantId = User.GetMerchantId();

            try
            {
                var merchant = await _payMerchantClient.Api.GetByIdAsync(merchantId);

                var publicKeyInfo = await _payAuthClient.GetPayAuthInformationAsync(merchantId);

                var baseAssetId = await _assetService.GetBaseAssetId(merchantId);

                var availableBaseAssets = (await _assetService.GetSettlementAssetsAsync(merchantId)).ToDictionary(_ => _.Key, _ => _.Value);

                // need to add base asset if not empty to the list of available assets
                if (!string.IsNullOrEmpty(baseAssetId) && !availableBaseAssets.ContainsKey(baseAssetId))
                {
                    Asset asset = await _lykkeAssetsResolver.TryGetAssetAsync(baseAssetId);

                    availableBaseAssets.TryAdd(baseAssetId, asset?.DisplayId ?? baseAssetId);
                }

                var settings = new SettingsResponse
                {
                    MerchantDisplayName = merchant.DisplayName,
                    EmployeeFullname    = User.GetName(),
                    EmployeeEmail       = User.GetEmail(),
                    AvailableBaseAssets = availableBaseAssets.Select(o => new AssetItemViewModel(o.Key, o.Value)).ToList().OrderBy(_ => _.Title),
                    BaseAssetId         = baseAssetId,
                    MerchantId          = merchantId,
                    MerchantApiKey      = merchant.ApiKey,
                    HasPublicKey        = !string.IsNullOrEmpty(publicKeyInfo.RsaPublicKey)
                };

                return(Ok(settings));
            }
            catch (Exception e)
            {
                _log.Error(e, new { employeeId, merchantId }.ToJson());

                return(BadRequest(ErrorResponse.Create(PayInvoicePortalApiErrorCodes.UnexpectedError)));
            }
        }
示例#23
0
        public async Task <IActionResult> GetDefault(string assetPairId)
        {
            try
            {
                IMarkup markup = await _markupService.GetDefaultAsync(assetPairId);

                if (markup == null)
                {
                    return(NotFound(ErrorResponse.Create("Default markup has not been set")));
                }

                return(Ok(Mapper.Map <MarkupResponse>(markup)));
            }
            catch (Exception ex)
            {
                await _log.WriteErrorAsync(nameof(MarkupsController), nameof(GetDefault), ex);

                throw;
            }
        }
示例#24
0
        public async Task <IActionResult> CancelAsync(
            [Required, RowKey] string merchantId,
            [Required, RowKey] string paymentRequestId)
        {
            try
            {
                await _paymentRequestService.CancelAsync(merchantId, paymentRequestId);

                return(NoContent());
            }
            catch (Exception e)
            {
                _log.ErrorWithDetails(e, new
                {
                    merchantId,
                    paymentRequestId
                });

                if (e is PaymentRequestNotFoundException notFoundEx)
                {
                    _log.ErrorWithDetails(notFoundEx, new
                    {
                        notFoundEx.WalletAddress,
                        notFoundEx.MerchantId,
                        notFoundEx.PaymentRequestId
                    });

                    return(NotFound(ErrorResponse.Create(notFoundEx.Message)));
                }

                if (e is NotAllowedStatusException notAllowedEx)
                {
                    _log.ErrorWithDetails(notAllowedEx,
                                          new { status = notAllowedEx.Status.ToString() });

                    return(BadRequest(ErrorResponse.Create(notAllowedEx.Message)));
                }

                throw;
            }
        }
示例#25
0
        public async Task <IActionResult> SetBaseAsset([FromBody] SetBaseAssetModel model)
        {
            var merchantId = User.GetMerchantId();

            try
            {
                await _payInvoiceClient.SetMerchantSettingAsync(new MerchantSetting
                {
                    MerchantId = merchantId,
                    BaseAsset  = model.BaseAssetId
                });

                return(Ok());
            }
            catch (Exception e)
            {
                _log.Error(e, new { merchantId, model.BaseAssetId }.ToJson());

                return(BadRequest(ErrorResponse.Create(PayInvoicePortalApiErrorCodes.UnexpectedError)));
            }
        }
示例#26
0
        public async Task <IActionResult> GetAllForMerchant(string merchantId)
        {
            merchantId = Uri.UnescapeDataString(merchantId);

            try
            {
                IReadOnlyList <IMarkup> markups = await _markupService.GetForMerchantAsync(merchantId);

                return(Ok(Mapper.Map <IEnumerable <MarkupResponse> >(markups)));
            }
            catch (InvalidRowKeyValueException e)
            {
                _log.ErrorWithDetails(e, new
                {
                    e.Variable,
                    e.Value
                });

                return(NotFound(ErrorResponse.Create("Merchant not found")));
            }
        }
示例#27
0
        public async Task <IActionResult> GetAllForMerchant(string merchantId)
        {
            IMerchant merchant = await _merchantService.GetAsync(merchantId);

            if (merchant == null)
            {
                return(NotFound(ErrorResponse.Create("Merchant not found")));
            }

            try
            {
                IReadOnlyList <IMarkup> markups = await _markupService.GetForMerchantAsync(merchantId);

                return(Ok(Mapper.Map <IEnumerable <MarkupResponse> >(markups)));
            }
            catch (Exception ex)
            {
                await _log.WriteErrorAsync(nameof(MarkupsController), nameof(GetAllForMerchant), ex);

                throw;
            }
        }
示例#28
0
        public async Task <IActionResult> SetAssetMerchantSettings(
            [FromBody] UpdateAssetMerchantSettingsRequest settingsRequest)
        {
            try
            {
                await _assetSettingsService.SetByMerchantAsync(settingsRequest.MerchantId,
                                                               settingsRequest.PaymentAssets,
                                                               settingsRequest.SettlementAssets);

                return(NoContent());
            }
            catch (InvalidRowKeyValueException e)
            {
                _log.ErrorWithDetails(e, new
                {
                    e.Variable,
                    e.Value
                });

                return(NotFound(ErrorResponse.Create("Merchant not found")));
            }
        }
示例#29
0
        public async Task <IActionResult> GetAssetsPersonalSettings([FromQuery] string merchantId)
        {
            IMerchant merchant = await _merchantService.GetAsync(merchantId);

            if (merchant == null)
            {
                return(NotFound(ErrorResponse.Create("Couldn't find merchant")));
            }

            try
            {
                IAssetAvailabilityByMerchant personal = await _assetsAvailabilityService.GetPersonalAsync(merchantId);

                return(Ok(Mapper.Map <AssetAvailabilityByMerchantResponse>(personal)));
            }
            catch (Exception ex)
            {
                await _log.WriteErrorAsync(nameof(AssetsController), nameof(GetAssetsPersonalSettings), ex);

                throw;
            }
        }
示例#30
0
        public async Task <IActionResult> GetDetailsAsync(
            [Required, RowKey] string merchantId,
            [Required, RowKey] string paymentRequestId)
        {
            IPaymentRequest paymentRequest = await _paymentRequestService.GetAsync(merchantId, paymentRequestId);

            if (paymentRequest == null)
            {
                return(NotFound(ErrorResponse.Create("Could not find payment request")));
            }

            PaymentRequestRefund refundInfo =
                await _paymentRequestService.GetRefundInfoAsync(paymentRequest.WalletAddress);

            PaymentRequestDetailsModel model = await _paymentRequestDetailsBuilder.Build <
                PaymentRequestDetailsModel,
                PaymentRequestOrderModel,
                PaymentRequestTransactionModel,
                PaymentRequestRefundModel>(paymentRequest, refundInfo);

            return(Ok(model));
        }