Beispiel #1
0
        public async Task <IActionResult> GetSettlementAssets()
        {
            try
            {
                AvailableAssetsResponse response =
                    await _payInternalClient.GetAvailableSettlementAssetsAsync(_headersHelper.MerchantId);

                return(Ok(Mapper.Map <AssetsResponseModel>(response)));
            }
            catch (Exception ex)
            {
                _log.Error(ex, null, $"request: {new {_headersHelper.MerchantId}.ToJson()}");
                throw;
            }
        }
Beispiel #2
0
        public async Task <IReadOnlyDictionary <string, string> > GetPaymentAssetsAsync(string merchantId, string settlementAssetId)
        {
            var result = new Dictionary <string, string>();

            try
            {
                AvailableAssetsResponse response =
                    await _payInternalClient.GetAvailablePaymentAssetsAsync(merchantId, settlementAssetId);

                foreach (string assetId in response.Assets)
                {
                    Asset asset = await _lykkeAssetsResolver.TryGetAssetAsync(assetId);

                    result.TryAdd(assetId, asset?.DisplayId ?? assetId);
                }
            }
            catch (Exception ex)
            {
                _log.ErrorWithDetails(ex, new { merchantId, settlementAssetId });
            }

            return(result);
        }
Beispiel #3
0
        public async Task <IActionResult> GetPaymentAssets(string settlementAssetId)
        {
            try
            {
                AvailableAssetsResponse response =
                    await _payInternalClient.GetAvailablePaymentAssetsAsync(_headersHelper.MerchantId,
                                                                            settlementAssetId);

                return(Ok(Mapper.Map <AssetsResponseModel>(response)));
            }
            catch (Exception ex)
            {
                _log.Error(ex, null, $@"request: {
                        new
                        {
                            _headersHelper.MerchantId,
                            settlementAssetId
                        }.ToJson()
                    }");

                if (ex is DefaultErrorResponseException clientEx)
                {
                    if (clientEx.StatusCode == HttpStatusCode.NotFound)
                    {
                        return(NotFound(clientEx.Error));
                    }

                    if (clientEx.StatusCode == HttpStatusCode.BadRequest)
                    {
                        return(BadRequest(clientEx.Error));
                    }
                }

                throw;
            }
        }