Ejemplo n.º 1
0
        public async Task <IActionResult> SetBaseAssetAsync([FromBody] UpdateBaseAssetRequest model)
        {
            try
            {
                MerchantSetting merchantSettings = await _merchantSettingService.GetByIdAsync(model.MerchantId);

                merchantSettings.BaseAsset = model.BaseAsset;

                await _merchantSettingService.SetAsync(merchantSettings);

                return(Ok());
            }
            catch (MerchantSettingNotFoundException ex)
            {
                _log.WarningWithDetails(ex.Message, model);

                return(NotFound(ErrorResponse.Create(ex.Message)));
            }
            catch (AssetNotAvailableForMerchantException ex)
            {
                _log.WarningWithDetails(ex.Message, model);

                return(BadRequest(ErrorResponse.Create(ex.Message)));
            }
        }
        public async Task <ActionResult> AddOrEditMerchantSetting(AddOrEditMerchantSettingDialog vm)
        {
            if (string.IsNullOrEmpty(vm.BaseAsset))
            {
                return(this.JsonFailResult("BaseAsset required", ErrorMessageAnchor));
            }
            var setting = new MerchantSetting();

            setting.MerchantId = vm.MerchantId;
            setting.BaseAsset  = vm.BaseAsset;
            try
            {
                await _payInvoiceClient.SetMerchantSettingAsync(setting);
            }
            catch (Lykke.Service.PayInvoice.Client.ErrorResponseException ex)
            {
                return(this.JsonFailResult(ex.Error.ErrorMessage, ErrorMessageAnchor));
            }

            return(this.JsonRequestResult("#merchantsSettingsList", Url.Action("MerchantsSettingsList"),
                                          new MerchantSettingsListViewModel()
            {
                SelectedMerchant = vm.MerchantId
            }));
        }
Ejemplo n.º 3
0
        public async Task <MerchantSetting> SetAsync(MerchantSetting merchantSetting)
        {
            var entity = new MerchantSettingEntity(GetPartitionKey(merchantSetting.MerchantId), GetRowKey(merchantSetting.MerchantId));

            Mapper.Map(merchantSetting, entity);

            await _storage.InsertOrMergeAsync(entity);

            return(merchantSetting);
        }
Ejemplo n.º 4
0
        public async Task <IActionResult> GetByIdAsync([Required][RowKey] string merchantId)
        {
            try
            {
                MerchantSetting merchantSettings = await _merchantSettingService.GetByIdAsync(merchantId);

                return(Ok(merchantSettings));
            }
            catch (MerchantSettingNotFoundException ex)
            {
                _log.WarningWithDetails(ex.Message, new { merchantId });

                return(NotFound(ErrorResponse.Create(ex.Message)));
            }
        }
        public async Task <MerchantSetting> SetAsync(MerchantSetting model)
        {
            try
            {
                await _payMerchantClient.Api.GetByIdAsync(model.MerchantId);
            }
            catch (ClientApiException ex) when(ex.HttpStatusCode == HttpStatusCode.NotFound)
            {
                throw new MerchantNotFoundException(model.MerchantId);
            }

            await ValidateAssetAsync(model.MerchantId, model.BaseAsset);

            await _merchantSettingRepository.SetAsync(model);

            _log.Info("Merchant settings updated.", model);

            return(model);
        }
Ejemplo n.º 6
0
        public async Task <IActionResult> SetAsync([FromBody] SetMerchantSettingModel model)
        {
            try
            {
                var merchantSettingModel = Mapper.Map <MerchantSetting>(model);

                MerchantSetting merchantSetting = await _merchantSettingService.SetAsync(merchantSettingModel);

                return(Ok(merchantSetting));
            }
            catch (MerchantNotFoundException ex)
            {
                _log.WarningWithDetails(ex.Message, new { ex.MerchantId });

                return(NotFound(ErrorResponse.Create(ex.Message)));
            }
            catch (AssetNotAvailableForMerchantException ex)
            {
                _log.WarningWithDetails(ex.Message, model);

                return(BadRequest(ErrorResponse.Create(ex.Message)));
            }
        }
 public MerchantConfigRepository(IOptions <MerchantSetting> options, CheckoutPaymentGatewayAPIContext context)
 {
     _merchantSetting = options.Value;
     _context         = context;
 }
 public async Task <MerchantSetting> SetMerchantSettingAsync(MerchantSetting model)
 {
     return(await _runner.RunAsync(() => _merchantSettingsApi.SetAsync(model)));
 }