Beispiel #1
0
        public void ShouldRetreivePaymentSummaryForInvoiceId()
        {
            var invoice             = GetInvoiceTransaction01();
            var invoiceProxy        = new InvoiceProxy();
            var insertInvoiceResult = invoiceProxy.InsertInvoice(invoice);

            Assert.IsTrue(insertInvoiceResult.DataObject.InsertedEntityId > 0,
                          "There was an error creating the first invoice for payment test - ShouldRetreivePaymentSummaryForInvoiceId.");

            var invoice01TransctionId = insertInvoiceResult.DataObject.InsertedEntityId;

            invoice             = GetInvoiceTransaction02();
            invoiceProxy        = new InvoiceProxy();
            insertInvoiceResult = invoiceProxy.InsertInvoice(invoice);

            Assert.IsTrue(insertInvoiceResult.DataObject.InsertedEntityId > 0,
                          "There was an error creating the second invoice for payment test - ShouldRetreivePaymentSummaryForInvoiceId.");

            var invoice02TransactionId = insertInvoiceResult.DataObject.InsertedEntityId;

            var invoicePayment = new PaymentTransaction
            {
                TransactionDate = DateTime.Now,
                TransactionType = "SP",
                Currency        = "AUD",
                Summary         =
                    string.Format("Test Payment insert for multiple invoices"),
                PaymentAccountId = _bankAccount01Id,
                PaymentItems     = new List <PaymentItem>
                {
                    new PaymentItem
                    {
                        InvoiceTransactionId = invoice01TransctionId,
                        AmountPaid           = 110.00M
                    },

                    new PaymentItem
                    {
                        InvoiceTransactionId = invoice02TransactionId,
                        AmountPaid           = 150.00M
                    }
                }
            };

            var invoicePaymentProxy          = new PaymentProxy();
            var insertInvoicePaymentResponse = invoicePaymentProxy.InsertInvoicePayment(invoicePayment);

            Assert.IsNotNull(insertInvoicePaymentResponse);
            Assert.IsTrue(insertInvoicePaymentResponse.IsSuccessfull);
            Assert.IsNotNull(insertInvoicePaymentResponse.RawResponse);

            var paymentsResponse = new PaymentsProxy().GetPayments(null, null, invoice02TransactionId, null, null, null,
                                                                   null, null, null, null, null, null);

            Assert.IsNotNull(paymentsResponse, "Payments response is NULL.");
            Assert.IsTrue(paymentsResponse.IsSuccessfull, "Payments response was not successful.");
            Assert.IsNotNull(paymentsResponse.DataObject.PaymentTransactions, "Payments response does not contain a payments summary.");
            Assert.IsTrue(paymentsResponse.DataObject.PaymentTransactions.Count > 0, "No payment summaries found for transaction type.");
            Assert.AreEqual(150M, paymentsResponse.DataObject.PaymentTransactions[0].TotalAmount, "Incorrect payment amount");
        }
Beispiel #2
0
        public void ShouldRetrievePaymentSummaryUsingPaymentDateRange()
        {
            var paymentsResponse = new PaymentsProxy().GetPayments(null, null, null, null, null, null, DateTime.Now.Date.AddDays(-30), DateTime.Now.Date, null, null, null,
                                                                   null);

            Assert.IsNotNull(paymentsResponse, "Payments response is NULL.");
            Assert.IsTrue(paymentsResponse.IsSuccessfull, "Payments response was not successful.");
            Assert.IsNotNull(paymentsResponse.DataObject.PaymentTransactions, "Payments response does not contain a payments summary.");
            Assert.IsTrue(paymentsResponse.DataObject.PaymentTransactions.Count > 0, "No payment summaries found for transaction type.");
        }
Beispiel #3
0
        public void ShouldRetreivePaymentSummaryUsingTransactionType()
        {
            var paymentsResponse = new PaymentsProxy().GetPayments(null, null, null, null, "SP", null, null, null, null, null, null,
                                                                   null);

            Assert.IsNotNull(paymentsResponse, "Payments response is NULL.");
            Assert.IsTrue(paymentsResponse.IsSuccessfull, "Payments response was not successful.");
            Assert.IsNotNull(paymentsResponse.DataObject.PaymentTransactions, "Payments response does not contain a payments summary.");
            Assert.IsTrue(paymentsResponse.DataObject.PaymentTransactions.Count > 0, "No payment summaries found for transaction type SP");
            foreach (var payment in paymentsResponse.DataObject.PaymentTransactions)
            {
                Assert.IsTrue(payment.TransactionType.Equals("SP"), "Incorrect payment transaction type in payment summary.");
            }
        }
Beispiel #4
0
        public void ShouldRetrievePaymentSummaryUsingPaymentAccountId()
        {
            var paymentsResponse = new PaymentsProxy().GetPayments(null, null, null, _bankAccount01Id, null, null, null, null, null, null, null,
                                                                   null);

            Assert.IsNotNull(paymentsResponse, "Payments response is NULL.");
            Assert.IsTrue(paymentsResponse.IsSuccessfull, "Payments response was not successful.");
            Assert.IsNotNull(paymentsResponse.DataObject.PaymentTransactions, "Payments response does not contain a payments summary.");
            Assert.IsTrue(paymentsResponse.DataObject.PaymentTransactions.Count > 0, "No payment summaries found for transaction type.");

            foreach (var payment in paymentsResponse.DataObject.PaymentTransactions)
            {
                Assert.AreEqual(_bankAccount01Id, payment.PaymentAccountId, "Incorrect payment account Id in payments summary.");
            }
        }
