Create Single Order | Climes API
This endpoint creates a single order.
Request Parameters
Order Schema
This is the schema for the Order API. Each request payload requires order
object
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/order
For an order where the customer is paying :
/v3/integrations/calculated/order
Method
POST
Headers
{
'x-api-key' : 'API_KEY',
'Content-Type' : 'application/json'
}
Payload
{
"order": {
"climes": 557,
"partner_order_id": "876287372837786837",
"customer_email": "johndoe5675533@gmail.com",
"customer_name": "John Doe",
"customer_phone": "+916355129211",
"unlock_date": 1660933800000,
"cart_id" : "9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d",
"project_id" : "farmers-for-forests"
}
}
Response Parameters
Status Code
201
Response Data
{
"message": "Order created successfully",
"partner_order_id": "876287372837786837"
}
Sample Request
- cURL
- NodeJs
- Axios
- Python
- Php
curl --location --request POST 'BASE_URL/v3/integrations/vote/order'
--header 'x-api-key: API_KEY'
--header 'Content-Type: application/json'
--data-raw '{
"order": {
"climes": 557,
"partner_order_id": "876287372837786837",
"customer_email": "johndoe5675533@gmail.com",
"customer_name": "John Doe",
"customer_phone": "+916355129211",
"unlock_date": 1660933800000,
"cart_id" : "9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d",
"project_id" : "farmers-for-forests"
}
}'
const fetch = require('node-fetch');
const baseURL = 'BASE_URL/v3/integrations/vote/order';
const apiKey = 'API_KEY';
const data = {
"order": {
"climes": 557,
"partner_order_id": "876287372837786837",
"customer_email": "johndoe5675533@gmail.com",
"customer_name": "John Doe",
"customer_phone": "+916355129211",
"unlock_date": 1660933800000,
"cart_id" : "9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d",
"project_id" : "farmers-for-forests"
}
};
const headers = {
'x-api-key': apiKey,
'Content-Type': 'application/json'
};
fetch(baseURL, {
method: 'POST',
headers: headers,
body: JSON.stringify(data)
})
.then(response => response.json())
.then(data => {
// Handle the response
console.log(data);
})
.catch(error => {
// Handle the error
console.error(error);
});
var axios = require('axios');
var data = {
"order": {
"climes": 557,
"partner_order_id": "876287372837786837",
"customer_email": "johndoe5675533@gmail.com",
"customer_name": "John Doe",
"customer_phone": "+916355129211",
"unlock_date": 1660933800000,
"cart_id" : "9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d",
"project_id" : "farmers-for-forests"
}
};
var config = {
method: 'post',
url: 'BASE_URL/v3/integrations/vote/order',
headers: {
'x-api-key': API_KEY,
'Content-Type': 'application/json'
},
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/order"
payload = json.dumps({
"order": {
"climes": 557,
"partner_order_id": "876287372837786837",
"customer_email": "johndoe5675533@gmail.com",
"customer_name": "John Doe",
"customer_phone": "+916355129211",
"unlock_date": 1660933800000,
"cart_id" : "9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d",
"project_id" : "farmers-for-forests"
}
})
headers = {
'x-api-key': 'API_KEY',
'Content-Type': 'application/json'
}
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/order');
$request->setMethod(HTTP_Request2::METHOD_POST);
$request->setConfig(array(
'follow_redirects' => TRUE
));
$request->setHeader(array(
'x-api-key' => 'API_KEY',
'Content-Type' => 'application/json'
));
$request->setBody('{
"order": {
"climes": 557,
"partner_order_id": "876287372837786837",
"customer_email": "johndoe5675533@gmail.com",
"customer_name": "John Doe",
"customer_phone": "+916355129211",
"unlock_date": 1660933800000
"cart_id" : "9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d"
"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 sample request.
Responses
- Success - 201
- Failure - 400
{
"message": "Order created successfully",
"partner_order_id": "876287372837786837"
}
{
"message": "Bad Request! Please send all the variables properly."
}