예제 #1
0
        protected override PaymentResult ExecutePaymentProcess(PaymentDataBase paymentData)
        {
            EftPaymentData eftPaymentData = paymentData as EftPaymentData;

            EftAuthorization eftResult = this.eftProcessor.AuthorizeEftPayment(eftPaymentData.RoutingNumber,
                                                                               eftPaymentData.BankAccountNumber, eftPaymentData.AccountType, eftPaymentData.Amount);

            if (eftResult.Authorized)
            {
                int referenceNumber = paymentsDao.SaveSuccessfulEftPayment(eftPaymentData, eftResult);

                PaymentResult paymentResult = new PaymentResult()
                {
                    CustomerAccountNumber = eftPaymentData.CustomerAccountNumber,
                    PaymentDate           = eftPaymentData.PaymentDate,
                    Success         = eftResult.Authorized,
                    ReferenceNumber = referenceNumber
                };

                return(paymentResult);
            }
            else
            {
                int referenceNumber = paymentsDao.SaveFailedEftPayment(eftPaymentData, eftResult);

                PaymentResult paymentResult = new PaymentResult()
                {
                    CustomerAccountNumber = eftPaymentData.CustomerAccountNumber,
                    PaymentDate           = eftPaymentData.PaymentDate,
                    Success         = eftResult.Authorized,
                    ReferenceNumber = referenceNumber
                };
                return(paymentResult);
            }
        }
예제 #2
0
        protected override PaymentResult ExecutePaymentProcess(PaymentDataBase paymentData)
        {
            CreditCardPaymentData creditCardData = paymentData as CreditCardPaymentData;

            CreditCardResult authResult = this.creditCardProcessor.AuthorizeCreditCard(creditCardData.CreditCardNumber,
                                                                                       creditCardData.ExpirationDate, creditCardData.Cvv, creditCardData.BillingZipCode, creditCardData.Amount);

            if (authResult.Authorized == true)
            {
                int referenceNumber = paymentsDao.SaveSuccessfulCreditCardPayment(creditCardData, authResult);

                PaymentResult paymentResult = new PaymentResult()
                {
                    CustomerAccountNumber = creditCardData.CustomerAccountNumber,
                    PaymentDate           = creditCardData.PaymentDate,
                    Success         = authResult.Authorized,
                    ReferenceNumber = referenceNumber
                };
                return(paymentResult);
            }
            else
            {
                int referenceNumber = paymentsDao.SaveFailedCreditCardPayment(creditCardData, authResult);

                PaymentResult paymentResult = new PaymentResult()
                {
                    CustomerAccountNumber = creditCardData.CustomerAccountNumber,
                    PaymentDate           = creditCardData.PaymentDate,
                    Success         = authResult.Authorized,
                    ReferenceNumber = referenceNumber
                };
                return(paymentResult);
            }
        }
        protected override PaymentResult ExecutePaymentProcess(PaymentDataBase paymentData)
        {
            CheckPaymentData checkPaymentData = paymentData as CheckPaymentData;

            int           referenceNumber = this.paymentsDao.SaveCheckPayment(checkPaymentData);
            PaymentResult paymentResult   = new PaymentResult()
            {
                CustomerAccountNumber = checkPaymentData.CustomerAccountNumber,
                PaymentDate           = checkPaymentData.PaymentDate,
                Success         = true,
                ReferenceNumber = referenceNumber
            };

            return(paymentResult);
        }
예제 #4
0
 /// <summary>
 /// Try to process the payment.  If we can, then we'll return.  Otherwise
 /// we'll call the next payment handler in the chain
 /// </summary>
 /// <param name="paymentData"></param>
 /// <returns></returns>
 public PaymentResult TryProcessPayment(PaymentDataBase paymentData)
 {
     if (this.CanProcessPayment(paymentData))
     {
         return(this.ExecutePaymentProcess(paymentData));
     }
     else if (this.NextPaymentTypeHandler != null)
     {
         return(this.NextPaymentTypeHandler.TryProcessPayment(paymentData));
     }
     else
     {
         throw new ApplicationException("Unable to Process Payment Type");
     }
 }
 protected override bool CanProcessPayment(PaymentDataBase paymentData)
 {
     return(paymentData.PaymentType == PaymentType.CHECK);
 }
예제 #6
0
 protected abstract PaymentResult ExecutePaymentProcess(PaymentDataBase paymentData);
예제 #7
0
 protected abstract bool CanProcessPayment(PaymentDataBase paymentData);
 public PaymentResult ProcessPayment(PaymentDataBase paymentData)
 {
     return(this.initialPaymentTypeHandler.TryProcessPayment(paymentData));
 }