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(); }
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); } }
public void Reporting_GetTransactionListTest_DateRange() { //check ApiLoginid / TransactionKey var sError = CheckApiLoginTransactionKey(); Assert.IsTrue(sError == "", sError); var responseStrings = new[] { "<?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>3321516</batchId><settlementTimeUTC>2014-04-06T15:20:51Z</settlementTimeUTC><settlementTimeLocal>2014-04-06T08:20:51</settlementTimeLocal><settlementState>settledSuccessfully</settlementState><paymentMethod>creditCard</paymentMethod></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></batch></batchList></getSettledBatchListResponse>", "<?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>2210220767</transId><submitTimeUTC>2014-04-06T08:48:39Z</submitTimeUTC><submitTimeLocal>2014-04-06T01:48:39</submitTimeLocal><transactionStatus>settledSuccessfully</transactionStatus><firstName>Sue</firstName><lastName>Zhu</lastName><accountType>Visa</accountType><accountNumber>XXXX1111</accountNumber><settleAmount>1.31</settleAmount><subscription><id>2016601</id><payNum>2</payNum></subscription></transaction></transactions></getTransactionListResponse>", "<?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>2210248566</transId><submitTimeUTC>2014-04-07T08:53:45Z</submitTimeUTC><submitTimeLocal>2014-04-07T01:53:45</submitTimeLocal><transactionStatus>settledSuccessfully</transactionStatus><firstName>Sue</firstName><lastName>Zhu</lastName><accountType>Visa</accountType><accountNumber>XXXX1111</accountNumber><settleAmount>1.31</settleAmount><subscription><id>2017665</id><payNum>2</payNum></subscription></transaction></transactions></getTransactionListResponse>" }; LocalRequestObject.ResponseStrings = responseStrings; LocalRequestObject.ResponseStringCount = 0; var target = new ReportingGateway(ApiLogin, TransactionKey); List<Transaction> actual = null; var sErr = ""; // if choose "USELOCAL", the test should pass with no exception // Otherwise, the test might fail for error, i.e. duplicated request. try { // Get settled transactions within a date range. actual = target.GetTransactionList(DateTime.Today.AddDays(-30), DateTime.Today); } catch (Exception e) { sErr = e.Message; } Assert.IsNotNull(actual); 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.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); } }
public void Reporting_GetTransactionDetailsTest() { //check ApiLoginid / TransactionKey string sError = CheckApiLoginTransactionKey(); Assert.IsTrue(sError == "", sError); const string responseString = "<?xml version=\"1.0\" encoding=\"utf-8\"?><getTransactionDetailsResponse 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><transaction><transId>2209067941</transId><submitTimeUTC>2014-03-21T23:16:25.797Z</submitTimeUTC><submitTimeLocal>2014-03-21T16:16:25.797</submitTimeLocal><transactionType>authCaptureTransaction</transactionType><transactionStatus>settledSuccessfully</transactionStatus><responseCode>1</responseCode><responseReasonCode>1</responseReasonCode><responseReasonDescription>Approval</responseReasonDescription><authCode>UUV1S1</authCode><AVSResponse>Y</AVSResponse><cardCodeResponse>P</cardCodeResponse><batch><batchId>3282059</batchId><settlementTimeUTC>2014-03-22T15:21:44.343Z</settlementTimeUTC><settlementTimeLocal>2014-03-22T08:21:44.343</settlementTimeLocal><settlementState>settledSuccessfully</settlementState></batch><authAmount>3.99</authAmount><settleAmount>3.99</settleAmount><taxExempt>false</taxExempt><payment><creditCard><cardNumber>XXXX1111</cardNumber><expirationDate>XXXX</expirationDate><cardType>Visa</cardType></creditCard></payment><recurringBilling>false</recurringBilling><customerIP>10.1.186.51</customerIP><product>Card Not Present</product><marketType>eCommerce</marketType></transaction></getTransactionDetailsResponse>"; LocalRequestObject.ResponseString = responseString; var target = new ReportingGateway(ApiLogin, TransactionKey); var sErr = ""; List<Transaction> settledTransactions = null; try { // Get the last 30-day settled transactions. settledTransactions = target.GetTransactionList(); } catch (Exception e) { sErr = e.Message; } Assert.IsNotNull(settledTransactions); Assert.Greater(settledTransactions.Count, 0); // pre-condition Transaction actual = null; // if choose "USELOCAL", the test should pass with no exception // Otherwise, the test might fail for error, i.e. duplicated request. try { // Get the transaction details of the settled transaction. actual = target.GetTransactionDetails(settledTransactions[0].TransactionID); } catch (Exception e) { sErr = e.Message; } Assert.IsNotNull(actual); Assert.IsNotNull(actual.TransactionID); Assert.IsNotNull(actual.BatchSettledOn); Assert.IsNotNull(actual.BatchSettlementID); // This is a settled transaction. The status does not have to be "settledSuccessfully" though. // For instance, it can be "void", or "refundSuccessfully" etc Assert.IsNotNull(actual.BatchSettlementState); Assert.IsNotNull(actual.Status); Assert.IsNotNull(actual.AVSCode); Assert.IsNotNull(actual.AVSResponse); Assert.IsNotNull(actual.AuthorizationCode); Assert.IsNotNull(actual.AuthorizationAmount); Assert.IsNotNull(actual.ResponseCode); Assert.IsNotNull(actual.SettleAmount); Assert.IsNotNull(actual.CardNumber); Assert.IsNotNull(actual.CardExpiration); Assert.IsNotNull(actual.CardType); var subscription = actual.Subscription; if (subscription != null) { Assert.Greater(subscription.ID, 0); Assert.Greater(subscription.PayNum, 0); } }