Exemple #1
0
 public AutofacModule(
     ExpirationPeriodsSettings expirationPeriods,
     int transactionConfirmationCount,
     IList <BlockchainWalletAllocationPolicy> walletAllocationSettings)
 {
     _expirationPeriods            = expirationPeriods;
     _transactionConfirmationCount = transactionConfirmationCount;
     _walletAllocationSettings     = walletAllocationSettings;
 }
 public BtcTransferService(IBitcoinApiClient bitcoinServiceClient,
                           ITransferRepository transferRepository,
                           ITransactionsService transactionServicey,
                           ITransactionPublisher transactionPublisher,
                           ExpirationPeriodsSettings expirationPeriods)
 {
     _bitcoinServiceClient =
         bitcoinServiceClient ?? throw new ArgumentNullException(nameof(bitcoinServiceClient));
 }
Exemple #3
0
        public PaymentRequestService(
            [NotNull] IPaymentRequestRepository paymentRequestRepository,
            [NotNull] IOrderService orderService,
            [NotNull] IPaymentRequestPublisher paymentRequestPublisher,
            [NotNull] ITransferService transferService,
            [NotNull] IPaymentRequestStatusResolver paymentRequestStatusResolver,
            [NotNull] ILogFactory logFactory,
            [NotNull] IWalletManager walletsManager,
            [NotNull] ITransactionsService transactionsService,
            [NotNull] ExpirationPeriodsSettings expirationPeriods,
            [NotNull] IMerchantWalletService merchantWalletService,
            [NotNull] IDistributedLocksService paymentLocksService,
            [NotNull] ITransactionPublisher transactionPublisher,
            [NotNull] IDistributedLocksService checkoutLocksService,
            [NotNull] IWalletBalanceValidator walletBalanceValidator,
            [NotNull] RetryPolicySettings retryPolicySettings,
            [NotNull] IAutoSettleSettingsResolver autoSettleSettingsResolver,
            [NotNull] IAssetSettingsService assetSettingsService)
        {
            _paymentRequestRepository     = paymentRequestRepository ?? throw new ArgumentNullException(nameof(paymentRequestRepository));
            _orderService                 = orderService ?? throw new ArgumentNullException(nameof(orderService));
            _paymentRequestPublisher      = paymentRequestPublisher ?? throw new ArgumentNullException(nameof(paymentRequestPublisher));
            _transferService              = transferService ?? throw new ArgumentNullException(nameof(transferService));
            _paymentRequestStatusResolver = paymentRequestStatusResolver ?? throw new ArgumentNullException(nameof(paymentRequestStatusResolver));
            _log                        = logFactory.CreateLog(this);
            _walletsManager             = walletsManager ?? throw new ArgumentNullException(nameof(walletsManager));
            _transactionsService        = transactionsService ?? throw new ArgumentNullException(nameof(transactionsService));
            _expirationPeriods          = expirationPeriods ?? throw new ArgumentNullException(nameof(expirationPeriods));
            _merchantWalletService      = merchantWalletService ?? throw new ArgumentNullException(nameof(merchantWalletService));
            _paymentLocksService        = paymentLocksService ?? throw new ArgumentNullException(nameof(paymentLocksService));
            _transactionPublisher       = transactionPublisher ?? throw new ArgumentNullException(nameof(transactionPublisher));
            _checkoutLocksService       = checkoutLocksService ?? throw new ArgumentNullException(nameof(checkoutLocksService));
            _walletBalanceValidator     = walletBalanceValidator ?? throw new ArgumentNullException(nameof(walletBalanceValidator));
            _autoSettleSettingsResolver = autoSettleSettingsResolver ?? throw new ArgumentNullException(nameof(autoSettleSettingsResolver));
            _assetSettingsService       = assetSettingsService ?? throw new ArgumentNullException(nameof(assetSettingsService));

            _settlementRetryPolicy = Policy
                                     .Handle <InsufficientFundsException>()
                                     .Or <SettlementOperationFailedException>()
                                     .Or <SettlementOperationPartiallyFailedException>()
                                     .WaitAndRetryAsync(
                retryPolicySettings.SettlementAttempts,
                attempt => TimeSpan.FromSeconds(Math.Pow(2, attempt)),
                (ex, timespan) => _log.Error(ex, "Settlement with retry"));

            _paymentRetryPolicy = Policy
                                  .Handle <InsufficientFundsException>()
                                  .Or <PaymentOperationFailedException>()
                                  .Or <PaymentOperationPartiallyFailedException>()
                                  .WaitAndRetryAsync(
                retryPolicySettings.DefaultAttempts,
                attempt => TimeSpan.FromSeconds(Math.Pow(2, attempt)),
                (ex, timespan) => _log.Error(ex, "Payment with retry"));
        }
 public AutofacModule(
     [NotNull] ExpirationPeriodsSettings expirationPeriods,
     int transactionConfirmationCount,
     [NotNull] IList <BlockchainWalletAllocationPolicy> walletAllocationSettings,
     [NotNull] IReadOnlyList <AssetPairSetting> assetPairLocalStorageSettings,
     [NotNull] CacheSettings cacheSettings,
     [NotNull] RetryPolicySettings retryPolicySettings)
 {
     _expirationPeriods             = expirationPeriods ?? throw new ArgumentNullException(nameof(expirationPeriods));
     _transactionConfirmationCount  = transactionConfirmationCount;
     _walletAllocationSettings      = walletAllocationSettings ?? throw new ArgumentNullException(nameof(walletAllocationSettings));
     _assetPairLocalStorageSettings = assetPairLocalStorageSettings ?? throw new ArgumentNullException(nameof(assetPairLocalStorageSettings));
     _cacheSettings       = cacheSettings ?? throw new ArgumentNullException(nameof(cacheSettings));
     _retryPolicySettings = retryPolicySettings ?? throw new ArgumentNullException(nameof(retryPolicySettings));
 }
