예제 #1
0
        /// <summary>
        /// Process a refund for a transaction.
        /// </summary>
        /// <param name="transaction">The refund transaction.</param>
        /// <param name="amount">The amount.</param>
        /// <param name="reasonValueId">The reason value identifier.</param>
        /// <param name="summary">The summary.</param>
        /// <param name="process">if set to <c>true</c> [process].</param>
        /// <param name="batchNameSuffix">The batch name suffix.</param>
        /// <param name="errorMessage">The error message.</param>
        /// <returns></returns>
        public static FinancialTransaction ProcessRefund(this FinancialTransaction transaction, decimal?amount, int?reasonValueId, string summary, bool process, string batchNameSuffix, out string errorMessage)
        {
            using (var rockContext = new RockContext())
            {
                var service           = new FinancialTransactionService(rockContext);
                var refundTransaction = service.ProcessRefund(transaction, null, null, string.Empty, true, string.Empty, out errorMessage);

                if (refundTransaction != null)
                {
                    rockContext.SaveChanges();
                }

                return(refundTransaction);
            }
        }