首页 > 解决方案 > 交易搜索始终为空

问题描述

我尝试搜索所有交易,但我总是得到空集合。在我的贝宝帐户中,我得到了很多交易。

我尝试了任何其他请求,同样我从所有请求中得到空

BraintreeGateway gw = new BraintreeGateway("access_token$...");
var request = new TransactionSearchRequest().Status.IncludedIn(TransactionStatus.ALL);
var collection = gw.Transaction.Search(request);

foreach (Braintree.Transaction transaction in collection)
{
    Console.WriteLine(transaction.Id);
}

标签: c#paypalbraintree

解决方案


由于ALL不是有效的交易状态,您不会收到任何结果。可能的状态在此处链接。要搜索所有交易,您需要遍历每个交易状态。这是一个例子:

request = new TransactionSearchRequest().
      Status.IncludedIn(TransactionStatus.AUTHORIZED,
                        TransactionStatus.SUBMITTED_FOR_SETTLEMENT
                        ...);  // add other statuses
collection = gateway.Transaction.Search(request);

全面披露:我在布伦特里工作。如果您还有其他问题,请随时联系 支持人员


推荐阅读