Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.stellartools.dev/llms.txt

Use this file to discover all available pages before exploring further.

The @stellartools/core package is the main way to talk to the StellarTools API from TypeScript or JavaScript. It covers customers, checkouts, products, subscriptions, payments, refunds, and credits.

Install

npm install @stellartools/core

Initialize

import { StellarTools } from "@stellartools/core";

const st = new StellarTools({
  api_key: process.env.STELLAR_TOOLS_API_KEY!,
});
The API key determines whether requests go to testnet or mainnet. No other configuration is needed.

Customers

const customer = await st.customers.create({
  email: "jane@example.com",
  name: "Jane Smith",
  phone: "+12345678901",
});

// customer.id — use this as customerId everywhere else

Checkouts

const checkout = await st.checkout.create({
  customer_id: customer.id,
  product_id: "prod_xxx",
  redirect_url: "https://yourapp.com/success",
});

// Send the customer to checkout.paymentUrl
redirect(checkout.payment_url);
For a direct amount checkout without a product:
const checkout = await st.checkout.create({
  customer_d: customer.id,
  amount: 10,
  asset_code: "XLM",
  redirect_url: "https://yourapp.com/success",
});

Products

const product = await st.products.create({
  name: "Pro Plan",
  type: "subscription",
  asset_code: "XLM",
  price_amount: 10,
  recurring_period: "monthly",
});
Product types: one_time, subscription, metered.

Subscriptions

// Create
const subscription = await st.subscriptions.create({
  customer_id: "cust_xxx",
  product_id: "prod_xxx",
});

// Pause, resume, cancel
await st.subscriptions.pause(subscription.id);
await st.subscriptions.resume(subscription.id);
await st.subscriptions.cancel(subscription.id);

Webhooks

const event = st.webhooks.constructEvent(
  rawBody,
  req.headers.get("X-StellarTools-Signature")!,
  process.env.STELLAR_TOOLS_WEBHOOK_SECRET!
);
See the Webhooks page for all event types and a full handler example.