🛠️ New

Introducing Anyhive

One API for payments and usage-based billing

Ship checkout, subscriptions, metered usage, and quotas without juggling multiple PSPs. Typed interfaces, smart routing, and safe retries so you rarely need PSP docs.

First checkout or usage event in 15 minutes

How it works

import { createAnyhive } from "anyhive-server";
import { stripeAdapter } from "@anyhive/psp-stripe";
import { payuniAdapter } from "@anyhive/psp-payuni";

export const anyhive = createAnyhive({
  psp: {
    providers: {
      stripe: stripeAdapter({ secretKey: process.env.STRIPE_SECRET_KEY! }),
      payuni: payuniAdapter({
        merchantId: process.env.PAYUNI_MERCHANT_ID!,
        hashKey: process.env.PAYUNI_HASH_KEY!,
      }),
    },
    router: ({ tenantId, country, currency, intent }) => {
      if (currency === "TWD" && intent.type === "checkout") return "payuni";
      if (intent.type === "subscription" || intent.type === "usage") return "stripe";
      return "stripe";
    },
    fallbackOrder: ["stripe"],
  },
});

Use Cases

Create checkout session (PayUni)
Persist customer and entitlements (Postgres)
Stripe payment succeeded webhook

Checkout & subscriptions

Launch one-time and recurring payments with a single, unified API.

[2023-12-15 14:23:45] INFO

Checkout session created (psp=payuni, currency=TWD).

[2023-12-15 14:23:47] ACTION

Router selected PSP 'stripe' for subscription.

[2023-12-15 14:23:50] DECISION

Usage event aggregated (feature=api_calls, window=hour).

[2023-12-15 14:23:52] WARNING

Payment requires 3DS; customer action sent.

[2023-12-15 14:23:55] ERROR

Webhook signature verified; event deduplicated.

Monitor payments and webhooks

Track normalized events, retries, and routing decisions with clear logs.

Route by region and currency

Select the best PSP per tenant, country, and currency—with fallbacks.

Features

Unified, typed API

Stable `checkout / track / check` interfaces that abstract PSP differences so you read fewer vendor docs.

Learn more >

Smart routing & fallbacks

Choose the best PSP by tenant, region, currency, and intent with automatic failover to maximize conversions.

Learn more >

Usage billing & quotas built-in

Idempotent usage events, windowed aggregation, tiered pricing, and Redis-backed rate limits.

Learn more >

Webhook & error normalization

Verified signatures, deduped events, and standardized error codes with safe retries and idempotency.

Learn more >

Adapter ecosystem

Official `@anyhive/psp-*` plus community adapters with a Technology Compatibility Kit (TCK).

Learn more >

Decoupled invoicing & tax

Integrate Invoicing/Tax providers separately for global compliance without complicating your payments flow.

Learn more >

Ready to unify payments and usage-based billing?