コード例 #1
0
ファイル: Program.cs プロジェクト: Deadzone/GroupBuy
        static void Main(string[] args)
        {
            var gate = new ReportingGateway("APILOGIN", "TRANSACTIONKEY");

            //Get all the batches settled
            var batches = gate.GetSettledBatchList();

            Console.WriteLine("All Batches in the last 30 days");
            foreach (var item in batches) {
                Console.WriteLine("Batch ID: {0}, Settled On : {1}", item.ID, item.SettledOn.ToShortDateString());
            }

            Console.WriteLine("*****************************************************");
            Console.WriteLine();

            var transactions = gate.GetTransactionList();
            foreach (var item in transactions) {
                Console.WriteLine("Transaction {0}: Card: {1} for {2} on {3}", item.TransactionID, item.CardNumber, item.SettleAmount.ToString("C"), item.DateSubmitted.ToShortDateString());
            }
            Console.Read();
        }
コード例 #2
0
        public void Reporting_GetBatchStatisticsTest()
        {
            //check login / password
            var sError = CheckLoginPassword();
            Assert.IsTrue(sError == "", sError);

            const string responseString = "<?xml version=\"1.0\" encoding=\"utf-8\"?><getBatchStatisticsResponse xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns=\"AnetApi/xml/v1/schema/AnetApiSchema.xsd\"><messages><resultCode>Ok</resultCode><message><code>I00001</code><text>Successful.</text></message></messages><batch><batchId>3260033</batchId><settlementTimeUTC>2014-03-14T15:20:05Z</settlementTimeUTC><settlementTimeLocal>2014-03-14T08:20:05</settlementTimeLocal><settlementState>settledSuccessfully</settlementState><paymentMethod>creditCard</paymentMethod><marketType>eCommerce</marketType><product>Card Not Present</product><statistics><statistic><accountType>Visa</accountType><chargeAmount>6.98</chargeAmount><chargeCount>2</chargeCount><refundAmount>0.00</refundAmount><refundCount>0</refundCount><voidCount>0</voidCount><declineCount>0</declineCount><errorCount>0</errorCount></statistic></statistics></batch></getBatchStatisticsResponse>";
            LocalRequestObject.ResponseString = responseString;

            var target = new ReportingGateway(ApiLogin, TransactionKey);
	    
            // Get a settlement batch Id.
            var settlementBatches = target.GetSettledBatchList();
            Assert.IsNotNull(settlementBatches);
            Assert.Greater(settlementBatches.Count, 0); // pre-condition
	    
	        // Get the batch statistics of the given batch id.
            var actual = target.GetBatchStatistics(settlementBatches[0].ID);

            Assert.AreEqual(1, actual.Count);
            Assert.AreEqual(settlementBatches[0].ID, actual[0].ID);
            Assert.IsNotNull(actual[0].State);
            Assert.IsNotNull(actual[0].PaymentMethod);
            Assert.IsNotNull(actual[0].MarketType);
            Assert.IsNotNull(actual[0].SettledOn);
            Assert.IsNotNull(actual[0].Product);
            Assert.IsNotNull(actual[0].Charges);

            Assert.AreEqual(1, actual[0].Charges.Count);
            Assert.IsNotNull(actual[0].Charges[0].Amount);
            Assert.IsNotNull(actual[0].Charges[0].CardType);
            Assert.IsNotNull(actual[0].Charges[0].ChargeBackAmount);
            Assert.IsNotNull(actual[0].Charges[0].ChargeBackCount);
            Assert.IsNotNull(actual[0].Charges[0].CorrectionNoticeCount);
            Assert.IsNotNull(actual[0].Charges[0].DeclineCount);
            Assert.IsNotNull(actual[0].Charges[0].RefundAmount);
            Assert.IsNotNull(actual[0].Charges[0].ReturnedItemsAmount);
            Assert.IsNotNull(actual[0].Charges[0].ReturnedItemsCount);
            Assert.IsNotNull(actual[0].Charges[0].VoidCount);
        }
