Skip to content

Create Stripe Checkout session to turn an add-on on

POST /billing/checkout-add-on-session

Turns an add-on on for a team with no card, in one payment. The Checkout takes the same amount POST /billing/add-on charges a saved card (the rest of the month, by days) and saves the payment method for the add-on's renewals; it becomes the customer's default. The add-on turns on when Stripe's webhook says the payment succeeded, not when the browser returns. The charge is claimed first, so a double click or a second tab pays one Checkout, and a card charge for the same add-on closes it first.

  • Already on, or this month already paid (turned off after paying): checkout is null and nothing is charged; the add-on is on.
  • A charge already sent to Stripe that waits on the card (authentication): 402 with hosted_invoice_url, as POST /billing/add-on.

Request Body

add_onstring

pro, partner or unified:<unified API name>.

Example: pro
cancel_urlstring

hosted only. Must be on the app origin. Defaults to the Billing settings page.

return_urlstring

elements only. Must be on the app origin. Defaults to the Billing settings page.

success_urlstring

hosted only. Must be on the app origin. Defaults to the Billing settings page.

team_idstring · uuid
ui_modestring

hosted returns url, Stripe's own page. elements returns client_secret, publishable_key and consent_text, for the app to show Stripe's Payment and Express Checkout Elements itself (Stripe.js initCheckoutElementsSdk) and confirm in place; it leaves the app only for a payment method that must redirect, to return_url.

Possible values:
hostedelements

Response Body

add_onobject

The add-on as GET /billing/add-on lists it.

checkoutobject

The Checkout to pay; null when the add-on is on already.

amount_centsinteger

What the Checkout charges, in cents.

Example: 1613
client_secretstring

Starts Stripe's Elements (ui_mode elements, Stripe.js initCheckoutElementsSdk); null when hosted.

consent_textstring

What the payer agrees to. Stripe shows it on its hosted page; with elements the app must show it by its Pay button.

publishable_keystring

The Stripe publishable key to start Stripe.js with; null when hosted.

session_idstring
Example: cs_test_a1b2c3
urlstring

Stripe's hosted page (ui_mode hosted); null for elements.

Errors

StatusDescription
400Unknown add-on, one the plan does not offer, a team that cannot be billed for add-ons, or a redirect URL not on the app origin or for the other ui_mode
402A charge for this add-on is waiting on the card; pay at hosted_invoice_url
403Forbidden if the caller is not an admin of the team
409The add-on is being charged right now, or a payment for it is still being confirmed; try again later
503Billing is not configured on this deployment (STRIPE_SECRET_KEY unset), or ui_mode elements was asked for and STRIPE_PUBLISHABLE_KEY is unset
curl -X POST 'https://api.truto.one/billing/checkout-add-on-session' \
  -H 'Authorization: Bearer <your_api_token>' \
  -H 'Content-Type: application/json' \
  -d '{
  "team_id": "your_team_id",
  "add_on": "pro",
  "ui_mode": "hosted",
  "success_url": "your_success_url",
  "cancel_url": "your_cancel_url",
  "return_url": "your_return_url"
}'
const body = {
  "team_id": "your_team_id",
  "add_on": "pro",
  "ui_mode": "hosted",
  "success_url": "your_success_url",
  "cancel_url": "your_cancel_url",
  "return_url": "your_return_url"
};

const response = await fetch('https://api.truto.one/billing/checkout-add-on-session', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer <your_api_token>',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify(body),
});

const data = await response.json();
console.log(data);
import requests

url = "https://api.truto.one/billing/checkout-add-on-session"
headers = {
    "Authorization": "Bearer <your_api_token>",
    "Content-Type": "application/json",
}
params = {
}
payload = {
    "team_id": "your_team_id",
    "add_on": "pro",
    "ui_mode": "hosted",
    "success_url": "your_success_url",
    "cancel_url": "your_cancel_url",
    "return_url": "your_return_url"
}

response = requests.post(url, headers=headers, params=params, json=payload)
print(response.json())