davidtsadler / ebay-sdk-php

An eBay SDK for PHP. Use the eBay API in your PHP projects.
Apache License 2.0
350 stars 346 forks source link

SellingManagerSoldTransaction InvoiceNumber #238

Closed olimortimer closed 5 years ago

olimortimer commented 5 years ago

Just started to use the SDK, but struggling a little...

I'm attempting to retrieve the 'Invoice number' and 'Notes to yourself' data from a Sold listing | Sales record, but can't work out how I can retrieve the 'Invoice number'.

I have the below so far:

    $requestSaleRecord = new Types\GetSellingManagerSaleRecordRequestType();
    $requestSaleRecord->OrderID = $order->OrderID;

    $requestSaleRecord->RequesterCredentials = new Types\CustomSecurityHeaderType();
    $requestSaleRecord->RequesterCredentials->eBayAuthToken = config('ebay.production.authToken');

    $responseSaleRecord = $this->service->GetSellingManagerSaleRecord($requestSaleRecord);

This gives me details on the sales record, and I can access the 'Notes to yourself' using $responseSaleRecord->SellingManagerSoldOrder->NotesToSeller. However, I originally thought $responseSaleRecord->SellingManagerSoldOrder->OrderStatus->SellerInvoiceNumber was the Invoice number but this doesn't seem to be the case. It is however, InvoiceNumber which is part of SellingManagerSoldTransaction. But when I try and access this using $responseSaleRecord->SellingManagerSoldOrder->SellingManagerSoldTransaction->InvoiceNumber it tells me that it is an undefined property.

$responseSaleRecord->SellingManagerSoldOrder->SellingManagerSoldTransaction is a RepeatableType but I can't work out how to use this. When I dump SellingManagerSoldTransaction I receive the following, but I'm a bit out of my depth and would really appreciate some guidance please:


RepeatableType {#8849 ▼
  -data: array:1 [▶]
  -position: 0
  -class: "DTS\eBaySDK\Trading\Types\SellingManagerSoldOrderType"
  -property: "SellingManagerSoldTransaction"
  -expectedType: "DTS\eBaySDK\Trading\Types\SellingManagerSoldTransactionType"
}````
olimortimer commented 5 years ago

Ignore me, I'm being stupid. I just need to loop over the RepeatableType, like I do for GetOrdersRequestType.

foreach ($responseSaleRecord->SellingManagerSoldOrder->SellingManagerSoldTransaction as $SellingManagerSoldTransaction) {
    dd($SellingManagerSoldTransaction->InvoiceNumber);
}