Beispiel #1
0
        /// <summary>
        /// Adds the scheduled payment.
        /// </summary>
        /// <param name="financialGateway">The financial gateway.</param>
        /// <param name="schedule">The schedule.</param>
        /// <param name="paymentInfo">The payment info.</param>
        /// <param name="errorMessage">The error message.</param>
        /// <returns></returns>
        public override FinancialScheduledTransaction AddScheduledPayment(FinancialGateway financialGateway, PaymentSchedule schedule, PaymentInfo paymentInfo, out string errorMessage)
        {
            errorMessage = string.Empty;

            if (ValidateCard(financialGateway, paymentInfo, out errorMessage))
            {
                var scheduledTransaction = new FinancialScheduledTransaction();
                scheduledTransaction.IsActive                 = true;
                scheduledTransaction.StartDate                = schedule.StartDate;
                scheduledTransaction.NextPaymentDate          = schedule.StartDate;
                scheduledTransaction.TransactionCode          = "T" + RockDateTime.Now.ToString("yyyyMMddHHmmssFFF");
                scheduledTransaction.GatewayScheduleId        = "Subscription_" + RockDateTime.Now.ToString("yyyyMMddHHmmssFFF");
                scheduledTransaction.LastStatusUpdateDateTime = RockDateTime.Now;
                scheduledTransaction.Status        = FinancialScheduledTransactionStatus.Active;
                scheduledTransaction.StatusMessage = "active";

                scheduledTransaction.FinancialPaymentDetail = new FinancialPaymentDetail()
                {
                    ExpirationMonth       = (paymentInfo as ReferencePaymentInfo)?.PaymentExpirationDate?.Month,
                    ExpirationYear        = (paymentInfo as ReferencePaymentInfo)?.PaymentExpirationDate?.Year,
                    CurrencyTypeValueId   = DefinedValueCache.GetId(Rock.SystemGuid.DefinedValue.CURRENCY_TYPE_CREDIT_CARD.AsGuid()),
                    AccountNumberMasked   = paymentInfo.MaskedNumber,
                    CreditCardTypeValueId = CreditCardPaymentInfo.GetCreditCardTypeFromCreditCardNumber(paymentInfo.MaskedNumber)?.Id ?? DefinedValueCache.GetId(Rock.SystemGuid.DefinedValue.CREDITCARD_TYPE_VISA.AsGuid())
                };

                return(scheduledTransaction);
            }

            return(null);
        }
Beispiel #2
0
        /// <summary>
        /// Charges the specified payment info.
        /// </summary>
        /// <param name="financialGateway">The financial gateway.</param>
        /// <param name="paymentInfo">The payment info.</param>
        /// <param name="errorMessage">The error message.</param>
        /// <returns></returns>
        public override FinancialTransaction Charge(FinancialGateway financialGateway, PaymentInfo paymentInfo, out string errorMessage)
        {
            errorMessage = string.Empty;

            if (ValidateCard(financialGateway, paymentInfo, out errorMessage))
            {
                var transaction = new FinancialTransaction();
                transaction.TransactionCode = "T" + RockDateTime.Now.ToString("yyyyMMddHHmmssFFF");

                transaction.FinancialPaymentDetail = new FinancialPaymentDetail()
                {
                    ExpirationMonth       = (paymentInfo as ReferencePaymentInfo)?.PaymentExpirationDate?.Month,
                    ExpirationYear        = (paymentInfo as ReferencePaymentInfo)?.PaymentExpirationDate?.Year,
                    CurrencyTypeValueId   = DefinedValueCache.GetId(Rock.SystemGuid.DefinedValue.CURRENCY_TYPE_CREDIT_CARD.AsGuid()),
                    AccountNumberMasked   = paymentInfo.MaskedNumber,
                    CreditCardTypeValueId = CreditCardPaymentInfo.GetCreditCardTypeFromCreditCardNumber(paymentInfo.MaskedNumber ?? string.Empty)?.Id ?? DefinedValueCache.GetId(Rock.SystemGuid.DefinedValue.CREDITCARD_TYPE_VISA.AsGuid())
                };

                return(transaction);
            }

            return(null);
        }