public OrdersController(IPaymentServiceClient client)
 {
     _client         = client;
     _orderGenerator = new Fixture();
     _orderGenerator.Customize <Order>(
         c => c.With(
             x => x.Items, _orderGenerator.CreateMany <string>(new Random().Next(5)).ToList()));
 }
Beispiel #2
0
 public void ClearPaymentSettingsFromCache()
 {
     // this forces the payment settings to be refreshed at the next call
     // since we can't them at the same time as the standard settings because we could be not authenticated
     _cachedSettings = null;
     _client         = null;
     _cache.Clear(PaymentSettingsCacheKey);
 }
 public OrderStateOrchestrator(IPaymentServiceClient paymentServiceClient,
                               IDistributedLockManager distributedLockManager,
                               IOrderStateMachineFactory orderStateMachineFactory,
                               IShipmentServiceClient shipmentServiceClient)
 {
     _distributedLockManager   = distributedLockManager;
     _orderStateMachineFactory = orderStateMachineFactory;
     _shipmentServiceClient    = shipmentServiceClient;
     _paymentServiceClient     = paymentServiceClient;
 }
Beispiel #4
0
        private async Task RefreshPaymentSettings()
        {
            try
            {
                _cachedSettings = await Mvx.Resolve <ConfigurationClientService>().GetPaymentSettings().ConfigureAwait(false);

                _cache.Set(PaymentSettingsCacheKey, _cachedSettings);
                _client = GetClient(_cachedSettings);
            }
            catch (Exception)
            {
                throw;
            }
        }
Beispiel #5
0
        public async Task <ClientPaymentSettings> GetPaymentSettings(bool cleanCache = false)
        {
            _cachedSettings = _cache.Get <ClientPaymentSettings>(PaymentSettingsCacheKey);

            if (_cachedSettings == null || cleanCache)
            {
                await RefreshPaymentSettings();

                _client = GetClient(_cachedSettings);

                return(_cachedSettings);
            }
            // set client with cached settings for now
            _client = GetClient(_cachedSettings);

            // Update cache...
            Task.Run(() => RefreshPaymentSettings()).FireAndForget();

            // ... and return current settings
            return(_cachedSettings);
        }
Beispiel #6
0
 public AccountServiceClient(string url, string sessionId, IPackageInfo packageInfo, IConnectivityService connectivityService, ILogger logger, IPaymentServiceClient tokenizationService = null)
     : base(url, sessionId, packageInfo, connectivityService, logger)
 {
     _paymentService = tokenizationService;
 }