Skip to content
TriedDocs
Account

Create checkout

Start a credit purchase: a Stripe Checkout page, or an inline charge in mock mode.

POSThttps://api.tried.com.au/billing/checkout

Needs keys Starts a one-off credit purchase. With Stripe (STRIPE_SECRET_KEY), it creates a Stripe Checkout session in payment mode and returns its URL. Without Stripe, the mock provider charges at once, adds the credit and returns the invoice. Admin only.

Request#

Field Type Required Description
amount number Yes AUD to buy, 5 to 10000.

Example request#

curl -X POST https://api.tried.com.au/billing/checkout \
  -H "Authorization: Bearer $TRIED_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "amount": 50
  }'
const res = await fetch("https://api.tried.com.au/billing/checkout", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.TRIED_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "amount": 50
  }),
});
const checkout = await res.json();
import os, requests

res = requests.post(
    "https://api.tried.com.au/billing/checkout",
    headers={"Authorization": f"Bearer {os.environ['TRIED_API_KEY']}"},
    json={
        "amount": 50,
    },
)
checkout = res.json()

Response#

200 OK

With Stripe:

{
  "provider": "stripe",
  "url": "https://checkout.stripe.com/c/pay/cs_live_a1B2c3D4e5F6g7H8",
  "reference": "cs_live_a1B2c3D4e5F6g7H8"
}

In mock mode:

{
  "provider": "mock",
  "url": null,
  "invoice": {
    "invoice_id": "inv_3d5f7a9c1e3b5d7f9a1c3e5b",
    "number": "TR-202610-3138402",
    "kind": "purchase",
    "amount": 50,
    "currency": "AUD",
    "status": "paid",
    "lines": [
      {
        "description": "Credit purchase ($50.00)",
        "quantity": 1,
        "unit_amount": 50,
        "amount": 50
      }
    ],
    "period_start": null,
    "period_end": null,
    "provider": "mock",
    "created_timestamp": 1760313600000,
    "html_url": "/billing/invoices/inv_3d5f7a9c1e3b5d7f9a1c3e5b/html"
  }
}
Field Type Description
provider string stripe or mock.
url string or null Stripe Checkout URL to redirect the user to. null in mock mode.
reference string Stripe Checkout session ID. Stripe only.
invoice object The purchase invoice, as in List invoices. Mock only.

After payment, Stripe returns the user to the dashboard at /billing?checkout=success. Cancelling returns to /billing.

Errors#

Status When
400 Validation failed, for example amount: Required.
401 Missing or invalid API key.
402 Mock mode only: the inline charge failed.
403 The key's IP allowlist or scopes reject the request. This route needs the admin scope. A dashboard user without the right role gets Requires role: admin. API keys act as admin.
429 Rate limit exceeded. See Rate limits.
500 Stripe rejected the request. Outside production the message is Stripe's error text.

See Errors for the body format.

To save a card instead of buying credits, use Create checkout session with mode: "setup".