npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@011bq/payments-sdk

v0.1.0

Published

Node/Next.js SDK for Bytequests payments API (Phase 1: one-time payments)

Readme

@011bq/payments-sdk

TypeScript SDK for the Bytequests payments API. Phase 1 covers one-time payments only (create order, draft invoice, status check).

Use this from Node.js or Next.js server code (Route Handlers / Server Actions). It is not intended for browser / client components — payment create calls send a cred-id header that should stay on the server.

Install

From the monorepo (local path), or after publish:

# Local workspace (from an app in this repo)
npm install ../packages/sdk

# Or after npm publish
npm install @011bq/payments-sdk

Requires Node.js 18+ (native fetch).

Quick start

import { PaymentsClient, PaymentsApiError } from "@011bq/payments-sdk";

const client = new PaymentsClient({
  credId: process.env.PAYMENTS_CRED_ID!,  // merchant credential UUID
});
// Defaults to https://billing.011bq.app (override with `baseUrl` if needed)

const { orderID, paymentLink } = await client.payments.createOrder({
  amount: 29.99,
  currency: "USD",
  successURL: "https://app.example.com/success",
  failureURL: "https://app.example.com/cancel",
  toolName: "my-app",
  payerEmail: "[email protected]",
});

// Redirect the user to paymentLink

Client options

| Option | Required | Description | |--------|----------|-------------| | baseUrl | no | API origin without trailing slash. Defaults to PAYMENTS_API_URL (https://billing.011bq.app) | | credId | no* | Default cred-id header for create calls | | fetch | no | Custom fetch (tests / agents) |

* credId is required on createOrder / createDraftInvoice either as the client default or via per-call options.credId.

Methods (Phase 1)

payments.createOrder(body, options?)

POST /api/v1/payment/create-order

const result = await client.payments.createOrder({
  amount: 10,
  currency: "USD",
  successURL: "https://app.example.com/ok",
  failureURL: "https://app.example.com/fail",
  toolName: "checkout",
  description: "Pro plan",
  payerEmail: "[email protected]",
  payerName: "Ada",
});
// { orderID, paymentGatewayID, paymentLink }

Override credential per call:

await client.payments.createOrder(body, { credId: "other-cred-uuid" });

payments.createDraftInvoice(body, options?)

POST /api/v1/payment/create-draft-invoice

const result = await client.payments.createDraftInvoice({
  itemName: "Consulting",
  description: "April invoice",
  amount: 100,
  currency: "USD",
  payerEmail: "[email protected]",
  firstName: "Ada",
  lastName: "Lovelace",
  successURL: "https://app.example.com/ok",
  failureURL: "https://app.example.com/fail",
});

payments.check(orderId)

GET /api/v1/payment/check/:orderId

const { status, message } = await client.payments.check(orderID);
// status: unpaid | paid | failed | refunded | …

Next.js Route Handler example

// app/api/checkout/route.ts
import { NextResponse } from "next/server";
import { PaymentsClient, PaymentsApiError } from "@011bq/payments-sdk";

const client = new PaymentsClient({
  credId: process.env.PAYMENTS_CRED_ID!,
});

export async function POST(request: Request) {
  const body = await request.json();

  try {
    const { paymentLink, orderID } = await client.payments.createOrder({
      amount: body.amount,
      currency: body.currency ?? "USD",
      successURL: body.successURL,
      failureURL: body.failureURL,
      toolName: "next-storefront",
      payerEmail: body.email,
    });

    return NextResponse.json({ orderID, paymentLink });
  } catch (err) {
    if (err instanceof PaymentsApiError) {
      return NextResponse.json(
        { error: err.message, code: err.code },
        { status: err.statusCode }
      );
    }
    throw err;
  }
}

Errors

Non-2xx API responses throw PaymentsApiError:

| Property | Meaning | |----------|---------| | message | Human-readable message from the API | | statusCode | HTTP / envelope status | | code | API error code when present | | details | Raw error field or response body |

Both standard (status_code) and validation (statusCode) envelopes are mapped.

Build (contributors)

cd packages/sdk
npm install
npm run build

Roadmap

  • Phase 1 (this package): create order, draft invoice, payment check
  • Later: subscriptions, public orders, invoices, dashboard APIs