public void PaymentTypeIsCreditCard()
        {
            PaymentType expectedPaymentType = PaymentType.CreditCard;

            var chargeCardPayment = new ChargeCardPayment();

            Assert.AreEqual(expectedPaymentType, chargeCardPayment.PaymentType,
                            "Incorrect PaymentType returned.");
        }
Esempio n. 2
0
        public void SavingChargeCardPaymentCallsSaveMethodOfChargeCardRepository()
        {
            var chargeCardPayment = new ChargeCardPayment();

            Expect.Call(_keyValueDictionaryFactory.GetDictionary(null, null)).IgnoreArguments().Return(_repositoryDictionary);
            Expect.Call(() => _creditCardRepository.SavePaymentInstrument(chargeCardPayment)).Return(null);

            _mocks.ReplayAll();
            _repository.SavePaymentInstrument(chargeCardPayment);
            _mocks.VerifyAll();
        }
Esempio n. 3
0
        /// <summary>
        /// Checks if the given transaction is valid for refund or not
        /// </summary>
        /// <param name="cardPayment"></param>
        /// <param name="amountToRefund"></param>
        /// <returns></returns>
        public bool IsCardValidforRefund(ChargeCardPayment cardPayment, decimal amountToRefund, out string reasonForFailure)
        {
            reasonForFailure = string.Empty;
            if (cardPayment.Amount < amountToRefund)
            {
                reasonForFailure = "The payment gateway doesn't allow refund of an amount greater than the one in the last transaction made. The Last Transaction amount is ($" + cardPayment.Amount.ToString("0.00") + ").";
                return(false);
            }

            if (cardPayment.DataRecorderMetaData.DateCreated < DateTime.Now.Date.AddDays(-120))
            {
                reasonForFailure = "Can Not Refund against the last transaction, made on Card on file. As the valid date of making a request is within 120 days.";
                return(false);
            }


            if (!ProcessorResponse.IsValidResponseString(cardPayment.ProcessorResponse))
            {
                reasonForFailure = "No valid Transaction Code found in the database, for the selected card on file.";
                return(false);
            }

            return(true);
        }
Esempio n. 4
0
 public ChargeCardPaymentEditModel()
 {
     ChargeCard        = new ChargeCard();
     ChargeCardPayment = new ChargeCardPayment();
 }
Esempio n. 5
0
        private PaymentInstrument GetPaymentInstrumentForRefund(decimal amount, int refundMode,
                                                                string checkNumber, string customerName,
                                                                ChargeCardPayment chargeCardPayment, OrganizationRoleUser creatorOrganizationRoleUser)
        {
            if (refundMode == PaymentType.Cash.PersistenceLayerId)
            {
                return(new CashPayment
                {
                    Amount = (-1) * amount,
                    DataRecorderMetaData =
                        new DataRecorderMetaData
                    {
                        DataRecorderCreator = creatorOrganizationRoleUser,
                        DateCreated = DateTime.Now,
                        DataRecorderModifier = creatorOrganizationRoleUser,
                        DateModified = DateTime.Now
                    }
                });
            }

            else if (refundMode == PaymentType.Check.PersistenceLayerId)
            {
                var check = new Check
                {
                    AccountNumber        = string.Empty,
                    Amount               = (-1) * amount,
                    BankName             = string.Empty,
                    CheckNumber          = checkNumber,
                    DataRecorderMetaData =
                        new DataRecorderMetaData
                    {
                        DataRecorderCreator  = creatorOrganizationRoleUser,
                        DateCreated          = DateTime.Now,
                        DataRecorderModifier = creatorOrganizationRoleUser,
                        DateModified         = DateTime.Now
                    },
                    CheckDate        = DateTime.Today,
                    RoutingNumber    = string.Empty,
                    PayableTo        = customerName,
                    AcountHolderName = string.Empty
                };

                return(new CheckPayment
                {
                    Check = check,
                    Amount = check.Amount,
                    CheckStatus = CheckPaymentStatus.Recieved,
                    DataRecorderMetaData = check.DataRecorderMetaData,
                    CheckId = check.Id
                });
            }

            return(new ChargeCardPayment
            {
                Amount = (-1) * amount,
                ChargeCardId = chargeCardPayment.ChargeCardId,
                ChargeCardPaymentStatus = ChargeCardPaymentStatus.Approve,
                DataRecorderMetaData =
                    new DataRecorderMetaData {
                    DataRecorderCreator = creatorOrganizationRoleUser, DateCreated = DateTime.Now
                },
                ProcessorResponse = chargeCardPayment.ProcessorResponse
            });
        }
Esempio n. 6
0
        public void GetByIdReturnsExpectedChargeCardPayment()
        {
            ChargeCardPayment chargeCardPayment = _repository.GetById(CHARGE_CARD_PAYMENT_ID);

            Assert.AreEqual(CHARGE_CARD_PAYMENT_ID, chargeCardPayment.Id);
        }