Tradera.com logotype

Tradera Developer Program

OrderService

Documentation Version 3 > OrderService

Service for orders information.

The following operations are supported. For a formal definition, please review the Service Description.

  • GetSellerOrders

    Returns all orders that have taken place within the specified constraints. The seller in this case is the user for which the call is made for.

    Parameters
    1. request, Holds request information for this call, see GetSellerOrdersRequest for detailed information.
    Returns

    Array of found SellerOrder objects

    Code Example

    The following is a code example in PHP. It prints all order information.

      1:
      2:
      3:
      4:
      5:
      6:
      7:
      8:
      9:
     10:
     11:
     12:
     13:
     14:
     15:
     16:
     17:
     18:
     19:
     20:
     21:
     22:
     23:
     24:
     25:
     26:
     27:
     28:
     29:
     30:
     31:
     32:
     33:
     34:
     35:
     36:
     37:
     38:
     39:
     40:
     41:
     42:
     43:
     44:
     45:
     46:
     47:
     48:
     49:
     50:
     51:
     52:
     53:
     54:
     55:
     56:
     57:
     58:
     59:
     60:
     61:
     62:
     63:
     64:
     65:
     66:
     67:
     68:
     69:
     70:
     71:
     72:
     73:
     74:
     75:
     76:
     77:
     78:
     79:
     80:
     81:
     82:
     83:
     84:
     85:
     86:
     87:
     88:
     89:
     90:
     91:
     92:
     93:
     94:
     95:
     96:
     97:
     98:
     99:
    100:
    101:
    102:
    103:
    104:
    105:
    106:
    107:
    108:
    109:
    110:
    111:
    112:
    113:
    114:
    115:
    116:
    117:
    118:
    119:
    120:
    121:
    122:
    123:
    124:
    125:
    126:
    127:
    128:
    129:
    130:
    131:
    132:
    133:
    134:
    135:
    136:
    137:
    138:
    139:
    140:
    141:
    142:
    143:
    144:
    145:
    146:
    147:
    148:
    149:
    150:
    151:
    152:
    153:
    154:
    155:
    156:
    157:
    
    ////////////////////////////////////////
    // helper functions
    ////////////////////////////////////////
    
    function ItemToString($item){
    	echo '  Item Id: ' . $item -> ItemId . PHP_EOL
    	. '  Title: ' . $item -> Title . PHP_EOL
    	. '  Quantity: ' . $item -> Quantity . PHP_EOL
    	. '  UnitPrice: ' . $item -> UnitPrice . PHP_EOL
    	. '  VAT: ' . $item -> VatRate . PHP_EOL . PHP_EOL;
    }
    function ItemsToString($items){
    	$itemsString = 'Items:' . PHP_EOL;
    	if(is_array($items)){
    		foreach ($items as $item) {
    			$itemsString = $itemsString . ItemToString($item);
    		}
    	}
    	else {
    		$itemsString = $itemsString . ItemToString($items);
    	}
    	return $itemsString;
    }
    
    function PrintOrder($order, $paid = true){
    	$paymentInfo = null;
    	if ($paid){
    		$paymentInfo = 	'Payment info:' . PHP_EOL
    		. '   -' . $order -> SellerOrderPayments -> SellerOrderPayment -> PaymentType . PHP_EOL
    		. '   -' . $order -> SellerOrderPayments -> SellerOrderPayment -> Reference . PHP_EOL
    		. '   -' . $order -> SellerOrderPayments -> SellerOrderPayment -> Amount . PHP_EOL
    		. '   -' . $order -> SellerOrderPayments -> SellerOrderPayment -> PaidDate . PHP_EOL
    		. '   -' . $order -> SellerOrderPayments -> SellerOrderPayment -> PaymentCost . PHP_EOL;
    	}
    
    	echo 'Order #' . $order -> OrderId . PHP_EOL
    	. 'Created: ' . $order -> CreatedDate . PHP_EOL
    	. 'Subtotal (VAT incl): ' . $order -> SubTotal . PHP_EOL
    	. 'Shipping type: ' . $order -> ShippingType . PHP_EOL
    	. 'Shipping cost (VAT incl): ' . $order -> ShippingCost . PHP_EOL
    	. $paymentInfo
    	. 'Items:' . PHP_EOL . ItemsToString($order -> Items -> SellerOrderItem) . PHP_EOL
    	. 'Buyer:' . PHP_EOL
    	. '  UserId: : ' . $order -> Buyer -> UserId . PHP_EOL
    	. '  First Name: : ' . $order -> Buyer -> FirstName . PHP_EOL
    	. '  Last Name: ' . $order -> Buyer -> LastName . PHP_EOL
    	. '  AddressLine1: ' . $order -> Buyer -> AddressLine1 . PHP_EOL
    	. '  ZipCode: ' . $order -> Buyer -> ZipCode . PHP_EOL
    	. '  City: ' . $order -> Buyer -> City . PHP_EOL
    	. '  Country: ' . $order -> Buyer -> CountryName . PHP_EOL
    	. '  E-mail: ' . $order -> Buyer -> Email . PHP_EOL
    	. '  Phone: ' . $order -> Buyer -> Phone . PHP_EOL
    	. '  User alias: ' . $order -> Buyer -> Alias . PHP_EOL
    	. 'Shipping address:' . PHP_EOL
    	. '   -' . $order -> ShipTo -> Name . PHP_EOL
    	. '   -' . $order -> ShipTo -> AddressLine1 . PHP_EOL
    	. '   -' . $order -> ShipTo -> ZipCode . PHP_EOL
    	. '   -' . $order -> ShipTo -> City . PHP_EOL
    	. '   -' . $order -> ShipTo -> CountryName . PHP_EOL . PHP_EOL;
    }
    
    function HandleOrders($orders){
    	if (is_array($orders)) {
    		echo '=============================================' . PHP_EOL
    		.'===============  Paid Orders ================' . PHP_EOL;
    		foreach ($orders as $order) {
    			if(isset($order -> SellerOrderPayments -> SellerOrderPayment)){
    				PrintOrder($order);
    				echo '=============================================' . PHP_EOL;
    			}
    		}
    		echo '=============================================' . PHP_EOL
    		.'=============== Unpaid Orders ===============' . PHP_EOL;
    		foreach ($orders as $order) {
    			if(!isset($order -> SellerOrderPayments -> SellerOrderPayment)){
    				PrintOrder($order, false);
    				echo '=============================================' . PHP_EOL;
    			}
    		}
    	}
    	else {
    		echo '=============================================' . PHP_EOL;
    	 	if(isset($orders -> SellerOrderPayments -> SellerOrderPayment)){
    		echo '===============  Paid Order  ================' . PHP_EOL;
    		}
    		else {
    		echo '=============== Unpaid Order ================' . PHP_EOL;
    
    		}
    		PrintOrder($orders, isset($orders -> SellerOrderPayments -> SellerOrderPayment));
    		echo '=============================================' . PHP_EOL;
    	}
    }
    
    
    ///////////////////////////////////////////////
    // Method call
    ///////////////////////////////////////////////
    try {
    
    	// Replace the following variables with your own key management
    	// $APPLICATION_KEY
    	// $TOKEN
    	// $USER_ID
    	// $APPLICATION_ID
    	$appId = $APPLICATION_ID;
    	$userId = $USER_ID;
    	$token = $TOKEN;
    	$appKey = $APPLICATION_KEY;
    	$orderServiceUrl = 'https://api.tradera.com/v3/OrderService.asmx';
    
    	$orderServiceUrlWithAuth = $orderServiceUrl
    					. '?appId=' . $appId
    					. '&appKey=' . $appKey
    					. '&userId=' . $userId
    					. '&token=' . $token;
    
    	$orderClient = new SoapClient(
    		$orderServiceUrl . '?WSDL',
    		array('location' => $orderServiceUrlWithAuth)
    	);
    	// The dates for which we want to get orders
    	$fromDate = mktime(15, 0, 0, 12, 24, 2015);
    	$toDate = null; // All dates after from date
    
    	$getSellerOrdersRequest = new StdClass();
    	$getSellerOrdersRequest -> FromDate = $fromDate;
    	$getSellerOrdersRequest -> ToDate = $toDate;
    	$getSellerOrdersRequest -> QueryDateMode = 'LastUpdatedDate';
    
    
    	$getSellerOrdersParams = new StdClass();
    	$getSellerOrdersParams -> request = $getSellerOrdersRequest;
    
    
    	echo 'Getting orders for time span: ';
    	echo (isset($fromDate) ? date('c', $fromDate) : 'start of time');
    	echo ' to ';
    	echo (isset($toDate) ? date('c', $toDate) : 'end of time') . PHP_EOL;
    
    	// Make Soap call
    	$getSellerOrdersResponse = $orderClient->GetSellerOrders($getSellerOrdersParams);
    
    	// Handle result
    	if(!isset($getSellerOrdersResponse -> GetSellerOrdersResult -> SellerOrders -> SellerOrder)) {
    		echo 'No orders in time span' . PHP_EOL;
    	}
    	else{
    		$sellerOrders = $getSellerOrdersResponse -> GetSellerOrdersResult -> SellerOrders -> SellerOrder;
    		HandleOrders($sellerOrders);
    	}
    
    
    }
    catch(SoapFault $soapFault) {
    	echo 'Error: ' . $soapFault->faultstring;
    }
    
  • SetSellerOrderAsShipped

    Sets seller order as shipped. The seller in this case is the user for which the call is made for.
    Important! Orders paid for with Klarna must be marked as shipped by the seller.

    Parameters
    1. request, The orderId of the order that is processed.
    Returns

    The orderId of the order that has been marked as shipped.

    Code Example

    This PHP example shows how this method can be used

      1:
      2:
      3:
      4:
      5:
      6:
      7:
      8:
      9:
     10:
     11:
     12:
     13:
     14:
     15:
     16:
     17:
     18:
     19:
     20:
     21:
     22:
     23:
     24:
     25:
     26:
     27:
     28:
     29:
     30:
     31:
     32:
     33:
     34:
     35:
     36:
     37:
     38:
     39:
     40:
     41:
     42:
     43:
     44:
     45:
     46:
     47:
    
    try {
    	// Replace the following variables with your own key management
    	// $APPLICATION_KEY
    	// $TOKEN
    	// $USER_ID
    	// $APPLICATION_ID
    	$appId = $APPLICATION_ID;
    	$userId = $USER_ID;
    	$token = $TOKEN;
    	$appKey = $APPLICATION_KEY;
    	$orderServiceUrl = 'https://api.tradera.com/v3/OrderService.asmx';
    
    	$orderServiceUrlWithAuth = $orderServiceUrl
    					. '?appId=' . $appId
    					. '&appKey=' . $appKey
    					. '&userId=' . $userId
    					. '&token=' . $token;
    
    	$orderClient = new SoapClient(
    		$orderServiceUrl . '?WSDL',
    		array('location' => $orderServiceUrlWithAuth)
    	);
    
    	// Set params
    	$orderId = 90763155;
    
    	$setShippedRequest = new StdClass();
    	$setShippedRequest -> OrderId = $orderId;
    
    	$setShippedParams = new StdClass();
    	$setShippedParams -> request = $setShippedRequest;
    
    	// Make Soap call
    	$setShippedResponse = $orderClient->SetSellerOrderAsShipped($setShippedParams);
    
    	// Handle result
    	if($setShippedResponse -> SetSellerOrderAsShippedResult -> OrderId == $orderId){
    		echo 'SUCCESS' . PHP_EOL;	
    	}
    	else {
    		echo 'FAILED' . PHP_EOL;
    	}
    
    }
    catch(SoapFault $soapFault) {
    	echo 'Error: ' . $soapFault->faultstring;
    }
    

XHTML CSS