简体   繁体   English

我可以使用eBay API获取eBay订单的PayPal交易ID吗?

[英]Can I get PayPal transaction id for an eBay order using eBay API?

I'm trying to find my way through eBay API and I find it quite confusing. 我试图通过eBay API找到自己的方式,我发现它很混乱。 Like the API responds to my requests with a lot of data, except half of it is null or otherwise not set. 就像API用大量数据响应我的请求,除了一半是空的或者没有设置。 I'm having this problem with the TransactionType objects that are returned. 我遇到了返回的TransactionType对象的这个问题。

There are two things that I actually want to find, PayPal transaction id and if the order was actually paid for. 我实际上想要找到两件事,即PayPal交易ID以及订单是否实际支付。 Let's skip the second one (it'll probably get it's own question if needed). 让我们跳过第二个(如果需要,它可能会得到它自己的问题)。

So my question is, can PayPal transaction id be actually extracted from eBay transaction using eBay API? 所以我的问题是, PayPal交易ID是否可以使用eBay API实际从eBay交易中提取? If yes, how do I do that? 如果是的话,我该怎么做?

Based on my findings, this id should appear in TransactionType.ExternalTransaction , but for my test auction (which ended when I "bought" it using another sandbox account and successfully "paid" for it using PayPal sandbox), there is nothing there. 根据我的发现,这个id应该出现在TransactionType.ExternalTransaction ,但是对于我的测试拍卖(当我用另一个沙盒帐户“购买”它并使用PayPal沙箱成功“支付”它时结束),那里什么都没有。

I've seen this post , but even after adding DetailLevelCodeType.ReturnAll to the DetailLevelList , there are no ExternalTransaction for the transactions within the order. 我已经看过这篇文章 ,但即使将DetailLevelCodeType.ReturnAll添加到DetailLevelList ,订单中的交易也没有ExternalTransaction

var apiCall = new GetOrdersCall(apiContext);
apiCall.NumberOfDays = 1;
apiCall.DetailLevelList = new DetailLevelCodeTypeCollection()
{
    DetailLevelCodeType.ReturnAll
};
apiCall.Execute();

Note, when I access transactions within the order I use SomeOrder.TransactionArray.Cast<eBay.Service.Core.Soap.TransactionType>() 注意,当我在订单中访问交易时,我使用SomeOrder.TransactionArray.Cast<eBay.Service.Core.Soap.TransactionType>()


It appears that if I explicitly ask for the transaction using GetItemTransactionsCall (setting DetailLevel to ReturnAll appears to be necessary) I can actually get information about the PayPal transaction. 看来,如果我使用GetItemTransactionsCall明确要求交易(将DetailLevel设置为ReturnAll似乎是必要的),我实际上可以获得有关PayPal交易的信息。

var apiCall = new GetItemTransactionsCall(apiContext);
apiCall.DetailLevelList = new DetailLevelCodeTypeCollection()
{
    DetailLevelCodeType.ReturnAll
};
apiCall.ItemID = "someItemId";
apiCall.Execute();
var trans = apiCall.TransactionList.Cast<TransactionType>().ToList();
var extTrans = trans.First().ExternalTransaction.Cast<ExternalTransactionType>().ToList();
var payPalId = extTrans.First().ExternalTransactionID;

I'm only slightly disappointed that I can't pull all information about orders that were placed using one call to the API (there probably is still a way to get all the informations that I need using minimal amount of bulk calls). 我有点失望的是,我无法获取有关使用一次调用API的订单的所有信息(可能仍有一种方法可以使用最少量的批量调用获取所需的所有信息)。

GetItemTransactions will give you what you need. GetItemTransactions将为您提供所需。 I've used it to obtain the PayPal transaction ID for transactions many times in the past without any problems. 我曾经多次使用它来获取交易的PayPal交易ID而没有任何问题。 Specifically, Transaction.ExternalTransaction.ExternalTransactionID . 具体来说, Transaction.ExternalTransaction.ExternalTransactionID

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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