1

我使用Transaction Details APIwithAuthorize.Net C# SDK直接从Authorize.Net 网站使用以下代码获取过去 30 天内所有交易的列表:

        //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());
        }

它工作正常。我试图通过添加以下内容来获取LineItems每个列表:Transaction

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

虽然它没有显示任何LineItems内容,但我什至设置了一个断点并看到它总是LineItems为每个事务显示 0,即使我可以登录 Web 界面并LineItems在事务详细信息报告中查看。

在此处输入图像描述

我究竟做错了什么?如何LineItems使用 ? 查看每笔交易Authorize.Net C# SDK

答案:(感谢 SO 用户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);
            }
        }
4

1 回答 1

3

GetTransactionList 返回有关交易的有限信息。在每笔交易中,执行 GetTransactionDetails:

GetTransactionList此函数返回指定批次 ID 的有限事务详细信息。

GetTransactionDetails此函数返回指定事务 ID 的完整事务详细信息。

发现自 Authorize.net 的 XML API 库查看 XML 部分的底部

于 2012-06-01T14:54:49.240 回答