I'm using the `Transaction Details API` with the `Authorize.Net C# SDK` to get a list of all transactions in the past 30 days using the following code directly from the Authorize.Net website:
//open a call to the Gateway
var gate = new ReportingGateway("myAPILogin", "myTransactionKey");
//Get all the batches settled
var batches = gate.GetSettledBatchList();
Console.WriteLine("All Batches in the last 30 days");
//Loop each batch returned
foreach (var item in batches)
{
Console.WriteLine("Batch ID: {0}, Settled On : {1}", item.ID,
item.SettledOn.ToShortDateString());
}
Console.WriteLine("*****************************************************");
Console.WriteLine();
//get all Transactions for the last 30 days
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());
}
and it works properly. I am trying to get the list of `LineItems` for each `Transaction` by adding this:
...
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());
foreach (var li in item.LineItems)
{
Console.WriteLine(" LineItem ID: {0} Name: {1} Quantity: {2} Unit Price: {3}",
li.ID, li.Name, li.Quantity, li.UnitPrice);
}
}
It doesn't show any `LineItems` though, I even set a break point and saw that it always shows 0 `LineItems` for each transaction, even though I can log into the web interface and view the `LineItems` in the transaction detail reports.
What am I doing wrong? How do I view `LineItems` of each transaction using the `Authorize.Net C# SDK`?
Solved! Go to Solution.
06-01-2012 07:20 AM - edited 06-01-2012 07:25 AM
Answered on StackOverflow - http://stackoverflow.com/a/10852600/585552
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());
var details = gate.GetTransactionDetails(item.TransactionID);
foreach (var li in details.LineItems)
{
Console.WriteLine(" LineItem ID: {0} Name: {1} Quantity: {2} Unit Price: {3}",
li.ID, li.Name, li.Quantity, li.UnitPrice);
}
}
06-01-2012 07:59 AM - edited 06-01-2012 08:04 AM
Answered on StackOverflow - http://stackoverflow.com/a/10852600/585552
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());
var details = gate.GetTransactionDetails(item.TransactionID);
foreach (var li in details.LineItems)
{
Console.WriteLine(" LineItem ID: {0} Name: {1} Quantity: {2} Unit Price: {3}",
li.ID, li.Name, li.Quantity, li.UnitPrice);
}
}
06-01-2012 07:59 AM - edited 06-01-2012 08:04 AM