我使用Transaction Details API
withAuthorize.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);
}
}