Exemplo n.º 1
0
        protected override PaymentResult ExecutePaymentProcess(BasePaymentData 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);
            }
        }
        protected override PaymentResult ExecutePaymentProcess(BasePaymentData paymentData)
        {
            CreditCardPaymentData creditCardData = paymentData as CreditCardPaymentData;

            CreditCardResult authResult = this.creditCardService.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);
            }
        }
Exemplo n.º 3
0
        protected override PaymentResult ExecutePaymentProcess(BasePaymentData 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);
        }
Exemplo n.º 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(BasePaymentData paymentData)
 {
     if (this.CanProcessPayment(paymentData))
     {
         return(this.ExecutePaymentProcess(paymentData));
     }
     else if (NextPaymentHandler != null)
     {
         return(this.NextPaymentHandler.TryProcessPayment(paymentData));
     }
     else
     {
         throw new ApplicationException("Unable to Process Payment Type");
     }
 }
Exemplo n.º 5
0
 protected override bool CanProcessPayment(BasePaymentData paymentData)
 {
     return(paymentData.PaymentType == PaymentType.EFT);
 }
Exemplo n.º 6
0
 public PaymentResult ProcessPayment(BasePaymentData paymentData)
 {
     return(this.paymentProcessingChainFirstElement.TryProcessPayment(paymentData));
 }
Exemplo n.º 7
0
 protected abstract PaymentResult ExecutePaymentProcess(BasePaymentData paymentData);
Exemplo n.º 8
0
 protected abstract bool CanProcessPayment(BasePaymentData paymentData);