Order

Create Order

post
https://<domain>/<api prefix>/<version>/commerce/create-order/

Sample code

Node
1
var request = require('request');
2
var options = {
3
'method': 'POST',
4
'url': 'https://<domain>/<api prefix>/<version>/commerce/create-order/',
5
'headers': {
6
'apikey': '<apikey>'
7
},
8
body: JSON.stringify(
9
{
10
"products": [
11
{
12
"product_id": <product id>,
13
"quantity":<product quantity>,
14
"unit_price":<product unit price>,
15
"discount":<product total dicount>,
16
"total_amount":<lineitem total amount>
17
}
18
],
19
"address": {
20
"address_first_name": "<address first name>",
21
"address_last_name": "<address last name>",
22
"address_mail_id": "<address email id>",
23
"address_phone_number": "<address phone number>",
24
"address_name_line": "<address house number>",
25
"address_premise": "<address street>",
26
"address_locality": "<address locality>",
27
"address_postal_code": "<address post code>",
28
"address_country_code": "<address country code>",
29
"address_state_code": "<address state code>"
30
},
31
"total_amount":<total order amount>,
32
"uid":"<user id>"
33
}
34
)
35
​
36
};
37
request(options, function (error, response) {
38
if (error) throw new Error(error);
39
console.log(response.body);
40
});
41
​
Copied!
PHP
1
<?php
2
​
3
$curl = curl_init();
4
​
5
curl_setopt_array($curl, array(
6
CURLOPT_URL => 'https://<domain>/<api prefix>/<version>/commerce/create-order/',
7
CURLOPT_RETURNTRANSFER => true,
8
CURLOPT_ENCODING => '',
9
CURLOPT_MAXREDIRS => 10,
10
CURLOPT_TIMEOUT => 0,
11
CURLOPT_FOLLOWLOCATION => true,
12
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
13
CURLOPT_CUSTOMREQUEST => 'POST',
14
CURLOPT_POSTFIELDS =>'{
15
"products": [
16
{
17
"product_id":<product id>,
18
"quantity":<product quantity>,
19
"unit_price":<product unit price>,
20
"discount":<product total dicount>,
21
"total_amount":<lineitem total amount>
22
}
23
],
24
"address":{
25
"address_first_name":"<address first name>",
26
"address_last_name":"<address last name>",
27
"address_mail_id":"<address email id>",
28
"address_phone_number":"<address phone number>",
29
"address_name_line":"<address house number>",
30
"address_premise":"<address street>",
31
"address_locality":"<address locality>",
32
"address_postal_code":"<address post code>",
33
"address_country_code":"<address country code>",
34
"address_state_code":"<address state code>"
35
},
36
"total_amount":<total order amount>,
37
"uid":"<user id>"
38
}',
39
CURLOPT_HTTPHEADER => array(
40
'apikey: <apikey>'
41
),
42
));
43
​
44
$response = curl_exec($curl);
45
​
46
curl_close($curl);
47
echo $response;
Copied!

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/

Sample code

Node
1
var request = require('request');
2
var options = {
3
'method': 'POST',
4
'url': 'https://<domain>/<api prefix>/<version>/commerce/upgrade-renewal-package/',
5
'headers': {
6
'apikey': '<apikey>'
7
},
8
body: JSON.stringify(
9
{
10
"product_id": <product id>,
11
"unit_price": <product unit price>,
12
"discount": <total discount amount>,
13
"order_total": <order total amount>
14
"address_first_name": "<address first name>",
15
"address_last_name": "<address last name>",
16
"address_mail_id": "<address email id>",
17
"address_phone_number": "<address phone number>",
18
"address_name_line": "<address house number>",
19
"address_premise": "<address street>",
20
"address_locality": "<address locality>",
21
"address_postal_code": "<address post code>",
22
"address_country_code": "<address country code>",
23
"address_state_code": "<address state code>"
24
"uid":"<user id>",
25
"order_type":"<order type>"
26
}
27
)
28
​
29
};
30
request(options, function (error, response) {
31
if (error) throw new Error(error);
32
console.log(response.body);
33
});
34
​
Copied!
PHP
1
<?php
2
​
3
$curl = curl_init();
4
​
5
curl_setopt_array($curl, array(
6
CURLOPT_URL => 'https://<domain>/<api prefix>/<version>/commerce/create-order/',
7
CURLOPT_RETURNTRANSFER => true,
8
CURLOPT_ENCODING => '',
9
CURLOPT_MAXREDIRS => 10,
10
CURLOPT_TIMEOUT => 0,
11
CURLOPT_FOLLOWLOCATION => true,
12
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
13
CURLOPT_CUSTOMREQUEST => 'POST',
14
CURLOPT_POSTFIELDS =>'{
15
"product_id": <product id>,
16
"unit_price": <product unit price>,
17
"discount": <total discount amount>,
18
"order_total": <order total amount>
19
"address_first_name": "<address first name>",
20
"address_last_name": "<address last name>",
21
"address_mail_id": "<address email id>",
22
"address_phone_number": "<address phone number>",
23
"address_name_line": "<address house number>",
24
"address_premise": "<address street>",
25
"address_locality": "<address locality>",
26
"address_postal_code": "<address post code>",
27
"address_country_code": "<address country code>",
28
"address_state_code": "<address state code>"
29
"uid":"<user id>",
30
"order_type":"<order type>"
31
}',
32
CURLOPT_HTTPHEADER => array(
33
'apikey: <apikey>'
34
),
35
));
36
​
37
$response = curl_exec($curl);
38
​
39
curl_close($curl);
40
echo $response;
Copied!

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

