Ejemplo n.º 1
0
 public CashoutService(
     [NotNull] IAssetSettingsService assetSettingsService,
     [NotNull] IBcnSettingsResolver bcnSettingsResolver,
     [NotNull] ITransferService transferService,
     [NotNull] ITransactionsService transactionsService,
     [NotNull] IMerchantWalletService merchantWalletService,
     [NotNull] IWalletBalanceValidator walletBalanceValidator,
     [NotNull] IWalletHistoryService walletHistoryService,
     [NotNull] RetryPolicySettings retryPolicySettings,
     [NotNull] ILogFactory logFactory)
 {
     _assetSettingsService   = assetSettingsService ?? throw new ArgumentNullException(nameof(assetSettingsService));
     _bcnSettingsResolver    = bcnSettingsResolver ?? throw new ArgumentNullException(nameof(bcnSettingsResolver));
     _transferService        = transferService ?? throw new ArgumentNullException(nameof(transferService));
     _transactionsService    = transactionsService ?? throw new ArgumentNullException(nameof(transactionsService));
     _merchantWalletService  = merchantWalletService ?? throw new ArgumentNullException(nameof(merchantWalletService));
     _walletBalanceValidator = walletBalanceValidator ?? throw new ArgumentNullException(nameof(walletBalanceValidator));
     _walletHistoryService   = walletHistoryService ?? throw new ArgumentNullException(nameof(walletHistoryService));
     _log         = logFactory.CreateLog(this);
     _retryPolicy = Policy
                    .Handle <InsufficientFundsException>()
                    .Or <CashoutOperationFailedException>()
                    .Or <CashoutOperationPartiallyFailedException>()
                    .WaitAndRetryAsync(
         retryPolicySettings.DefaultAttempts,
         attempt => TimeSpan.FromSeconds(Math.Pow(2, attempt)),
         (ex, timespan) => _log.Error(ex, "Cashout with retry"));
 }
Ejemplo n.º 2
0
 public TransactionsManager(
     [NotNull] ITransactionsService transactionsService,
     [NotNull] IPaymentRequestService paymentRequestService,
     [NotNull] ILogFactory logFactory,
     [NotNull] IWalletHistoryService walletHistoryService,
     int transactionConfirmationCount,
     [NotNull] IConfirmationsService confirmationsService,
     [NotNull] IBcnWalletUsageService bcnWalletUsageService)
 {
     _transactionsService          = transactionsService ?? throw new ArgumentNullException(nameof(transactionsService));
     _paymentRequestService        = paymentRequestService ?? throw new ArgumentNullException(nameof(paymentRequestService));
     _walletHistoryService         = walletHistoryService ?? throw new ArgumentNullException(nameof(walletHistoryService));
     _transactionConfirmationCount = transactionConfirmationCount;
     _confirmationsService         = confirmationsService ?? throw new ArgumentNullException(nameof(confirmationsService));
     _bcnWalletUsageService        = bcnWalletUsageService ?? throw new ArgumentNullException(nameof(bcnWalletUsageService));
     _log = logFactory.CreateLog(this);
 }