Create Multiple Orders | Climes API
This endpoint creates a single order.
Request Parameters
Orders Schema
Each request payload has an orders
array which requires individual order object
Name | Description | Type | Optional |
---|---|---|---|
orders | This is an array of orders which can be sent instead of sending single order. | array | required |
Order Schema
Name | Description | Type | Optional |
---|---|---|---|
climes | This is the amount of climes chosen by the user to neutralise his/her journey. You can calculate the total Carbon emitted by the users journey using Climes' Truecost API's. | number | required |
partner_order_id | This partner_order_id has to be unique and generated from your end. This can be used to have a tally of orders sent for processing if required. | string | required |
customer_email | Users Email address | string | required |
customer_name | Users Full Name | string | required |
customer_phone | Users Phone Number | string | optional |
unlock_date | This timestamp is for the journeys that are yet to be done which have a possibility for the ticket cancellation. The unlock_date has to be the timestamp at which the journey is over. Till the journey is not over the climes will be in a locked state and can only be accessed after the journey is over. Default is 10 days from the date of order placed. | epoch timestamp in milliseconds. i.e. 1660933800000 | optional |
cart_id | This is the cart_id of your store. This has to be unique and has to be same as cart_id in Create OptIn API. For Climes Vote product if this is not sent then it will be of same value as partner_order_id This field is for Climes Vote product only | string | optional |
project_id | This is the project selected by your user to support with their climes. | string | optional |
tip
If you want the order to be unlocked immediately then you can send any past timestamp.
caution
All the order updates like Partial Addition, Partial Cancellation , Full Order Cancellation can only be done before the unlock_date has passed. Once unlock_date has passed no updates will be supported for that order.
Endpoint
For an order where the merchant is paying :
/v3/integrations/vote/orders
For an order where the customer is paying :
/v3/integrations/calculated/orders
Method
POST
Headers
{
'x-api-key' : 'API_KEY',
'Content-Type' : 'application/json'
}
Payload
{
"orders": [
{
"climes": 15,
"partner_order_id": "PIDhkj786sdfdsf",
"customer_email": "johndoe@climes.io",
"customer_name": "John Doe",
"customer_phone": "+911234567890",
"unlock_date": 1651326671442,
"cart_id" : "9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d",
"project_id" : "farmers-for-forests"
},
{
"climes": 19,
"partner_order_id": "PIDketwjh78dpwe",
"customer_email": "johndoe@climes.io",
"customer_name": "John Doe",
"customer_phone": "+911234567890",
"unlock_date": 1651326678489,
"cart_id" : "550e8400-e29b-41d4-a716-446655440000",
"project_id" : "farmers-for-forests"
}
]
}
Response Parameters
Status Code
201
Response Data
{
"message": "Orders created successfully",
"partner_order_ids": [
"987346873685787647",
"345345343434534534"
]
}
Sample Request
- cURL
- NodeJs
- Axios
- Python
- Php
curl --location --request POST 'BASE_URL/v3/integrations/vote/orders' --header 'Content-Type: application/json' --header 'x-api-key: API_KEY' --data-raw '{
"orders": [
{
"climes": 15,
"partner_order_id": "987346873685787647",
"customer_email": "johndoe@climes.io",
"customer_name": "John Doe",
"customer_phone": "+911234567890",
"unlock_date": 1651326671442,
"cart_id" : "9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d",
"project_id" : "farmers-for-forests"
},
{
"climes": 19,
"partner_order_id": "345345343434534534",
"customer_email": "johndoe@climes.io",
"customer_name": "John Doe",
"customer_phone": "+911234567890",
"unlock_date": 1651326678489,
"cart_id" : "550e8400-e29b-41d4-a716-446655440000",
"project_id" : "farmers-for-forests"
}
]
}'
const fetch = require('node-fetch');
const url = 'BASE_URL/v3/integrations/vote/orders';
const apiKey = 'API_KEY';
const orders = [
{
climes: 15,
partner_order_id: '987346873685787647',
customer_email: 'johndoe@climes.io',
customer_name: 'John Doe',
customer_phone: '+911234567890',
unlock_date: 1651326671442,
"cart_id" : "9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d",
"project_id" : "farmers-for-forests"
},
{
climes: 19,
partner_order_id: '345345343434534534',
customer_email: 'johndoe@climes.io',
customer_name: 'John Doe',
customer_phone: '+911234567890',
unlock_date: 1651326678489,
"cart_id" : "550e8400-e29b-41d4-a716-446655440000",
"project_id" : "farmers-for-forests"
}
];
const headers = {
'Content-Type': 'application/json',
'x-api-key': apiKey
};
const options = {
method: 'POST',
headers: headers,
body: JSON.stringify({ orders })
};
fetch(url, options)
.then(response => response.json())
.then(data => {
console.log(data);
})
.catch(error => {
console.error('Error:', error);
});
var axios = require('axios');
var data = JSON.stringify({
"orders": [
{
"climes": 15,
"partner_order_id": "987346873685787647",
"customer_email": "johndoe@climes.io",
"customer_name": "John Doe",
"customer_phone": "+911234567890",
"unlock_date": 1651326671442,
"cart_id": "9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d",
"project_id" : "farmers-for-forests"
},
{
"climes": 19,
"partner_order_id": "345345343434534534",
"customer_email": "johndoe@climes.io",
"customer_name": "John Doe",
"customer_phone": "+911234567890",
"unlock_date": 1651326678489,
"cart_id": "550e8400-e29b-41d4-a716-446655440000",
"project_id" : "farmers-for-forests"
}
]
});
var config = {
method: 'post',
url: 'BASE_URL/v3/integrations/vote/orders',
headers: {
'Content-Type': 'application/json',
'x-api-key': 'API_KEY'
},
data : data
};
axios(config)
.then(function (response) {
console.log(JSON.stringify(response.data));
})
.catch(function (error) {
console.log(error);
});
import requests
import json
url = "BASE_URL/v3/integrations/vote/orders"
payload = json.dumps({
"orders": [
{
"climes": 15,
"partner_order_id": "987346873685787647",
"customer_email": "johndoe@climes.io",
"customer_name": "John Doe",
"customer_phone": "+911234567890",
"unlock_date": 1651326671442,
"cart_id": "9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d",
"project_id" : "farmers-for-forests"
},
{
"climes": 19,
"partner_order_id": "345345343434534534",
"customer_email": "johndoe@climes.io",
"customer_name": "John Doe",
"customer_phone": "+911234567890",
"unlock_date": 1651326678489,
"cart_id": "550e8400-e29b-41d4-a716-446655440000",
"project_id" : "farmers-for-forests"
}
]
})
headers = {
'Content-Type': 'application/json',
'x-api-key': 'API_KEY'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
<<?php
require_once 'HTTP/Request2.php';
$request = new HTTP_Request2();
$request->setUrl('BASE_URL/v3/integrations/vote/orders');
$request->setMethod(HTTP_Request2::METHOD_POST);
$request->setConfig(array(
'follow_redirects' => TRUE
));
$request->setHeader(array(
'Content-Type' => 'application/json',
'x-api-key' => 'API_KEY'
));
$request->setBody('{
"orders": [
{
"climes": 15,
"partner_order_id": "987346873685787647",
"customer_email": "johndoe@climes.io",
"customer_name": "John Doe",
"customer_phone": "+911234567890",
"unlock_date": 1651326671442,
"cart_id" : "9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d"
"project_id" : "farmers-for-forests"
},
{
"climes": 19,
"partner_order_id": "345345343434534534",
"customer_email": "johndoe@climes.io",
"customer_name": "John Doe",
"customer_phone": "+911234567890",
"unlock_date": 1651326678489,
"cart_id" : "550e8400-e29b-41d4-a716-446655440000"
"project_id" : "farmers-for-forests"
}
]
}');
try {
$response = $request->send();
if ($response->getStatus() == 200) {
echo $response->getBody();
}
else {
echo 'Unexpected HTTP status: ' . $response->getStatus() . ' ' .
$response->getReasonPhrase();
}
}
catch(HTTP_Request2_Exception $e) {
echo 'Error: ' . $e->getMessage();
}
Sample Response
Below are sample responses for the above request.
Responses
- Success - 201
- Failure - 400
{
"message": "Orders created successfully",
"partner_order_ids": [
"987346873685787647",
"345345343434534534"
]
}
{
"message": "Bad Request! Please send all the variables properly."
}