public async Task <IActionResult> Get(string clientId) { var depositViaCreditCardBlocked = (await _clientAccount.GetDepositBlockAsync(clientId)).DepositViaCreditCardBlocked; var isOnMaintenance = await _appGlobalSettingsService.IsOnMaintenanceAsync(); var result = new PaymentMethodsResponse { PaymentMethods = new[] { new PaymentMethod { Name = CashInPaymentSystem.Fxpaygate.ToString(), Assets = _paymentSettings.Fxpaygate.SupportedCurrencies, Available = !depositViaCreditCardBlocked && !isOnMaintenance }, new PaymentMethod { Name = CashInPaymentSystem.CreditVoucher.ToString(), Assets = _paymentSettings.CreditVouchers.SupportedCurrencies, Available = !isOnMaintenance } } }; return(Ok(result)); }
public void DeserializePaymentMethodsTest() { DotNetXmlDeserializer deserializer = new DotNetXmlDeserializer(); RestResponse restResponse = new RestResponse(); restResponse.Content = @"<paymentMethodsResponse> <code>SUCCESS</code> <paymentMethods> <paymentMethodComplete> <id>193</id> <description>COBRO_EXPRESS</description> <country>AR</country> </paymentMethodComplete> <paymentMethodComplete> <id>254</id> <description>PSE</description> <country>CO</country> </paymentMethodComplete> <paymentMethodComplete> <id>139</id> <description>AMEX</description> <country>MX</country> </paymentMethodComplete> <paymentMethodComplete> <id>250</id> <description>VISA</description> <country>CO</country> </paymentMethodComplete> </paymentMethods> </paymentMethodsResponse>"; PaymentMethodsResponse response = deserializer.Deserialize <PaymentMethodsResponse>(restResponse); Assert.AreEqual(ResponseCode.SUCCESS, response.ResponseCode); Assert.AreEqual(4, response.PaymentMethods.Count); Assert.AreEqual("193", response.PaymentMethods[0].Id); Assert.AreEqual("COBRO_EXPRESS", response.PaymentMethods[0].Description); Assert.AreEqual(PaymentCountry.AR.ToString(), response.PaymentMethods[0].Country); Assert.AreEqual("254", response.PaymentMethods[1].Id); Assert.AreEqual("PSE", response.PaymentMethods[1].Description); Assert.AreEqual(PaymentCountry.CO.ToString(), response.PaymentMethods[1].Country); Assert.AreEqual("139", response.PaymentMethods[2].Id); Assert.AreEqual("AMEX", response.PaymentMethods[2].Description); Assert.AreEqual(PaymentCountry.MX.ToString(), response.PaymentMethods[2].Country); Assert.AreEqual("250", response.PaymentMethods[3].Id); Assert.AreEqual("VISA", response.PaymentMethods[3].Description); Assert.AreEqual(PaymentCountry.CO.ToString(), response.PaymentMethods[3].Country); }
public async Task <PaymentMethodsResult> GetPaymentMethods() { JObject @params = new JObject() { new JProperty("params", new JObject() { new JProperty("auth", new JObject() { new JProperty("token", Settings.CurrentHost.Token) }) }) }; PaymentMethodsResponse response = await restClient.PostAsync <PaymentMethodsResponse, JObject>(Settings.CurrentHost.Url + Constants.ApiURI.URI_GET_PAYMENT_METHODS, @params); return(response?.Result); }
public async Task <IActionResult> Get() { var clientId = _requestContext.ClientId; var partnerId = _requestContext.PartnerId; var supportedCurrenciesTask = _link4PayServiceClient.GetSupportedCurrenciesAsync(new Empty()).ResponseAsync; var allAssetsTask = _assetsHelper.GetAllAssetsAsync(); var assetsAvailableToClientTask = _assetsHelper.GetSetOfAssetsAvailableToClientAsync(clientId, partnerId, true); var depositBlockedTask = _clientAccountClient.ClientSettings.GetDepositBlockSettingsAsync(clientId); await Task.WhenAll(supportedCurrenciesTask, allAssetsTask, assetsAvailableToClientTask, depositBlockedTask); IReadOnlyCollection <IAsset> allAssts = allAssetsTask.Result; HashSet <string> assetsAvailableToClient = assetsAvailableToClientTask.Result; var result = new PaymentMethodsResponse { PaymentMethods = new List <PaymentMethod> { //TODO: remove after web wallet release new PaymentMethod { Name = "Fxpaygate", Available = !depositBlockedTask.Result.DepositViaCreditCardBlocked, Assets = supportedCurrenciesTask.Result.Currencies }, new PaymentMethod { Name = "Link4Pay", Available = !depositBlockedTask.Result.DepositViaCreditCardBlocked, Assets = supportedCurrenciesTask.Result.Currencies }, new PaymentMethod { Name = "Cryptos", Available = true, Assets = allAssts .Where(x => x.BlockchainDepositEnabled) .Select(x => x.Id) .ToList() }, new PaymentMethod { Name = "Swift", Available = true, Assets = allAssts .Where(x => x.SwiftDepositEnabled) .Select(x => x.Id) .ToList() } } }; var model = new PaymentMethodsResponse { PaymentMethods = new List <PaymentMethod>() }; foreach (var method in result.PaymentMethods) { var availableToClient = method.Assets.Where(assetsAvailableToClient.Contains).ToList(); if (availableToClient.Any()) { model.PaymentMethods.Add(new PaymentMethod { Assets = availableToClient, Available = method.Available, Name = method.Name }); } } return(Ok(model)); }