public async Task <TransferToExternalResultModel> TransferAsync(string customerId, string amount) { if (string.IsNullOrEmpty(customerId)) { throw new ArgumentNullException(nameof(customerId)); } if (string.IsNullOrEmpty(amount)) { throw new ArgumentNullException(nameof(amount)); } if (!Money18.TryParse(amount, out var amount18)) { throw new FormatException("Amount is in wrong format"); } var response = await _ccTransfersClient.Api.TransferToExternalAsync( new TransferToExternalRequest { CustomerId = customerId, Amount = amount18 }); if (response.Error != TransferToExternalErrorCodes.None) { _log.Warning("Couldn't transfer to external wallet", context: new { customerId, amount, error = response.Error.ToString() }); } return(_mapper.Map <TransferToExternalResultModel>(response)); }
public async Task <Money18> GetNextWalletLinkingFeeAsync(Guid customerId) { if (customerId == Guid.Empty) { throw new ArgumentNullException(nameof(customerId)); } var counter = await _counterRepository.GetAsync(customerId.ToString()); var fee = await _configurationItemsRepository.GetAsync((counter?.ApprovalsCounter ?? 0) < 1 ?ConfigurationItemType.FirstTimeLinkingFee : ConfigurationItemType.SubsequentLinkingFee); if (fee == null) { _log.Warning("Wallet linking fee has not been set, please use API to update it"); return(0); } if (!Money18.TryParse(fee.Value, out var result)) { _log.Error(message: "Couldn't parse Money18 from configuration value", context: new { fee = fee.Value }); return(0); } return(result); }
public BaseConversionRateRequestValidator() { RuleFor(r => r.Amount) .NotNull() .NotEmpty() .Must(r => r != null && Money18.TryParse(r, out var money18) && money18 > 0) .WithMessage("Amount should be valid number greater than 0."); }
public DemoModeService( IRabbitPublisher <EmailCodeVerifiedEvent> emailCodeVerifiedPublisher, ICustomerProfileClient customerProfileClient, IPartnersIntegrationClient partnersIntegrationClient, IPartnerManagementClient partnerManagementClient, PaymentRequestModelSettings paymentRequestSettings, ICustomerManagementServiceClient customerManagementServiceClient, string demoModeEmailSuffix, ILogFactory logFactory) { if (paymentRequestSettings.FiatAmount.HasValue && !string.IsNullOrWhiteSpace(paymentRequestSettings.TokensAmount)) { throw new ArgumentException("Cannot have both FiatAmount and TokensAmount set"); } if (!paymentRequestSettings.FiatAmount.HasValue && string.IsNullOrWhiteSpace(paymentRequestSettings.TokensAmount)) { throw new ArgumentException("FiatAmount or TokensAmount required"); } _emailCodeVerifiedPublisher = emailCodeVerifiedPublisher; _customerProfileClient = customerProfileClient; _partnersIntegrationClient = partnersIntegrationClient; _partnerManagementClient = partnerManagementClient; _paymentRequestSettings = paymentRequestSettings; _customerManagementServiceClient = customerManagementServiceClient; _demoModeEmailSuffix = demoModeEmailSuffix; _log = logFactory.CreateLog(this); if (!string.IsNullOrWhiteSpace(paymentRequestSettings.TokensAmount)) { var tokensAmountCorrect = Money18.TryParse(paymentRequestSettings.TokensAmount, out _tokensAmount); if (!tokensAmountCorrect) { throw new ArgumentException("Invalid value for TokensAmount", nameof(paymentRequestSettings.TokensAmount)); } } }