Beispiel #1
0
        public bool AddBankDepositPaymentDetailsOtherInvoice(BankPaymentDetail Obj)
        {
            try
            {
                int status = 0;
                using (SqlConnection connection = DataAccess.CreateConnection())
                {
                    SqlCommand command = DataAccess.CreateCommand(connection);

                    DataAccess.CreateStoredprocedure(command, "AddBankDepositPaymentDetailsOtherInvoice_SP");
                    DataAccess.AddInParameter(command, "@Notes", SqlDbType.VarChar, Obj.Notes);
                    DataAccess.AddInParameter(command, "@Amount", SqlDbType.Float, Obj.Amount);
                    DataAccess.AddInParameter(command, "@InvoiceId", SqlDbType.Int, Obj.InvoiceId);
                    DataAccess.AddInParameter(command, "@BankAccountId", SqlDbType.Int, Obj.BankAccountId);
                    DataAccess.AddInParameter(command, "@BankDate", SqlDbType.VarChar, Obj.BankDate);
                    DataAccess.AddInParameter(command, "@UserId", SqlDbType.VarChar, Obj.UserId);
                    status = DataAccess.ExecuteNonQuery(command);
                    return(status < 0 ? false : true);
                }
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
Beispiel #2
0
        public async Task <IActionResult> Get(Guid paymentReference)
        {
            await Task.Delay(100);

            var bankPaymentDetail = new BankPaymentDetail(paymentReference, "Accepted", "4485063526474709", "01/20", 20.00m, "GBP", 123);

            return(Ok(bankPaymentDetail));
        }
        public PaymentDetail MapDetail(BankPaymentDetail bankPaymentDetail)
        {
            var cardNumber = MaskCardNumber(bankPaymentDetail.CardNumber);

            return(new PaymentDetail(bankPaymentDetail.PaymentReference, bankPaymentDetail.Status,
                                     cardNumber, bankPaymentDetail.ExpiryDate, bankPaymentDetail.Amount,
                                     bankPaymentDetail.Currency, bankPaymentDetail.Cvv));
        }
        public void Should_Mask_CardNumber_When_Mapping_BankPaymentDetail_To_PaymentDetail()
        {
            // Arrange
            var bankPaymentDetail = new BankPaymentDetail(Guid.NewGuid(), "Accepted", "4485063526474709", "01/20", 20.00m, "GBP", 123);
            var bankPaymentMapper = new BankPaymentMapper();

            // Act
            var paymentDetail = bankPaymentMapper.MapDetail(bankPaymentDetail);

            // Assert
            Assert.Equal("4***********4709", paymentDetail.CardNumber);
        }
        public void Should_Map_BankPaymentDetail_To_PaymentDetail()
        {
            // Arrange
            var bankPaymentDetail = new BankPaymentDetail(Guid.NewGuid(), "Accepted", "4485063526474709", "01/20", 20.00m, "GBP", 123);
            var bankPaymentMapper = new BankPaymentMapper();

            // Act
            var paymentDetail = bankPaymentMapper.MapDetail(bankPaymentDetail);

            // Assert
            Assert.Equal(bankPaymentDetail.PaymentReference, paymentDetail.PaymentReference);
            Assert.Equal(bankPaymentDetail.Status, paymentDetail.Status);
            Assert.Equal("4***********4709", paymentDetail.CardNumber);
            Assert.Equal(bankPaymentDetail.ExpiryDate, paymentDetail.ExpiryDate);
            Assert.Equal(bankPaymentDetail.Amount, paymentDetail.Amount);
            Assert.Equal(bankPaymentDetail.Currency, paymentDetail.Currency);
            Assert.Equal(bankPaymentDetail.Cvv, paymentDetail.Cvv);
        }
        public PaymentGatewayServiceShould()
        {
            paymentReference   = Guid.NewGuid();
            paymentRequest     = CreatePaymentRequest();
            bankPaymentRequest = new BankPaymentRequest("4485063526474709", "01/20", 20.00m, "GBP", 123);
            bankApiMock        = new Mock <IBankApiClient>();
            var bankPaymentDetail   = new BankPaymentDetail(paymentReference, "Accepted", "4485063526474709", "01/20", 20.00m, "GBP", 123);
            var bankPaymentResponse = new BankPaymentResponse(paymentReference, "Accepted");
            var paymentResponse     = new PaymentResponse(paymentReference, "Accepted");
            var paymentDetail       = new PaymentDetail(paymentReference, "Accepted", "4***********4709", "01/20", 20.00m, "GBP", 123);

            bankApiMock.Setup(service => service.Process(It.IsAny <BankPaymentRequest>()))
            .Returns(Task.FromResult(bankPaymentResponse));
            bankApiMock.Setup(service => service.GetPaymentDetail(paymentReference)).Returns(Task.FromResult(bankPaymentDetail));
            bankPaymentMapperMock = new Mock <IBankPaymentMapper>();
            bankPaymentMapperMock.Setup(mapper => mapper.MapRequest(It.IsAny <PaymentRequest>())).Returns(bankPaymentRequest);
            bankPaymentMapperMock.Setup(mapper => mapper.MapResponse(It.IsAny <BankPaymentResponse>()))
            .Returns(paymentResponse);
            bankPaymentMapperMock.Setup(mapper => mapper.MapDetail(It.IsAny <BankPaymentDetail>()))
            .Returns(paymentDetail);
            applicationLoggerMock = new Mock <IApplicationLogger>();
            paymentGatewayService = new PaymentGatewayService(bankApiMock.Object, bankPaymentMapperMock.Object, applicationLoggerMock.Object);
        }
Beispiel #7
0
        public ActionResult AgtCustTransaction(FormCollection form)
        {
            int InvoiceId = (string.IsNullOrEmpty(form["InvoiceId"])) ? 0 : Convert.ToInt32(form["InvoiceId"]);

            try
            {
                int TransactionMethod = (string.IsNullOrEmpty(form["TransactionMethod"])) ? 0 : Convert.ToInt32(form["TransactionMethod"]);
                #region Payment by Cash
                if (TransactionMethod == 1)
                {
                    CashTransaction Obj = new CashTransaction();
                    Obj.Amount    = (string.IsNullOrEmpty(form["PaymentAmount"])) ? 0 : Convert.ToDouble(form["PaymentAmount"]);
                    Obj.Remarks   = (string.IsNullOrEmpty(form["PaymentRemarks"])) ? string.Empty : Convert.ToString(form["PaymentRemarks"]);
                    Obj.UserId    = User.Identity.GetUserId();
                    Obj.InvoiceId = InvoiceId;
                    new OtherInvoiceDA().OtherInvoicePaymentCashVoucher(Obj);
                }
                #endregion
                #region Payment by Bank Cheque
                else if (TransactionMethod == 2)
                {
                    ChequeDetails Obj = new ChequeDetails();
                    Obj.AccountNo = (string.IsNullOrEmpty(form["AccountNo"])) ? string.Empty : Convert.ToString(form["AccountNo"]);
                    Obj.Amount    = (string.IsNullOrEmpty(form["PaymentAmount"])) ? 0 : Convert.ToDouble(form["PaymentAmount"]);
                    Obj.BankNames = (BankName)Convert.ToInt32(((string.IsNullOrEmpty(form["BankId"])) ? "0" : Convert.ToString(form["BankId"])).Replace(",", ""));
                    Obj.ChequeNo  = (string.IsNullOrEmpty(form["ChequeNo"])) ? string.Empty : Convert.ToString(form["ChequeNo"]);
                    Obj.InvoiceId = InvoiceId;
                    Obj.Remarks   = (string.IsNullOrEmpty(form["PaymentRemarks"])) ? string.Empty : Convert.ToString(form["PaymentRemarks"]);
                    Obj.SortCode  = (string.IsNullOrEmpty(form["SortCode"])) ? string.Empty : Convert.ToString(form["SortCode"]);
                    this.chequeTransaction(Obj);
                }
                #endregion
                #region Payment By Credit Card
                else if (TransactionMethod == 3)
                {
                    CCardDetail Obj = new CCardDetail();
                    Obj.Amount        = (string.IsNullOrEmpty(form["PaymentAmount"])) ? 0 : Convert.ToDouble(form["PaymentAmount"]);
                    Obj.BankAccountId = (string.IsNullOrEmpty(form["BankAccountId"])) ? 0 : Convert.ToInt32(form["BankAccountId"]);
                    Obj.BankDate      = (string.IsNullOrEmpty(form["BankDate"])) ? string.Empty : Convert.ToString(form["BankDate"]);
                    Obj.CardHolder    = (string.IsNullOrEmpty(form["CardHolderName"])) ? string.Empty : Convert.ToString(form["CardHolderName"]);
                    Obj.CardNo        = (string.IsNullOrEmpty(form["CreditCardNo"])) ? string.Empty : Convert.ToString(form["CreditCardNo"]);
                    Obj.ExtraAmount   = (string.IsNullOrEmpty(form["ExtraAmount"])) ? string.Empty : Convert.ToString(form["ExtraAmount"]);
                    Obj.InvoiceId     = InvoiceId;
                    Obj.Notes         = String.Format("Credit Card Invoice Payment by {0}. - {1}", User.Identity.GetDisplayName(), (string.IsNullOrEmpty(form["PaymentRemarks"])) ? string.Empty : Convert.ToString(form["PaymentRemarks"]));
                    Obj.UserId        = User.Identity.GetUserId();
                    new OtherInvoiceDA().AddCreditCardPaymentDetailsOtherInvoice(Obj);
                }
                #endregion
                #region Payment by Debit Card
                else if (TransactionMethod == 4)
                {
                    DCardDetail Obj = new DCardDetail();
                    Obj.Amount        = (string.IsNullOrEmpty(form["PaymentAmount"])) ? 0 : Convert.ToDouble(form["PaymentAmount"]);
                    Obj.BankAccountId = (string.IsNullOrEmpty(form["BankAccountId"])) ? 0 : Convert.ToInt32(form["BankAccountId"]);
                    Obj.BankDate      = (string.IsNullOrEmpty(form["BankDateDebitCard"])) ? string.Empty : Convert.ToString(form["BankDateDebitCard"]);
                    Obj.CardHolder    = (string.IsNullOrEmpty(form["CardHolderNameDebitCard"])) ? string.Empty : Convert.ToString(form["CardHolderNameDebitCard"]);
                    Obj.CardNo        = (string.IsNullOrEmpty(form["DebitCardNo"])) ? string.Empty : Convert.ToString(form["DebitCardNo"]);
                    Obj.ExtraAmount   = (string.IsNullOrEmpty(form["ExtraAmountDebitCard"])) ? string.Empty : Convert.ToString(form["ExtraAmountDebitCard"]);
                    Obj.InvoiceId     = InvoiceId;
                    Obj.Notes         = String.Format("Debit Card Invoice Payment by {0}. - {1}", User.Identity.GetDisplayName(), (string.IsNullOrEmpty(form["PaymentRemarks"])) ? string.Empty : Convert.ToString(form["PaymentRemarks"]));
                    Obj.UserId        = User.Identity.GetUserId();
                    new OtherInvoiceDA().AddDebitCardPaymentDetailsOtherInvoice(Obj);
                }
                #endregion
                #region Payment by Bank Deposit
                else if (TransactionMethod == 5)
                {
                    BankPaymentDetail Obj = new BankPaymentDetail();
                    Obj.Amount        = (string.IsNullOrEmpty(form["PaymentAmount"])) ? 0 : Convert.ToDouble(form["PaymentAmount"]);
                    Obj.BankAccountId = (string.IsNullOrEmpty(form["BankAccountId"])) ? 0 : Convert.ToInt32(form["BankAccountId"]);
                    Obj.BankDate      = (string.IsNullOrEmpty(form["BankDateBankDeposit"])) ? string.Empty : Convert.ToString(form["BankDateBankDeposit"]);
                    Obj.InvoiceId     = InvoiceId;
                    Obj.Notes         = String.Format("Bank Deposit/Transfer Invoice Payment by {0}. - {1}", User.Identity.GetDisplayName(), (string.IsNullOrEmpty(form["PaymentRemarks"])) ? string.Empty : Convert.ToString(form["PaymentRemarks"]));
                    Obj.UserId        = User.Identity.GetUserId();
                    new OtherInvoiceDA().AddBankDepositPaymentDetailsOtherInvoice(Obj);
                }
                #endregion
                return(RedirectToAction("Details", "OtherInvoice", new { id = InvoiceId }));
            }
            catch (Exception ex)
            {
                return(RedirectToAction("Details", "OtherInvoice", new { id = InvoiceId }));
            }
        }