curl --request GET \
--url https://api.cnaught.com/v1/checkout/sessions/{id} \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.cnaught.com/v1/checkout/sessions/{id}"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.cnaught.com/v1/checkout/sessions/{id}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.cnaught.com/v1/checkout/sessions/{id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.cnaught.com/v1/checkout/sessions/{id}"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.cnaught.com/v1/checkout/sessions/{id}")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.cnaught.com/v1/checkout/sessions/{id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"id": "zpQ6QSNRQh",
"amount_kg": 100,
"price_usd_cents": 200,
"success_url": "https://www.example.com/confirmation?my_query=my_value&session_id={CHECKOUT_SESSION_ID}",
"cancel_url": "https://www.example.com/purchase-credits",
"checkout_url": "https://checkout.cnaught.com/pay/zpQ6QSNRQh",
"state": "open",
"created_on": "2022-07-31T18:00:00.000000Z",
"expires_on": "2022-08-01T18:00:00.000000Z",
"completed_on": null,
"portfolio_id": "mHvNvWbq",
"order_description": "on behalf of Jane Smith",
"order_webhook_url": "https://www.example.com/callback"
}{
"title": "Authorization has been denied for this request",
"status": 401
}{
"type": "https://api.cnaught.com/v1/errors/not-found",
"title": "Could not find checkout session",
"status": 404
}Get Checkout Session
Returns the Checkout Session with the given id
curl --request GET \
--url https://api.cnaught.com/v1/checkout/sessions/{id} \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.cnaught.com/v1/checkout/sessions/{id}"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.cnaught.com/v1/checkout/sessions/{id}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.cnaught.com/v1/checkout/sessions/{id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.cnaught.com/v1/checkout/sessions/{id}"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.cnaught.com/v1/checkout/sessions/{id}")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.cnaught.com/v1/checkout/sessions/{id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"id": "zpQ6QSNRQh",
"amount_kg": 100,
"price_usd_cents": 200,
"success_url": "https://www.example.com/confirmation?my_query=my_value&session_id={CHECKOUT_SESSION_ID}",
"cancel_url": "https://www.example.com/purchase-credits",
"checkout_url": "https://checkout.cnaught.com/pay/zpQ6QSNRQh",
"state": "open",
"created_on": "2022-07-31T18:00:00.000000Z",
"expires_on": "2022-08-01T18:00:00.000000Z",
"completed_on": null,
"portfolio_id": "mHvNvWbq",
"order_description": "on behalf of Jane Smith",
"order_webhook_url": "https://www.example.com/callback"
}{
"title": "Authorization has been denied for this request",
"status": 401
}{
"type": "https://api.cnaught.com/v1/errors/not-found",
"title": "Could not find checkout session",
"status": 404
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Path Parameters
Id of the Checkout Session to retrieve
"zpQ6QSNRQh"
Response
Checkout Session
Identifier that can be used to retrieve the Checkout Session
"zpQ6QSNRQh"
Amount of carbon credits to be purchased upon checkout completion, in kilograms
10.5
Total price to be charged upon checkout completion, in USD cents
2350
URL the customer will be redirected to after they complete Checkout.
"https://www.example.com/purchase/success"
URL the customer will be redirected to if they click the "back" button in Checkout.
"https://www.example.com/purchase"
URL to the Checkout Session. Redirect the customer to this URL to take them to Checkout.
"https://checkout.cnaught.com/pay/zpQ6QSNRQh"
The status of the Checkout Session, one of open, complete, or expired.
open- The checkout session is still in progress. Payment processing has not started.complete- The checkout session is complete. Payment processing may still be in progress.expired- The checkout session has expired. No further processing will occur.
Timestamp of when the session will expire.
Timestamp of when the session was completed. Null if session has not been completed.
Id of the portfolio the customer will purchase from when completing Checkout.
Id of the subaccount associated with the customer
Description to be associated with the order created from this session.
Webhook URL for updates to the order created from this session.