CNaughtCNaught
PricingSign In

Create Checkout Session

Creates a Checkout Session that, when completed, will result in an order for the specified amount of carbon credits (in kilograms). The total price must be at least $0.50 (the corresponding amount will depend on the per kg price of the specified portfolio). The Quotes API can be used to check the price before attempting to create a session.

POST/checkout/sessions

Authorizations#

Authorization

string

header

required

Bearer authentication header of the form Bearer <token>, where <token> is your CNaught API key.

Headers#

X-Subaccount-Id

string

The Subaccount the Checkout Session will create an order for when successfully completed

Body#

Checkout Session Parameters

amount_kg

number

required

Amount of carbon credits to be purchased upon checkout completion, in kilograms

success_url

string

required

The URL the customer will be redirected to after the payment is completed. The {CHECKOUT_SESSION_ID} template can be used to include the session id in a query parameter. Make sure to include the template exactly as {CHECKOUT_SESSION_ID} (i.e. do not replace it with the actual session id).

cancel_url

string

required

The URL the customer will be directed to if they decide to cancel payment and return to your website

portfolio_id

string | null

Optional id of the portfolio to use for fulfilling the order resulting from the Checkout Session. If not specified, the user or subaccount's default portfolio will be used (depending on if a subaccount is provided).

description

string | null

Optional public description for the order that will be shown on the certificate, as provided when order was placed

notification_config

NotificationConfig | null

Optional configuration for a callback url to invoke with updates when the status of an order changes.

Response#

201

Checkout Session

Remove Logo From Subaccount

Create Checkout Session

curl --request POST \
  --url https://api.cnaught.com/v1/checkout/sessions \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "amount_kg": 100,
  "success_url": "https://www.example.com/confirmation?my_query=my_value&session_id={CHECKOUT_SESSION_ID}",
  "cancel_url": "https://www.example.com/purchase-credits",
  "description": "on behalf of Jane Smith",
  "notification_config": {
    "url": "https://www.example.com/callback"
  }
}'
{
  "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"
}