コード例 #3
0
        public void Reporting_GetSettledBatchListTest()
        {
            //check ApiLoginid / TransactionKey
            var sError = CheckApiLoginTransactionKey();
            Assert.IsTrue(sError == "", sError);

            const string responseString = "<?xml version=\"1.0\" encoding=\"utf-8\"?><getSettledBatchListResponse xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns=\"AnetApi/xml/v1/schema/AnetApiSchema.xsd\"><messages><resultCode>Ok</resultCode><message><code>I00001</code><text>Successful.</text></message></messages><batchList><batch><batchId>3319724</batchId><settlementTimeUTC>2014-04-05T15:17:40Z</settlementTimeUTC><settlementTimeLocal>2014-04-05T08:17:40</settlementTimeLocal><settlementState>settledSuccessfully</settlementState><paymentMethod>creditCard</paymentMethod><marketType>eCommerce</marketType><product>Card Not Present</product></batch><batch><batchId>3321516</batchId><settlementTimeUTC>2014-04-06T15:20:51Z</settlementTimeUTC><settlementTimeLocal>2014-04-06T08:20:51</settlementTimeLocal><settlementState>settledSuccessfully</settlementState><paymentMethod>creditCard</paymentMethod><marketType>eCommerce</marketType><product>Card Not Present</product></batch><batch><batchId>3323130</batchId><settlementTimeUTC>2014-04-07T15:20:19Z</settlementTimeUTC><settlementTimeLocal>2014-04-07T08:20:19</settlementTimeLocal><settlementState>settledSuccessfully</settlementState><paymentMethod>creditCard</paymentMethod><marketType>eCommerce</marketType><product>Card Not Present</product></batch><batch><batchId>3332321</batchId><settlementTimeUTC>2014-04-10T15:19:25Z</settlementTimeUTC><settlementTimeLocal>2014-04-10T08:19:25</settlementTimeLocal><settlementState>settledSuccessfully</settlementState><paymentMethod>creditCard</paymentMethod><marketType>eCommerce</marketType><product>Card Not Present</product></batch><batch><batchId>3338386</batchId><settlementTimeUTC>2014-04-12T15:15:33Z</settlementTimeUTC><settlementTimeLocal>2014-04-12T08:15:33</settlementTimeLocal><settlementState>settledSuccessfully</settlementState><paymentMethod>creditCard</paymentMethod><marketType>eCommerce</marketType><product>Card Not Present</product></batch><batch><batchId>3351463</batchId><settlementTimeUTC>2014-04-17T15:16:33Z</settlementTimeUTC><settlementTimeLocal>2014-04-17T08:16:33</settlementTimeLocal><settlementState>settledSuccessfully</settlementState><paymentMethod>creditCard</paymentMethod><marketType>eCommerce</marketType><product>Card Not Present</product></batch><batch><batchId>3357414</batchId><settlementTimeUTC>2014-04-19T15:18:22Z</settlementTimeUTC><settlementTimeLocal>2014-04-19T08:18:22</settlementTimeLocal><settlementState>settledSuccessfully</settlementState><paymentMethod>creditCard</paymentMethod><marketType>eCommerce</marketType><product>Card Not Present</product></batch><batch><batchId>3378742</batchId><settlementTimeUTC>2014-04-29T21:32:25Z</settlementTimeUTC><settlementTimeLocal>2014-04-29T14:32:25</settlementTimeLocal><settlementState>settledSuccessfully</settlementState><paymentMethod>creditCard</paymentMethod><marketType>eCommerce</marketType><product>Card Not Present</product></batch><batch><batchId>3392423</batchId><settlementTimeUTC>2014-05-03T16:19:54Z</settlementTimeUTC><settlementTimeLocal>2014-05-03T09:19:54</settlementTimeLocal><settlementState>settledSuccessfully</settlementState><paymentMethod>creditCard</paymentMethod><marketType>eCommerce</marketType><product>Card Not Present</product></batch></batchList></getSettledBatchListResponse>";
            LocalRequestObject.ResponseString = responseString;

            var target = new ReportingGateway(ApiLogin, TransactionKey);

            List<Batch> actual = null;
            var sErr = "";

            // if choose "USELOCAL", the test should pass with no exception
            // Otherwise, the test might fail for error.
            try
            {
                // Get settled batches for the last 30 days.
                actual = target.GetSettledBatchList();
            }
            catch (Exception e)
            {
                sErr = e.Message;
            }

            Assert.IsNotNull(actual);
            Assert.Greater(actual.Count, 0);  // can be 0; better not be.

            foreach (var batch in actual)
            {
                Assert.AreEqual("settledSuccessfully", batch.State);
            }
        }
