3

I'm trying to get a list of my orders (items sold) using the api davidtsadler/ebay-sdk-php

https://github.com/davidtsadler/ebay-sdk-php

but I can't get a list.

I found some examples but those didn't work for me.

$service = new Services\TradingService(array(
  'apiVersion' => $this->config['tradingApiVersion'],
  'siteId' => Constants\SiteIds::ES,
  'sandbox'=> true,
));
/**
 * Create the request object.
 *
 * For more information about creating a request object, see:
 * http://devbay.net/sdk/guides/getting-started/#request-object
 */
$request = new Types\GetMyeBaySellingRequestType();
/**
 * An user token is required when using the Trading service.
 *
 * For more information about getting your user tokens, see:
 * http://devbay.net/sdk/guides/application-keys/
 */

$args = array(
  "OrderStatus"   => "Completed",
  "OrderStatus"   => "All",
  "SortingOrder"  => "Ascending",
  //"OrderRole"     => "Seller",
  "ModTimeFrom"   => new \DateTime('2015-01-01'),
);

$getOrders = new Types\GetOrdersRequestType($args);
$getOrders->RequesterCredentials = new Types\CustomSecurityHeaderType();
$getOrders->RequesterCredentials->eBayAuthToken = $this->config['sandbox']['userToken'];
$getOrders->IncludeFinalValueFee = true;
$getOrders->Pagination = new Types\PaginationType();
$getOrders->Pagination->EntriesPerPage = 200;
//$getOrders->OrderIDArray = new Types\OrderIDArrayType();
$getOrdersPageNum = 10;

//$getOrders->OrderIDArray->OrderID[] = '110169861526-110169862570'; //'200980916385-1185594371010'
$response = $service->getOrders($getOrders);

echo print_r($response,1);

foreach ($response->OrderArray->Order as $order) {
  printf("SaleRecordID %s\n", $order->ShippingDetails->SellingManagerSalesRecordNumber);
}

It returns 0 pages although I have 'sold' and paid items in my Ebay private account.

DTS\eBaySDK\Trading\Types\GetOrdersResponseType Object
(
    [values:DTS\eBaySDK\Types\BaseType:private] => Array
        (
            [Timestamp] => DateTime Object
                (
                    [date] => 2015-10-05 15:14:01.578000
                    [timezone_type] => 2
                    [timezone] => Z
                )

            [Ack] => Success
            [Version] => 927
            [Build] => E927_INTL_API_17590342_R1
            [PaginationResult] => DTS\eBaySDK\Trading\Types\PaginationResultType Object
                (
                    [values:DTS\eBaySDK\Types\BaseType:private] => Array
                        (
                            [TotalNumberOfPages] => 0
                            [TotalNumberOfEntries] => 0
                        )

                    [attachment:DTS\eBaySDK\Types\BaseType:private] => Array
                        (
                            [data] => 
                            [mimeType] => 
                        )

                )

            [HasMoreOrders] => 
            [OrderArray] => DTS\eBaySDK\Trading\Types\OrderArrayType Object
                (
                    [values:DTS\eBaySDK\Types\BaseType:private] => Array
                        (
                        )

                    [attachment:DTS\eBaySDK\Types\BaseType:private] => Array
                        (
                            [data] => 
                            [mimeType] => 
                        )

                )

            [OrdersPerPage] => 100
            [PageNumber] => 1
            [ReturnedOrderCountActual] => 0
        )

    [attachment:DTS\eBaySDK\Types\BaseType:private] => Array
        (
            [data] => 
            [mimeType] => 
        )

)
Luuklag
  • 3,897
  • 11
  • 38
  • 57
Rafa Cuestas
  • 433
  • 1
  • 5
  • 13

1 Answers1

2

Well I found myself the solution! It must be pased a period of time in the call off the GetOrdersRequestType($args)

"CreateTimeFrom" => new \DateTime('2015-01-01'), "CreateTimeTo" => new \DateTime('2015-10-06'),

if not don't will retrieve nothing.

The working example :

$service = new Services\TradingService(array(
  'apiVersion' => $this->config['tradingApiVersion'],
  'siteId' => Constants\SiteIds::ES,
  'sandbox'=> true,
));
/**
 * Create the request object.
 *
 * For more information about creating a request object, see:
 * http://devbay.net/sdk/guides/getting-started/#request-object
 */
$request = new Types\GetMyeBaySellingRequestType();
/**
 * An user token is required when using the Trading service.
 *
 * For more information about getting your user tokens, see:
 * http://devbay.net/sdk/guides/application-keys/
 */

$args = array(
  "OrderStatus"   => "Completed",
  "OrderStatus"   => "All",
  "SortingOrder"  => "Ascending",
  //"OrderRole"     => "Seller",
  "CreateTimeFrom"   => new \DateTime('2015-01-01'),
  "CreateTimeTo"   => new \DateTime('2015-10-06'),
);

$getOrders = new Types\GetOrdersRequestType($args);
$getOrders->RequesterCredentials = new Types\CustomSecurityHeaderType();
$getOrders->RequesterCredentials->eBayAuthToken = $this->config['sandbox']['userToken'];
$getOrders->IncludeFinalValueFee = true;
$getOrders->Pagination = new Types\PaginationType();
$getOrders->Pagination->EntriesPerPage = 3;
//$getOrders->OrderIDArray = new Types\OrderIDArrayType();
$getOrdersPageNum = 1;


//$getOrders->OrderIDArray->OrderID[] = '200980916385-1185594371010'; //'200980916385-1185594371010'
$response = $service->getOrders($getOrders);
echo print_r($response,1);

foreach ($response->OrderArray->Order as $order) {
  printf("SaleRecordID %s\n", $order->ShippingDetails->SellingManagerSalesRecordNumber);
}
exit(0);
Rafa Cuestas
  • 433
  • 1
  • 5
  • 13
  • there is a problem with this code, if user completed the order but not paid, it happened to me. Need somehow to check, if paid – jmp Nov 08 '16 at 22:54