Пример #1
0
        /// <summary>
        /// Create a new payment processor to handle a single automated payment.
        /// </summary>
        /// <param name="currentPersonAliasId">The current user's person alias ID. Possibly the REST user.</param>
        /// <param name="automatedPaymentArgs">The arguments describing how to charge the payment and store the resulting transaction</param>
        /// <param name="rockContext">The context to use for loading and saving entities</param>
        /// <param name="enableDuplicateChecking">If false, the payment will be charged even if there is a similar transaction for the same person
        /// within a short time period.</param>
        /// <param name="enableScheduleAdherenceProtection">If false and a schedule is indicated in the args, the payment will be charged even if
        /// the schedule has already been processed according to it's frequency.</param>
        public AutomatedPaymentProcessor(int?currentPersonAliasId, AutomatedPaymentArgs automatedPaymentArgs, RockContext rockContext, bool enableDuplicateChecking = true, bool enableScheduleAdherenceProtection = true)
        {
            _rockContext                       = rockContext;
            _automatedPaymentArgs              = automatedPaymentArgs;
            _currentPersonAliasId              = currentPersonAliasId;
            _enableDuplicateChecking           = enableDuplicateChecking;
            _enableScheduleAdherenceProtection = enableScheduleAdherenceProtection;
            _futureTransaction                 = null;

            _personAliasService                   = new PersonAliasService(_rockContext);
            _financialGatewayService              = new FinancialGatewayService(_rockContext);
            _financialAccountService              = new FinancialAccountService(_rockContext);
            _financialPersonSavedAccountService   = new FinancialPersonSavedAccountService(_rockContext);
            _financialBatchService                = new FinancialBatchService(_rockContext);
            _financialTransactionService          = new FinancialTransactionService(_rockContext);
            _financialScheduledTransactionService = new FinancialScheduledTransactionService(_rockContext);

            _payment = null;
        }
Пример #2
0
        /// <summary>
        /// If this payment processor is handling charging a future transaction, this method copies that future transaction into the appropriate args
        /// </summary>
        private void CopyFutureTransactionToArgs()
        {
            if (_futureTransaction == null || _automatedPaymentArgs != null)
            {
                return;
            }

            _automatedPaymentArgs = new AutomatedPaymentArgs
            {
                AuthorizedPersonAliasId       = _futureTransaction.AuthorizedPersonAliasId ?? -1,
                AutomatedGatewayId            = _futureTransaction.FinancialGatewayId ?? -1,
                FinancialPersonSavedAccountId = _futureTransaction.TransactionCode.AsInteger(),
                ScheduledTransactionId        = _futureTransaction.ScheduledTransactionId,
                ShowAsAnonymous         = _futureTransaction.ShowAsAnonymous,
                TransactionTypeGuid     = _futureTransaction.TransactionTypeValue?.Guid,
                FinancialSourceGuid     = _futureTransaction.SourceTypeValue?.Guid,
                AutomatedPaymentDetails = _futureTransaction.TransactionDetails?.Select(td => new AutomatedPaymentArgs.AutomatedPaymentDetailArgs
                {
                    AccountId = td.AccountId,
                    Amount    = td.Amount
                }).ToList()
            };
        }
Пример #3
0
        /// <summary>
        /// Create a new payment processor to handle a single automated payment from a future transaction (probably generated from text-to-give).
        /// </summary>
        /// <param name="futureTransaction">The transaction with a FutureProcessingDateTime</param>
        /// <param name="rockContext">The context to use for loading and saving entities</param>
        public AutomatedPaymentProcessor(FinancialTransaction futureTransaction, RockContext rockContext)
        {
            _rockContext          = rockContext;
            _automatedPaymentArgs = null;
            _currentPersonAliasId = futureTransaction.CreatedByPersonAliasId;
            _futureTransaction    = futureTransaction;

            // The job charging these future transactions could have a variable run frequency and be charging a days worth at a time, so the duplicate
            // checking could very easily provide false positives. Therefore, we rely on the "dry-run" to have previously validated
            _enableDuplicateChecking           = false; // These future transactions should have already had a "dry-run" and been validated.
            _enableScheduleAdherenceProtection = false; // These future transactions should have already had a "dry-run" and been validated

            _personAliasService                   = new PersonAliasService(_rockContext);
            _financialGatewayService              = new FinancialGatewayService(_rockContext);
            _financialAccountService              = new FinancialAccountService(_rockContext);
            _financialPersonSavedAccountService   = new FinancialPersonSavedAccountService(_rockContext);
            _financialBatchService                = new FinancialBatchService(rockContext);
            _financialTransactionService          = new FinancialTransactionService(_rockContext);
            _financialScheduledTransactionService = new FinancialScheduledTransactionService(_rockContext);

            _payment = null;

            CopyFutureTransactionToArgs();
        }