Beispiel #5
0
        public void ShouldRetrievePaymentSummaryUsingPaymentAccountId()
        {
            var paymentsResponse = new PaymentsProxy().GetPayments(null, null, null, _bankAccount01Id, null, null, null, null, null, null, null,
                                                                   null);

            Assert.NotNull(paymentsResponse);
            Assert.True(paymentsResponse.IsSuccessfull, "Payments response was not successful.");
            Assert.NotNull(paymentsResponse.DataObject.PaymentTransactions);
            Assert.True(paymentsResponse.DataObject.PaymentTransactions.Count > 0, "No payment summaries found for transaction type.");

            foreach (var payment in paymentsResponse.DataObject.PaymentTransactions)
            {
                Assert.Equal(_bankAccount01Id, payment.PaymentAccountId);
            }
        }
Beispiel #6
0
        public void TestPaging()
        {
            var invoice             = GetInvoiceTransaction01();
            var invoiceProxy        = new InvoiceProxy();
            var insertInvoiceResult = invoiceProxy.InsertInvoice(invoice);

            Assert.IsTrue(insertInvoiceResult.DataObject.InsertedEntityId > 0,
                          "There was an error creating the invoice for payment test.");

            var invoicePayment1 = new PaymentTransaction
            {
                TransactionDate = DateTime.Now,
                TransactionType = "SP",
                Currency        = "AUD",
                Summary         =
                    string.Format("Test Payment insert for Inv# {0}",
                                  insertInvoiceResult.DataObject.GeneratedInvoiceNumber),
                PaymentAccountId = _bankAccount01Id,
                PaymentItems     = new List <PaymentItem>
                {
                    new PaymentItem()
                    {
                        InvoiceTransactionId =
                            insertInvoiceResult.DataObject.InsertedEntityId,
                        AmountPaid = 50.00M
                    }
                }
            };


            var invoicePaymentProxy          = new PaymentProxy();
            var insertInvoicePaymentResponse = invoicePaymentProxy.InsertInvoicePayment(invoicePayment1);

            Assert.IsNotNull(insertInvoicePaymentResponse);
            Assert.IsTrue(insertInvoicePaymentResponse.IsSuccessfull);
            Assert.IsNotNull(insertInvoicePaymentResponse.RawResponse);

            var invoicePayment2 = new PaymentTransaction
            {
                TransactionDate = DateTime.Now,
                TransactionType = "SP",
                Currency        = "AUD",
                Summary         =
                    string.Format("Test Payment insert for Inv# {0}",
                                  insertInvoiceResult.DataObject.GeneratedInvoiceNumber),
                PaymentAccountId = _bankAccount01Id,
                PaymentItems     = new List <PaymentItem>
                {
                    new PaymentItem()
                    {
                        InvoiceTransactionId =
                            insertInvoiceResult.DataObject.InsertedEntityId,
                        AmountPaid = 60.00M
                    }
                }
            };

            insertInvoicePaymentResponse = invoicePaymentProxy.InsertInvoicePayment(invoicePayment2);

            Assert.IsNotNull(insertInvoicePaymentResponse);
            Assert.IsTrue(insertInvoicePaymentResponse.IsSuccessfull);
            Assert.IsNotNull(insertInvoicePaymentResponse.RawResponse);

            var paymentsProxy = new PaymentsProxy();

            var paymentsPage1 = paymentsProxy.GetPayments(1, 1, insertInvoiceResult.DataObject.InsertedEntityId, null, "SP", null, null, null, null, null, null, null);

            Assert.IsNotNull(paymentsPage1);
            Assert.IsNotNull(paymentsPage1.DataObject);
            Assert.AreEqual(paymentsPage1.DataObject.PaymentTransactions.Count, 1);

            var paymentsPage2 = paymentsProxy.GetPayments(2, 1, insertInvoiceResult.DataObject.InsertedEntityId, null, "SP", null, null, null, null, null, null, null);

            Assert.IsNotNull(paymentsPage2);
            Assert.IsNotNull(paymentsPage2.DataObject);
            Assert.AreEqual(paymentsPage2.DataObject.PaymentTransactions.Count, 1);
            Assert.AreNotEqual(paymentsPage1.DataObject.PaymentTransactions[0].TransactionId, paymentsPage2.DataObject.PaymentTransactions[0].TransactionId);

            //Test number of rows returned for page.
            var paymentsPage3 = paymentsProxy.GetPayments(1, 2, insertInvoiceResult.DataObject.InsertedEntityId, null, "SP", null, null, null, null, null, null, null);

            Assert.IsNotNull(paymentsPage3);
            Assert.IsNotNull(paymentsPage3.DataObject);
            Assert.AreEqual(paymentsPage3.DataObject.PaymentTransactions.Count, 2);
        }