Exemple #5
0
 public PaymentRequestService(
     IPaymentRequestRepository paymentRequestRepository,
     IOrderService orderService,
     IPaymentRequestPublisher paymentRequestPublisher,
     ITransferService transferService,
     IPaymentRequestStatusResolver paymentRequestStatusResolver,
     ILog log,
     IWalletManager walletsManager,
     ITransactionsService transactionsService,
     ExpirationPeriodsSettings expirationPeriods)
 {
     _paymentRequestRepository     = paymentRequestRepository;
     _orderService                 = orderService;
     _paymentRequestPublisher      = paymentRequestPublisher;
     _transferService              = transferService;
     _paymentRequestStatusResolver = paymentRequestStatusResolver;
     _log                 = log;
     _walletsManager      = walletsManager;
     _transactionsService = transactionsService;
     _expirationPeriods   = expirationPeriods;
 }
        public AssetsLocalCache(
            [NotNull] ILogFactory logFactory,
            [NotNull] IAssetsService assetsService,
            [NotNull] RetryPolicySettings retryPolicySettings,
            [NotNull] ExpirationPeriodsSettings expirationPeriodsSettings)
        {
            ILog log = logFactory.CreateLog(this);

            _assetsCache = new CachedDataDictionary <string, Asset>
                           (
                async() =>
            {
                IList <Asset> assets = await Policy
                                       .Handle <Exception>()
                                       .WaitAndRetryAsync(
                    retryPolicySettings.DefaultAttempts,
                    attempt => TimeSpan.FromSeconds(Math.Pow(2, attempt)),
                    (ex, timestamp) => log.Error("Getting assets dictionary with retry", ex))
                                       .ExecuteAsync(() => assetsService.AssetGetAllAsync(true));

                return(assets.ToDictionary(itm => itm.Id));
            }, expirationPeriodsSettings.AssetsCache);

            _assetPairsCache = new CachedDataDictionary <string, AssetPair>(
                async() =>
            {
                IList <AssetPair> assetPairs = await Policy
                                               .Handle <Exception>()
                                               .WaitAndRetryAsync(
                    retryPolicySettings.DefaultAttempts,
                    attempt => TimeSpan.FromSeconds(Math.Pow(2, attempt)),
                    (ex, timestamp) => log.Error("Getting asset pairs dictionary with retry", ex))
                                               .ExecuteAsync(() => assetsService.AssetPairGetAllAsync());

                return(assetPairs.ToDictionary(itm => itm.Id));
            }, expirationPeriodsSettings.AssetsCache);
        }