コード例 #4
0
        public void Reporting_GetTransactionListTest()
        {
            //check ApiLoginid / TransactionKey
            var sError = CheckApiLoginTransactionKey();
            Assert.IsTrue(sError == "", sError);

            const string responseString = "<?xml version=\"1.0\" encoding=\"utf-8\"?><getTransactionListResponse xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns=\"AnetApi/xml/v1/schema/AnetApiSchema.xsd\"><messages><resultCode>Ok</resultCode><message><code>I00001</code><text>Successful.</text></message></messages><transactions><transaction><transId>2209067941</transId><submitTimeUTC>2014-03-21T23:16:25Z</submitTimeUTC><submitTimeLocal>2014-03-21T16:16:25</submitTimeLocal><transactionStatus>settledSuccessfully</transactionStatus><accountType>Visa</accountType><accountNumber>XXXX1111</accountNumber><settleAmount>3.99</settleAmount><marketType>eCommerce</marketType><product>Card Not Present</product></transaction><transaction><transId>2209067934</transId><submitTimeUTC>2014-03-21T23:16:07Z</submitTimeUTC><submitTimeLocal>2014-03-21T16:16:07</submitTimeLocal><transactionStatus>settledSuccessfully</transactionStatus><accountType>Visa</accountType><accountNumber>XXXX1111</accountNumber><settleAmount>2.99</settleAmount><marketType>eCommerce</marketType><product>Card Not Present</product></transaction><transaction><transId>2209067927</transId><submitTimeUTC>2014-03-21T23:15:44Z</submitTimeUTC><submitTimeLocal>2014-03-21T16:15:44</submitTimeLocal><transactionStatus>settledSuccessfully</transactionStatus><accountType>Visa</accountType><accountNumber>XXXX1111</accountNumber><settleAmount>1.99</settleAmount><marketType>eCommerce</marketType><product>Card Not Present</product></transaction><transaction><transId>2209060796</transId><submitTimeUTC>2014-03-21T21:20:18Z</submitTimeUTC><submitTimeLocal>2014-03-21T14:20:18</submitTimeLocal><transactionStatus>settledSuccessfully</transactionStatus><accountType>Visa</accountType><accountNumber>XXXX1111</accountNumber><settleAmount>1.99</settleAmount><marketType>eCommerce</marketType><product>Card Not Present</product></transaction></transactions></getTransactionListResponse>";
            LocalRequestObject.ResponseString = responseString;

            var target = new ReportingGateway(ApiLogin, TransactionKey);

            // Get a settlement batch Id.
            var settlementBatches = target.GetSettledBatchList();

            Assert.IsNotNull(settlementBatches);
            Assert.Greater(settlementBatches.Count, 0); // pre-condition
	    
            List<Transaction> actual = null;
            string sErr = "";

            // if choose "USELOCAL", the test should pass with no exception
            // Otherwise, the test might fail for error, i.e. duplicated request.
            try
            {
                // Get a particular settled transactions.
                actual = target.GetTransactionList(settlementBatches[0].ID);
            }
            catch (Exception e)
            {
                sErr = e.Message;
            }

            Assert.IsNotNull(actual);
            Assert.Greater(actual.Count, 0);

            foreach (var tx in actual)
	        {
                Assert.IsNotNull(tx.TransactionID);
                Assert.IsNotNull(tx.DateSubmitted);
                Assert.IsNotNull(tx.Status);
                Assert.IsNotNull(tx.CardType);
                Assert.IsNotNull(tx.CardNumber);
                Assert.IsNotNull(tx.SettleAmount);
                Assert.IsNotNull(tx.MarketType);
                Assert.IsNotNull(tx.Product);
                Assert.IsNull(tx.MobileDeviceID);
                Assert.AreEqual(tx.HasReturnedItems, NullableBooleanEnum.Null);

                if (tx.Subscription == null) continue;
                Assert.Greater(tx.Subscription.ID, 0);
                Assert.Greater(tx.Subscription.PayNum, 0);
	        }
        }
コード例 #5
0
        public void Reporting_GetSettledBatchListTest_NoRecord()
        {
            //check ApiLoginid / TransactionKey
            string sError = CheckApiLoginTransactionKey();
            Assert.IsTrue(sError == "", sError);

            const string responseString = "<?xml version=\"1.0\" encoding=\"utf-8\"?><getSettledBatchListResponse xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns=\"AnetApi/xml/v1/schema/AnetApiSchema.xsd\"><messages><resultCode>Ok</resultCode><message><code>I00004</code><text>No records found.</text></message></messages></getSettledBatchListResponse>";
            LocalRequestObject.ResponseString = responseString;

            var target = new ReportingGateway(ApiLogin, TransactionKey);

            List<Batch> actual = null;
            var sErr = "";

            // if choose "USELOCAL", the test should pass with no exception
            // Otherwise, the test might fail for error.
            try
            {
                // Get settled batches for the next two days (the 2 days in future).
                actual = target.GetSettledBatchList(DateTime.UtcNow, DateTime.UtcNow.AddDays(2));
            }
            catch (Exception e)
            {
                sErr = e.Message;
            }

            Assert.IsNotNull(actual);
            Assert.AreEqual(0, actual.Count);
        }