List Orders

get
https://<domain>/<api prefix>/<version>/commerce/all-orders/

Sample Code

Node

1
var request = require("request");
2
​
3
var options = { method: 'GET',
4
url: 'https://<domain>/<api prefix>/<version>/commerce/all-orders/',
5
headers:
6
{ authorization: 'Bearer <access-token>',
7
apikey: '<apikey>',
8
'content-type': 'multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW' }
9
}
10
};
11
​
12
request(options, function (error, response, body) {
13
if (error) throw new Error(error);
14
​
15
console.log(body);
16
});
Copied!

PHP

1
<?php
2
​
3
$curl = curl_init();
4
​
5
curl_setopt_array($curl, array(
6
CURLOPT_PORT => "8000",
7
CURLOPT_URL => "https://<domain>/<api prefix>/<version>/commerce/all-orders/",
8
CURLOPT_RETURNTRANSFER => true,
9
CURLOPT_ENCODING => "",
10
CURLOPT_MAXREDIRS => 10,
11
CURLOPT_TIMEOUT => 30,
12
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
13
CURLOPT_CUSTOMREQUEST => "GET",
14
CURLOPT_POSTFIELDS => "------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"product_id\"\r\n\r\n46363\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW--",
15
CURLOPT_HTTPHEADER => array(
16
"apikey: <apikey>",
17
"authorization: Bearer <access-token>",
18
"content-type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW",
19
),
20
));
21
​
22
$response = curl_exec($curl);
23
$err = curl_error($curl);
24
​
25
curl_close($curl);
26
​
27
if ($err) {
28
echo "cURL Error #:" . $err;
29
} else {
30
echo $response;
31
}
Copied!

Order Details

get
β€Ž
https://<domain>/<api prefix>/<version>/commerce/order-details/

Sample Code

Node

1
var request = require('request');
2
var options = {
3
'method': 'POST',
4
'url': 'https://<domain>/<api prefix>/<version>/commerce/order-details/',
5
'headers': {
6
'apikey': '<apikey>',
7
'Authorization': 'Bearer <access token>',
8
},
9
formData: {
10
'order_number': 'order_number'
11
}
12
};
13
request(options, function (error, response) {
14
if (error) throw new Error(error);
15
console.log(response.body);
16
});
17
​
Copied!

PHP

1
<?php
2
​
3
$curl = curl_init();
4
​
5
curl_setopt_array($curl, array(
6
CURLOPT_URL => 'https://<domain>/<api prefix>/<version>/commerce/order-details/?order_number=<order_number>',
7
CURLOPT_RETURNTRANSFER => true,
8
CURLOPT_ENCODING => '',
9
CURLOPT_MAXREDIRS => 10,
10
CURLOPT_TIMEOUT => 0,
11
CURLOPT_FOLLOWLOCATION => true,
12
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
13
CURLOPT_CUSTOMREQUEST => 'GET',
14
CURLOPT_POSTFIELDS => array(),
15
CURLOPT_HTTPHEADER => array(
16
'apikey: <apikey>',
17
'Authorization: Bearer <access token>'
18
),
19
));
20
​
21
$response = curl_exec($curl);
22
​
23
curl_close($curl);
24
echo $response;
Copied!

Error Responses

status code
error type
field
description
400
Validation Error
order_number
Order Number maynot be blank.
Order Number is required.
Invalid order number.