API – Order

General Online Reference

http://4221117.shop53.dandomain.dk/admin/webapi/endpoints/v1_0/OrderService/help

CreateOrder [POST]

The CreateOrder operation creates a new order in the shop.Input

The operation takes the following input:

  • an authentication key
  • an order

Validation

The following validation will determine whether the operation succeeds:

  • the authentication key must be valid
  • the order header must be valid, ie.:
    • the customer cannot be null
    • the currency cannot be null
    • the site cannot be null
    • the payment method cannot be null
    • the payment method must be valid for the chosen country
    • the payment method must be valid for the chosen B2B group (if any)
    • the shipping method cannot be null
    • the shipping method must be valid for the chosen country
    • the shipping method must be valid for the chosen B2B group (if any)
  • the order must contain at least one order line
  • each order line must be valid, ie.:
    • the product cannot be null
    • the product must be valid (ie. exist for the site and not be hidden/deactivated)
    • the quantity cannot be null – and must be positive

The order CREATE permission is required to perform this operation.

Output

When successful the operation returns an order.

The result will contain the unique order number assigned to the new order.

Remarks

The new order will be created without an order state – this has to be set manually via the shop administration site. It will be treated as incomplete by the shop (see the CompleteOrder service operation).

The order line quantity is not validated against minimum (or maximum) buy amounts.

Request and response format

http://4221117.shop53.dandomain.dk/admin/webapi/endpoints/v1_0/OrderService/help/operations/CreateOrder

Code examples

C# (Console)

 

var key = "05b4df18-6fb5-4249-9506-f376e3177280";
var endpointUrl = "http://{yourshopurl}/admin/webapi/Endpoints/v1_0/OrderService";
var customerId = 17;
var currencyCode = "DKK";
var paymentId = 56;
var shippingId = 48;
var siteId = 26;
var product1Id = 304;
var product2Id = 305;

var order = new
	{
		altDeliveryInfo = new
		{
			address = "Test Address 22",
			address2 = "",
			attention = "Test attention",
			city = "Randers",
			country = "Danmark",
			countryId = 2397,
			ean = "",
			email = "test@test.dk",
			fax = "22222222",
			name = "Test name",
			phone = "22222222",
			state = "",
			zipCode = "8900"

		},
		currencyCode = currencyCode,
		customerId = customerId,
		orderLines = new object[]
			{
				new
					{
						productId = product1Id,
						quantity = 1,
					},
				new
					{
						productId = product2Id,
						quantity = 1,
					}
			}
		,
		paymentId = paymentId,
		shippingId = shippingId,
		siteId = siteId
	};
var jSon = new System.Web.Script.Serialization.JavaScriptSerializer().Serialize(order);
var request = WebRequest.Create(endpointUrl + "/" + key);
request.Method = "POST";
request.ContentType = "text/json";
using (var writeStream = new StreamWriter(request.GetRequestStream()))
{
	writeStream.Write(jSon);
	writeStream.Flush();
	writeStream.Close();
}
try
{
	var response = (HttpWebResponse) request.GetResponse();
	var dataStream = response.GetResponseStream();
	if (dataStream != null)
	{
		using (var reader = new StreamReader(dataStream))
		{
			var responseFromServer = reader.ReadToEnd();
			Console.Write(responseFromServer);
		}
		dataStream.Close();
	}
}
catch (WebException exception)
{
	var exceptionMessage = new StreamReader(exception.Response.GetResponseStream()).ReadToEnd();
	Console.Write(exceptionMessage);
}
Console.ReadLine();

 

PHP

<?php 
//Endpoint url 
$service_url = "http://{yourshopurl}/admin/webapi/Endpoints/v1_0/OrderService"; 
//Your API key 
$api_key = "05b4df18-6fb5-4249-9506-f376e3177280"; 
//existing customer id 
$customer_id = 17; 
//The code of the currency the order is made in 
$currency_code = "DKK"; 
//Existing payment id 
$payment_id = 56; 
//Existing shipping id 
$shipping_id = 48; 
//Existing site id 
$site_id = 26; 
//Existing product ids 
$product1_id = 304; 
$product2_id = 305; 
//Country id 
$country_id = 2397; 
//Data for new order 
$order = array ( "altDeliveryInfo" => array(
			"address" => "Test Address 22",
			"address2" => "",
			"attention" => "Test attention",
			"city" => "Randers",
			"country" => "Danmark",
			"countryId" => $country_id,
			"ean" => "",
			"email" => "test@test.dk",
			"fax" => "22222222",
			"name" => "Test name",
			"phone" => "22222222",
			"state" => "",
			"zipCode" => "8900"
			),
		"currencyCode" => $currency_code,
		"customerId" => $customer_id,
		"orderLines" => array (
			array(
			"productId" => $product1_id,
			"quantity" => 1
			),
			array("productId" => $product2_id,
			"quantity" => 1
			)),
			"paymentId" => $payment_id,
			"shippingId" => $shipping_id,
			"siteId" => $site_id
	);
//Encode to jason string
$data_string = json_encode($order);
//Init request
$ch = curl_init($service_url . '/' . $api_key);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    'Content-Type: application/json',
    'Content-Length: ' . strlen($data_string))
);
//Execute request
$result = curl_exec($ch);
//Print to stdout
var_export($result);


GetOrders [GET]

The GetOrders operation retrieves a list of orders from the shop created within a certain date interval.

Input
The operation takes the following input:
  • an authentication key
  • a date interval, specified with a start date and an end date
Validation
The following validation will determine whether the operation succeeds:
  • the authentication key must be valid
  • the start date cannot be null

The order READ permission is required to perform this operation.

Output
When successful the operation returns a list of orders.
All orders are retrieved – regardless of status. Only orders created within the specified date interval are returned.
Request and response format.

Code examples

C# (Console)

var key = "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX";
var endpointUrl = "http://{yourshopurl}/admin/webapi/Endpoints/v1_0/OrderService";
var startDate = "2000-1-1";
var endDate = "2014-5-7";
var request = WebRequest.Create(endpointUrl + "/" + key + "/GetByDateInterval?start=" + startDate + "&end=" + endDate);
request.Method = "GET";
try
{
	var response = (HttpWebResponse)request.GetResponse();
	var dataStream = response.GetResponseStream();
	if (dataStream != null)
	{
		using (var reader = new StreamReader(dataStream))
		{
			var responseFromServer = reader.ReadToEnd();
			Console.Write(responseFromServer);
		}
		dataStream.Close();
	}
}
catch (WebException exception)
{
	var exceptionMessage = new StreamReader(exception.Response.GetResponseStream()).ReadToEnd();
	Console.Write(exceptionMessage);
}
Console.ReadLine();

 

PHP

<?php
//Endpoint url
$service_url = "http://{yourshopurl}/admin/webapi/Endpoints/v1_0/OrderService/";
//Method
$method_name = "GetByDateInterval";

//Your API key
$api_key = "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX";

//Start date (fifteenth of may two thousand and ten)
$start_date = "2010-5-15";

//End date (seventh of july two thousand and fourteen)
$end_date = "2014-7-7";

$curl = curl_init($service_url . $api_key . "/" . $method_name . "?start=" . $start_date . "&amp;amp;amp;end=" . $end_date);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($curl);

if ($response === false) {
    $info = curl_getinfo($curl);
    curl_close($curl);
    die('An error occured during servicecall. Info: ' . var_export($info));
}
curl_close($curl);
$decoded = json_decode($response);
var_export($decoded);

GetOrder [GET]

The GetOrder operation retrieves an order from the shop based on a unique order number.

Input

The operation takes the following input:

  • an authentication key (see Authentication for details)
  • an order number (id) for the order

Validation

The following validation will determine whether the operation succeeds:

  • the authentication key must be valid (see Authentication for details)
  • the order number cannot be null

The order READ permission is required to perform this operation.

Output

When successful the operation returns an order.

Request and response format

Code examples

C# (Console)

var key = "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX";
var endpointUrl = "http://{yourshopurl}/admin/webapi/Endpoints/v1_0/OrderService";
var orderId = "126";
var request = WebRequest.Create(endpointUrl + "/" + key + "/" + orderId);
request.Method = "GET";
try
{
	var response = (HttpWebResponse)request.GetResponse();
	var dataStream = response.GetResponseStream();
	if (dataStream != null)
	{
		using (var reader = new StreamReader(dataStream))
		{
			var responseFromServer = reader.ReadToEnd();
			Console.Write(responseFromServer);
		}
		dataStream.Close();
	}
}
catch (WebException exception)
{
	var exceptionMessage = new StreamReader(exception.Response.GetResponseStream()).ReadToEnd();
	Console.Write(exceptionMessage);
}
Console.ReadLine();

PHP

<?php
//Endpoint url
$service_url = "http://{yourshopurl}/admin/webapi/Endpoints/v1_0/OrderService/";

//Your API key
$api_key = "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX";

//Ordernumber of existing order
$order_id = 129;

$curl = curl_init($service_url . $api_key . "/" . $order_id);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($curl);

if ($response === false) {
    $info = curl_getinfo($curl);
    curl_close($curl);
    die('An error occured during servicecall. Info: ' . var_export($info));
}
curl_close($curl);
$decoded = json_decode($response);
var_export($decoded);


DeleteOrder [DELETE]

The DeleteOrder operation deletes an order from the shop based on a unique order number.

Input

The operation takes the following input:

  • an authentication key (see Authentication for details)
  • an order number (id) for the order

Validation

The following validation will determine whether the operation succeeds:

  • the authentication key must be valid (see Authentication for details)
  • the order number cannot be null

The order DELETE permission is required to perform this operation.

Output

When successful the operation returns true. If the order was not found it returns false instead.

Request and response format

http://4221117.shop53.dandomain.dk/admin/webapi/endpoints/v1_0/OrderService/help/operations/DeleteOrder

Code examples

C# (Console)

var key = "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX";
var id = "127";
var endpointUrl = "http://{yourshopurl}/admin/webapi/Endpoints/v1_0/OrderService";
var request = WebRequest.Create(endpointUrl + "/" + key + "/" + id);
request.Method = "DELETE";
try
{
	var response = (HttpWebResponse) request.GetResponse();
	var dataStream = response.GetResponseStream();
	if (dataStream != null) 
	{
		using (var reader = new StreamReader(dataStream))
		{
			var responseFromServer = reader.ReadToEnd();
			Console.Write(responseFromServer);
		}
		dataStream.Close();
	}
}
catch (WebException exception)
{
	var exceptionMessage = new StreamReader(exception.Response.GetResponseStream()).ReadToEnd();
	Console.Write(exceptionMessage);
}
Console.ReadLine();

PHP

<?php
//Endpoint url
$service_url = "http://{yourshopurl}/admin/webapi/Endpoints/v1_0/OrderService/";

//Your API key
$api_key = "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX";

//Ordernumber of existing order
$order_id = 129;

$curl = curl_init($service_url . $api_key . "/" . $order_id);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "DELETE");
$response = curl_exec($curl);

if ($response === false) {
    $info = curl_getinfo($curl);
    curl_close($curl);
    die('An error occured during servicecall. Info: ' . var_export($info));
}
curl_close($curl);
$decoded = json_decode($response);
var_export($decoded);


CompleteOrder [PUT]

The CompleteOrder operation completes an order in the shop based on a unique order number.

Input

The operation takes the following input:

  • an authentication key (see Authentication for details)
  • an order number (id) for the order

Validation

The following validation will determine whether the operation succeeds:

  • the authentication key must be valid (see Authentication for details)
  • the order number cannot be null

The order UPDATE permission is required to perform this operation.

Output

When successful the operation returns true.  If the order was not found (or no order number was specified) it returns false instead.

Remarks

Marking orders as complete should be used to indicate whether orders are ready for processing, eg. that payment has been confirmed.

Request and response format
http://4221117.shop53.dandomain.dk/admin/webapi/endpoints/v1_0/OrderService/help/operations/CompleteOrder

Code examples

C# (Console)

var key = "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX";
var endpointUrl="http://{yourshopurl}/admin/webapi/Endpoints/v1_0/OrderService";
var orderId = "127";
var request = WebRequest.Create(endpointUrl + "/" + key + "/CompleteOrder/" + orderId);
request.Method = "PUT";
request.ContentLength = 0;
request.ContentType = "text/json";
try
{
	var response = (HttpWebResponse)request.GetResponse();
	using (var dataStream = response.GetResponseStream())
	{
		if (dataStream != null)
		{
			using (var reader = new StreamReader(dataStream))
			{
				var responseFromServer = reader.ReadToEnd();
				Console.Write(responseFromServer);
			}
			dataStream.Close();
		}
	}
}
catch (WebException exception)
{
	var exceptionMessage = new StreamReader(exception.Response.GetResponseStream()).ReadToEnd();
	Console.Write(exceptionMessage);
}
Console.ReadLine();

PHP

<?php
//Endpoint url
$service_url = "http://{yourshopurl}/admin/webapi/Endpoints/v1_0/OrderService/";

//Your API key
$api_key = "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX";

//Ordernumber of existing order
$order_id = 130;

//Init request
$curl = curl_init($service_url . $api_key . "/CompleteOrder/" . $order_id);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "PUT");
curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Length: ' . "0"));

//Execute request
$response = curl_exec($curl);

if ($response === false) {
    $info = curl_getinfo($curl);
    curl_close($curl);
    die('An error occured during servicecall. Info: ' . var_export($info));
}
curl_close($curl);
$decoded = json_decode($response);
var_export($decoded);


GetOrdersByCustomerNumber [GET]

The GetOrdersByCustomerNumber operation retrieves a list of orders from the shop created by a customer with a certain customer number.

Input

The operation takes the following input:

  • an authentication key (see Authentication for details)
  • a string, specifying the customer number

Validation

The following validation will determine whether the operation succeeds:

  • the authentication key must be valid (see Authentication for details)
  • the customer number cannot be null

The order READ permission is required to perform this operation.

Output

When successful the operation returns a list of orders.

All orders are retrieved – regardless of status. Only orders created by a customer with the given customer number are returned.

Request and response format

http://4221117.shop53.dandomain.dk/admin/webapi/endpoints/v1_0/OrderService/help/operations/GetOrdersByCustomerNumber

GetOrdersInModifiedInterval [GET]

The GetOrders operation retrieves a list of orders from the shop created within a certain date interval that have been modified.

Input

The operation takes the following input:

  • an authentication key (see Authentication for details)
  • a date interval, specified with a start date and an end date

Validation

The following validation will determine whether the operation succeeds:

  • the authentication key must be valid (see Authentication for details)
  • the start date cannot be null

The order READ permission is required to perform this operation.

Output

When successful the operation returns a list of orders.

All orders are retrieved. Only orders created within the specified date interval that have been modified are returned.

Request and response format

http://4221117.shop53.dandomain.dk/admin/webapi/endpoints/v1_0/OrderService/help/operations/GetOrdersInModifiedInterval



GetOrderStates [GET]

The GetOrderStates operation retrieves a list of all order states from the shop.

Input

The operation takes the following input:

Validation

The following validation will determine whether the operation succeeds:

  • the authentication key must be valid (see Authentication for details)

The order READ permission is required to perform this operation.

Output

When successful the operation returns a list of order states.

All order states are retrieved.

Request and response format

http://4221117.shop53.dandomain.dk/admin/webapi/endpoints/v1_0/OrderService/help/operations/GetOrderStates


SetOrderComment [PUT]

The SetOrderComment operation sets the comment on an existing order by the order id.
The operation returns a bool true for success.

Input

The operation takes the following input:

  • an authentication key (see Authentication for details)
  • an integer specifying the order id
  • a string containing the wanted comment

Validation

The following validation will determine whether the operation succeeds:

  • the authentication key must be valid (see Authentication for details)
  • the order id cannot be null

The order UPDATE permission is required to perform this operation.

Output

When successful the operation returns a boolean of true.

Request and response format

http://4221117.shop53.dandomain.dk/admin/webapi/endpoints/v1_0/OrderService/help/operations/SetOrderComment


SetOrderState [PUT]

The SetOrderState operation sets the state of an existing order by the order id.
The operation returns a bool true for success.

Input

The operation takes the following input:

  • an authentication key (see Authentication for details)
  • an integer specifying the order id
  • an integer specifying the order state id

Validation

The following validation will determine whether the operation succeeds:

  • the authentication key must be valid (see Authentication for details)
  • the order id cannot be null
  • the order state id cannot be null

The order UPDATE permission is required to perform this operation.

Output

When successful the operation returns a boolean of true.

Request and response format

http://4221117.shop53.dandomain.dk/admin/webapi/endpoints/v1_0/OrderService/help/operations/SetOrderState


SetTrackNumber [PUT]

The SetTrackNumber operation sets the track number on an existing order by the order id.
The operation returns a bool true for success.

Input

The operation takes the following input:

  • an authentication key (see Authentication for details)
  • an integer specifying the order id
  • a string specifying the track number

Validation

The following validation will determine whether the operation succeeds:

  • the authentication key must be valid (see Authentication for details)
  • the order id cannot be null

The order UPDATE permission is required to perform this operation.

Output

When successful the operation returns a boolean of true.

Request and response format

http://4221117.shop53.dandomain.dk/admin/webapi/endpoints/v1_0/OrderService/help/operations/SetTrackNumber


 


Du finder dokumentationen til Dandomain Webshop her: https://webshop-help.dandomain.dk x