简体   繁体   中英

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. Like the API responds to my requests with a lot of data, except half of it is null or otherwise not set. I'm having this problem with the TransactionType objects that are returned.

There are two things that I actually want to find, PayPal transaction id and if the order was actually paid for. 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? 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.

I've seen this post , but even after adding DetailLevelCodeType.ReturnAll to the DetailLevelList , there are no ExternalTransaction for the transactions within the order.

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>()


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.

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

GetItemTransactions will give you what you need. I've used it to obtain the PayPal transaction ID for transactions many times in the past without any problems. Specifically, Transaction.ExternalTransaction.ExternalTransactionID .

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