简体   繁体   中英

Authorize.Net Transaction Details API Not Returning LineItems

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 ?

ANSWER: (thanks to SO User Josh )

        ...
        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);
            }
        }

GetTransactionList returns limited information about the transaction. On each transaction, do a GetTransactionDetails:

GetTransactionList This function returns limited transaction details for a specified batch ID.

GetTransactionDetails This function returns full transaction details for a specified transaction ID.

Found from Authorize.net's XML API library Look towards the bottom on the XML section

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM