Order

Create Order

post
​

https://<domain>/<api prefix>/<version>/commerce/create-order/
This API Endpoint will create an order.
Request
Response
Request
Headers
apikey
required
string
apikey
Authorization
required
string
Bearer access token
Body Parameters
uid
required
string
user id
total_amount
required
number
Order total amount
address
required
object
Is an object for address details, the object should contain address_first_name, address_last_name, address_mail_id, address_phone_number, address_name_line, address_premise, address_locality, address_postal_code, address_country_code, and address_state_code
products
required
array
Must be an array of products, product object should contain product_id, quantity, unit_price, discount, and total_amount.
Response
200: OK
​HTTP/1.1 200 OK
Content-Type: application/json
​
Body:
{
"status_code": 200,
"errors": {},
"data": {}
}

Sample code

Node

var request = require('request');
var options = {
'method': 'POST',
'url': 'https://<domain>/<api prefix>/<version>/commerce/create-order/',
'headers': {
'apikey': '<apikey>'
},
body: JSON.stringify(
{
"products": [
{
"product_id": <product id>,
"quantity":<product quantity>,
"unit_price":<product unit price>,
"discount":<product total dicount>,
"total_amount":<lineitem total amount>
}
],
"address": {
"address_first_name": "<address first name>",
"address_last_name": "<address last name>",
"address_mail_id": "<address email id>",
"address_phone_number": "<address phone number>",
"address_name_line": "<address house number>",
"address_premise": "<address street>",
"address_locality": "<address locality>",
"address_postal_code": "<address post code>",
"address_country_code": "<address country code>",
"address_state_code": "<address state code>"
},
"total_amount":<total order amount>,
"uid":"<user id>"
}
)
​
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
​

PHP

<?php
​
$curl = curl_init();
​
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://<domain>/<api prefix>/<version>/commerce/create-order/',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS =>'{
"products": [
{
"product_id":<product id>,
"quantity":<product quantity>,
"unit_price":<product unit price>,
"discount":<product total dicount>,
"total_amount":<lineitem total amount>
}
],
"address":{
"address_first_name":"<address first name>",
"address_last_name":"<address last name>",
"address_mail_id":"<address email id>",
"address_phone_number":"<address phone number>",
"address_name_line":"<address house number>",
"address_premise":"<address street>",
"address_locality":"<address locality>",
"address_postal_code":"<address post code>",
"address_country_code":"<address country code>",
"address_state_code":"<address state code>"
},
"total_amount":<total order amount>,
"uid":"<user id>"
}',
CURLOPT_HTTPHEADER => array(
'apikey: <apikey>'
),
));
​
$response = curl_exec($curl);
​
curl_close($curl);
echo $response;

Error Responses

Status Code

Error Type

Field

Description

400

Validation Error

products

This field is required. Must have one product.

400

Validation Error

product_id

Invalid product_id <product id>

400

Validation Error

quantity

Invalid quantity. Quantity must be greater than 1.

400

Validation Error

address_state_code

Invalid address_state_code

400

Validation Error

address_country_code

Invalid address_country_code

400

Validation Error

uid

Invalid user id

400

Validation Error

total_amount

Invalid order total_amount. Order total_amount must be the sum of line item total_amount.

Renewal or Upgrade

post
​

https://<domain>/<api prefix>/<version>/commerce/upgrade-renewal-package/
This API Endpoint will help to package upgrade or renewal
Request
Response
Request
Headers
apikey
required
string
apikey
Authorization
required
string
Bearer access token
Body Parameters
order_type
required
string
Possible values are upgrade,renewal
uid
required
string
user id
order_total
required
number
Order tatal amount
address_state_code
required
string
Adress state code
address_country_code
required
string
Adresss county code
address_postal_code
required
string
Adress postal code
address_locality
required
string
Address locality
address_premise
required
string
Address street
address_name_line
required
string
Address house number
address_phone_number
required
string
Address phone number
address_mail_id
required
string
Address E-mail ID
address_last_name
required
string
Address last name
address_first_name
required
string
Address first name
discount
optional
number
Total discount
unit_price
required
number
unit price of the product
product_id
required
number
product id
Response
200: OK
​

Sample code

Node

var request = require('request');
var options = {
'method': 'POST',
'url': 'https://<domain>/<api prefix>/<version>/commerce/upgrade-renewal-package/',
'headers': {
'apikey': '<apikey>'
},
body: JSON.stringify(
{
"product_id": <product id>,
"unit_price": <product unit price>,
"discount": <total discount amount>,
"order_total": <order total amount>
"address_first_name": "<address first name>",
"address_last_name": "<address last name>",
"address_mail_id": "<address email id>",
"address_phone_number": "<address phone number>",
"address_name_line": "<address house number>",
"address_premise": "<address street>",
"address_locality": "<address locality>",
"address_postal_code": "<address post code>",
"address_country_code": "<address country code>",
"address_state_code": "<address state code>"
"uid":"<user id>",
"order_type":"<order type>"
}
)
​
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
​

PHP

<?php
​
$curl = curl_init();
​
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://<domain>/<api prefix>/<version>/commerce/create-order/',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS =>'{
"product_id": <product id>,
"unit_price": <product unit price>,
"discount": <total discount amount>,
"order_total": <order total amount>
"address_first_name": "<address first name>",
"address_last_name": "<address last name>",
"address_mail_id": "<address email id>",
"address_phone_number": "<address phone number>",
"address_name_line": "<address house number>",
"address_premise": "<address street>",
"address_locality": "<address locality>",
"address_postal_code": "<address post code>",
"address_country_code": "<address country code>",
"address_state_code": "<address state code>"
"uid":"<user id>",
"order_type":"<order type>"
}',
CURLOPT_HTTPHEADER => array(
'apikey: <apikey>'
),
));
​
$response = curl_exec($curl);
​
curl_close($curl);
echo $response;

Error Responses

Status Code

Error Type

Field

Description

400

Validation Error

product_id

Invalid product_id <product id>

400

Validation Error

address_postcode

Invalid postcode

400

Validation Error

address_state_code

Invalid address_state_code

400

Validation Error

address_first_name

Invalid address_first_name

400

Validation Error

address_last_name

Invalid address_last_name

400

Validation Error

address_country_code

Invalid address_country_code

400

Validation Error

uid

Invalid user id

400

Validation Error

product_id

Couldn't process your request. Renewal package not same as the existing package. Please check your package and try again.

400

Validation Error

product_id

Couldn't process your request. May be you reached maximum upgrade or invalid package id.

400

Validation Error

order_total

Discount must be less than unit_price.

400

Validation Error

order_total

Order total must be difference of unit_price and discount.

400

Validation Error

uid

You are not placed into the genealogy yet. Please wait until the placement completes.

400

Validation Error

uid

There exists a package upgrade in processing. Please wait until the process complete or contact the site administrator.

400

Validation Error

uid

System initiated package auto upgrade. Please wait until the process complete.

400

Validation Error

uid

Payment for previous purchase is not completed yet. Please wait until the payment complete or cancel that payment.

400

Validation Error

uid

There exists a package upgrade in processing. Please wait until the process complete or contact the site administrator.

400

Validation Error

uid

You cannot perform package upgrade because you have an active refund request.

400

Validation Error

product_id

The supplied package same as the existing package. Please change your package and try again.

400

Validation Error

order_type

Invalid order_type. Supported values are upgrade,renewal

400

Validation Error

product_id

You already have an active package.

List Orders

get
​

https://<domain>/<api prefix>/<version>/commerce/all-orders/
get the list of orders
Request
Response
Request
Headers
apikey
required
string
apikey
Authorization
required
string
Bearer access token
Query Parameters
order number
optional
string
order number
period
optional
string
period
category
optional
string
category
limit
optional
string
limit
Response
200: OK
HTTP/1.1 200 OK
Content-Type: application/json
​
Body:
{
"status_code": 200,
"errors": {},
"data": {
"orders": [
{
"id": <id>,
"uid": <uid>,
"order_number": <order number>,
"data": <data>,
"order_total": <order_total>,
"currency_symbol": <currency_symbol>,
"currency_code": <currency_code>,
"order_type": <order_type>,
"status": <status>,
"created": <created>,
"modified": <modified>,
"shipping_id": <shipping_id>,
"billing_id": <billing_id>
}
],
"filter_data": <filter data>
}
}

Sample Code

Node

var request = require("request");
​
var options = { method: 'GET',
url: 'https://<domain>/<api prefix>/<version>/commerce/all-orders/',
headers:
{ authorization: 'Bearer <access-token>',
apikey: '<apikey>',
'content-type': 'multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW' }
}
};
​
request(options, function (error, response, body) {
if (error) throw new Error(error);
​
console.log(body);
});

PHP

<?php
​
$curl = curl_init();
​
curl_setopt_array($curl, array(
CURLOPT_PORT => "8000",
CURLOPT_URL => "https://<domain>/<api prefix>/<version>/commerce/all-orders/",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_POSTFIELDS => "------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"product_id\"\r\n\r\n46363\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW--",
CURLOPT_HTTPHEADER => array(
"apikey: <apikey>",
"authorization: Bearer <access-token>",
"content-type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW",
),
));
​
$response = curl_exec($curl);
$err = curl_error($curl);
​
curl_close($curl);
​
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}