Create Stripe Checkout session to turn an add-on on
/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):
checkoutisnulland nothing is charged; the add-on is on. - A charge already sent to Stripe that waits on the card (authentication):
402withhosted_invoice_url, asPOST /billing/add-on.
Request Body
pro, partner or unified:<unified API name>.
prohosted only. Must be on the app origin. Defaults to the Billing settings page.
elements only. Must be on the app origin. Defaults to the Billing settings page.
hosted only. Must be on the app origin. Defaults to the Billing settings page.
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.
hostedelements
Response Body
The add-on as GET /billing/add-on lists it.
The Checkout to pay; null when the add-on is on already.
What the Checkout charges, in cents.
1613Starts Stripe's Elements (ui_mode elements, Stripe.js initCheckoutElementsSdk); null when hosted.
What the payer agrees to. Stripe shows it on its hosted page; with elements the app must show it by its Pay button.
The Stripe publishable key to start Stripe.js with; null when hosted.
cs_test_a1b2c3Stripe's hosted page (ui_mode hosted); null for elements.
Errors
| Status | Description |
|---|---|
400 | Unknown 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 |
402 | A charge for this add-on is waiting on the card; pay at hosted_invoice_url |
403 | Forbidden if the caller is not an admin of the team |
409 | The add-on is being charged right now, or a payment for it is still being confirmed; try again later |
503 | Billing 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())