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

pakkasir

v1.0.0

Published

Fully-typed TypeScript SDK for the Pakasir payment gateway.

Readme


Features

  • Fully typed. Strict TypeScript, zero any, end-to-end response inference.
  • Zero runtime dependencies. Uses the platform fetch available in Node 18+ and all modern browsers.
  • Clean architecture. Injectable HTTP transport, discriminated error hierarchy, domain-oriented modules.
  • Tested. 33+ unit tests covering happy paths, API errors, network failures, and schema validation.
  • Extensible. Add new endpoints or custom middleware (retries, logging) without touching core code.

Installation

pnpm add pakkasir
# or
npm install pakkasir
# or
yarn add pakkasir

Requires Node.js ≥ 18 (for native fetch).

Quick start

import { PakasirClient } from 'pakkasir';

const client = new PakasirClient({
  apiKey: process.env.PAKASIR_API_KEY!,
  project: 'my-shop',
});

// Create a QRIS transaction.
const { payment } = await client.transactions.create({
  method: 'qris',
  orderId: 'INV-0001',
  amount: 15_000,
});

console.log(payment.payment_number); // QRIS payload string

Configuration

PakasirClient accepts the following options. All but apiKey and project have sensible defaults and can also be read from environment variables.

| Option | Type | Default | Env var | | ---------------- | ------------------------ | ------------------------- | ------------------ | | apiKey | string | — | PAKASIR_API_KEY | | project | string | — | PAKASIR_PROJECT | | baseUrl | string | https://app.pakasir.com | PAKASIR_BASE_URL | | timeoutMs | number | 30_000 | — | | defaultHeaders | Record<string, string> | {} | — | | transport | HttpTransport | built-in FetchTransport | — | | fetch | typeof fetch | globalThis.fetch | — |

Modules

Transactions

// Create
await client.transactions.create({ method: 'qris', orderId, amount });

// Fetch current state
await client.transactions.detail({ orderId, amount });

// Cancel a pending transaction
await client.transactions.cancel({ orderId, amount });

Supported payment methods: qris, bni_va, bri_va, cimb_niaga_va, maybank_va, permata_va, sampoerna_va, bnc_va, atm_bersama_va, artha_graha_va.

Payments

// Sandbox only: simulate a completed payment.
await client.payments.simulate({ method: 'bni_va', orderId, amount });

Webhooks

// In your HTTP handler:
const payload = client.webhooks.verify(request.rawBody, {
  expectedOrderId: 'INV-0001',
  expectedAmount: 15_000,
  expectedProject: 'my-shop',
});

if (client.webhooks.isPaymentSuccess(payload)) {
  await fulfillOrder(payload.order_id);
}

URL integration

import { buildPaymentRedirectUrl } from 'pakkasir';

const hostedUrl = buildPaymentRedirectUrl({
  project: 'my-shop',
  amount: 15_000,
  orderId: 'INV-0001',
  qrisOnly: true,
  redirectUrl: 'https://merchant.example.com/thanks',
});

Error handling

Every error thrown by the SDK extends PakasirError and carries a kind discriminant:

import { PakasirError, ApiError, NetworkError, ValidationError } from 'pakkasir';

try {
  await client.transactions.create({ method: 'qris', orderId, amount });
} catch (err) {
  if (err instanceof PakasirError) {
    switch (err.kind) {
      case 'api':
        /* non-2xx HTTP response: err.status, err.body */ break;
      case 'network':
        /* transport failure: err.cause */ break;
      case 'validation':
        /* bad input / bad response shape */ break;
      case 'webhook':
        /* webhook verification failed */ break;
    }
  }
}

Architecture

PakasirClient
  ├── transactions  ── TransactionsModule ──┐
  ├── payments      ── PaymentsModule      ─┤
  └── webhooks      ── WebhooksModule       │  (pure, no network)
                                            │
                         ┌──────────────────┘
                         ▼
                    HttpTransport  (interface)
                         │
                         └─► FetchTransport  (default impl)

The HttpTransport interface is the only seam that touches the network, making the SDK trivial to unit-test. Every module is pure and produces typed HttpRequest objects; the transport is responsible for auth injection, serialization, and error translation.

For a full walkthrough, read examples/usage.ts.

Development

pnpm install      # install dependencies
pnpm typecheck    # strict TypeScript check
pnpm lint         # ESLint
pnpm format       # Prettier
pnpm test         # Vitest
pnpm test:coverage # with coverage report
pnpm build        # emit dist/
pnpm example      # run examples/usage.ts

Contributing

Contributions are very welcome. Please read CONTRIBUTING.md and our Code of Conduct before opening a pull request.

For security issues, please follow the process described in SECURITY.md instead of opening a public issue.

Versioning

This project follows Semantic Versioning 2.0. Releases are fully automated by semantic-release: every push to main is analyzed, the next version is computed from Conventional Commit types (fix: → patch, feat: → minor, feat!: → major), and CHANGELOG.md, Git tags, the GitHub Release, and the npm publication are all produced in one shot.

See CHANGELOG.md for release notes.

License

MIT © pakkasir contributors