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

@geekapps/billing-fastify

v0.11.0

Published

Geekapps Billing SDK for Fastify

Readme

@geekapps/billing-fastify

Cliente/plugin Fastify para a Geekapps Billing API — cria cobranças, gerencia clientes/itens/pedidos parcelados a partir de outros serviços Node.

Uso como plugin Fastify

import Fastify from "fastify";
import { billingPlugin } from "@geekapps/billing-fastify";

const app = Fastify();

app.register(billingPlugin, {
  baseUrl: "https://billing-api.seudominio.com",
  serviceAccount: {
    issuerUrl: process.env.GEEKAPPS_AUTH_ISSUER!,
    clientId: process.env.GEEKAPPS_SERVICE_ACCOUNT_CLIENT_ID!,
    clientSecret: process.env.GEEKAPPS_SERVICE_ACCOUNT_CLIENT_SECRET!,
  },
  mode: "prod", // definido uma vez — todas as chamadas via app.billingClient já usam esse valor
});

app.get("/exemplo", async (req) => {
  return app.billingClient.charges.create({
    customer_id: "...",
    item_id: "...",
    method: "PIX",
  });
});

Uso standalone (sem Fastify)

import { BillingClient, createServiceAccountToken } from "@geekapps/billing-fastify";

const client = new BillingClient({
  baseUrl: "https://billing-api.seudominio.com",
  token: createServiceAccountToken({
    issuerUrl: "...",
    clientId: "...",
    clientSecret: "...",
  }),
  mode: "dev",
});

await client.customers.create({ name: "...", email: "..." });

O mode (dev/prod) é configurado uma única vez ao instanciar o cliente — nenhum método individual precisa recebê-lo novamente.

Cobrança avulsa simples (sempre cartão)

charges.charge cobra direto no cartão padrão já salvo do cliente; se ele ainda não tiver um, retorna uma URL de checkout para cadastrar o cartão e pagar.

const result = await client.charges.charge(customerId, 5000); // R$ 50,00

if (!result.charged_off_session) {
  // abra result.checkout_url em uma nova aba para o cliente cadastrar o cartão
}

Assinatura de plano (checkout + confirmação + status)

Fluxo público (cliente final anônimo, ainda sem Customer cadastrado — coleta nome/e-mail no checkout):

const { checkout_url, checkout_token, management_token } = await client.plans.checkout(planId, {
  customer: { name, email },
});

// redirecione o cliente para checkout_url, depois confirme o pagamento:
const status = await client.checkout.waitUntilPaid(checkout_token);

// guarde management_token — a qualquer momento depois, verifique se a assinatura
// segue ativa e qual item ela cobre (rota pública, sem autenticação):
const subStatus = await client.subscriptions.checkByToken(management_token);
if (subStatus.subscription.active) {
  console.log("cobrando", subStatus.item.name);
}

Fluxo simplificado (autenticado, o Customer já existe na sua org — sem formulário de nome/e-mail):

const { checkout_url } = await client.plans.checkoutPlan(planId, customerId, {
  return_url: "https://meuapp.com/conta?upgraded=1",
});
// redirecione o cliente para checkout_url; ele paga e volta para sua URL de retorno

// depois que o cliente volta:
const { active, item } = await client.plans.confirmPlanSubscription(planId, customerId);
if (active) {
  // ativa o plano real no seu sistema
}

Plano avulso (sem página pública)

Planos normalmente nascem junto com uma BillingPlanPage (POST /billing-plan-pages), mas também podem ser criados sozinhos — útil para o fluxo simplificado acima, onde você não precisa de uma página de preços hospedada:

const plan = await client.plans.create({
  item_id: itemId,
  interval: "MONTHLY",
  // plan_page_id omitido — plano fica avulso
});

// depois, se quiser, vincule a uma página existente:
await client.plans.attachToPage(plan.id, pageId);
// ou desvincule de novo:
await client.plans.detachFromPage(plan.id);