Billing SDK

Billing SDK

Send payments, subscriptions, invoices and refunds to Faurya from your server with the official @faurya/billing npm package.

Faurya Billing SDK

@faurya/billing is the official server-side package for sending your revenue to Faurya. It wraps the Billing API, the Payments API and the Goals API in one typed client, so you can write:

await faurya.billing.invoices.upsert("inv_1042", invoice);

instead of building fetch calls, headers, retries and error parsing yourself.

npm install @faurya/billing

Server only. The SDK uses your site API key. It refuses to start in a browser, because the key would be visible to every visitor. Call it from your backend, API routes, server actions, webhooks or scripts.

What you can do with it

  • Record a payment in one call and see it attributed to the visitor and traffic source that earned it.
  • Track server-side goals, such as signup or trial_started, when they happen in your backend.
  • Send your full billing model — customers, plans, invoices, payments, refunds, cancellations — so Faurya can show MRR, subscribers, churn and plan changes.
  • Import your history in one job, streaming straight from your own database.
  • Check a subscription and see whether it counts as a subscriber, and if not, why.

Do I need it?

Your situationWhat to use
You use a payment provider Faurya connects to (Stripe, Paddle, Dodo, Polar…)Nothing — Faurya already reads it. Don't send the same data again or it counts twice.
You only want revenue and attribution for one-off paymentspayments.create
You bill subscriptions from your own code, or from a provider Faurya does not connect tobilling.*
You are moving history out of another analytics tool or your own databasebilling.imports.run

Why use the SDK instead of raw HTTP

  • Typed requests and responses. Every field is autocompleted and checked by TypeScript, with the same snake_case names the API docs use.
  • Safe retries built in. Rate limits and temporary failures are retried for you, but payments are never sent twice.
  • Clear errors. Each failure is a specific error class (FauryaConflictError, FauryaRateLimitError…) carrying the error code, every field problem and the request id.
  • Bulk imports in one line. Batching, size limits, committing and waiting are handled for you.
  • Your key stays safe. It is never logged, never sent anywhere but Faurya, and never shipped to a browser.

Works on Node.js 18+, Bun, Deno and edge runtimes (Vercel, Cloudflare Workers). It has no dependencies.

Guides