Ejemplo n.º 1
0
        public BaseResponse AddAchFunds(AchPayment payment)
        {
            var nonCreditPayment = MapperHelper.UIMapTo<AchPayment, NonCreditPayment>(payment);

            var addFundsResponse = _paymentService.AddFoundsUsingPaymentAchBsPos(nonCreditPayment);

            var paymentId = _blackstonePosService.FindPayment(payment.AccountNumber, payment.RoutingNumber);

            payment.Id = paymentId;

            if (!addFundsResponse.WasSuccess)
                payment.Saved = false;//Assures the payment info is not modified since it was failed

            var achPayment = GetAchPaymentInstance(nonCreditPayment);

            //Add or Update the Payment Info
            var newPayment = _blackstonePosService.AddItem(_achPaymentRepository, achPayment);

            var achTransaction = GetAchTransactionInstance(newPayment.Id, payment.Amount, addFundsResponse.WasSuccess, addFundsResponse.Message);

            //Add or Update the Payment Transaction
            _blackstonePosService.AddItem(_achTransactionRepository, achTransaction);

            var status = addFundsResponse.WasSuccess ? 200 : 201;

            var message = addFundsResponse.Message;

            return new BaseResponse
            {
                Status = status,

                ErrorMessage = !string.IsNullOrEmpty(message)? message: "Errors trying to add funds."
            };
        }
Ejemplo n.º 2
0
        private AchPayment GetAchPaymentInstance(NonCreditPayment nonCreditPayment)
        {
            var achPayment = new AchPayment
            {
                AccountNumber = nonCreditPayment.AccountNumber,
                RoutingNumber = nonCreditPayment.RoutingNumber,
                MerchantId = int.Parse(nonCreditPayment.MerchantId),
                Saved = nonCreditPayment.SaveAccount,
                Id = int.Parse(nonCreditPayment.Id),
                TimeStamp = DateTime.Now

            };

            return achPayment;
        }