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

pakasir-js

v1.1.0

Published

The fastest Pakasir SDK. 4KB. Zero dependencies.

Readme

pakasir-js

The fastest Pakasir SDK. 4KB. Zero dependencies.

Ultra-lean TypeScript payment library for Pakasir API. Works on Node 18+, Bun, and Deno.

Installation

npm i pakasir-js

Quick Start

Initialize

import { Pakasir } from 'pakasir-js';

const pakasir = new Pakasir({
    project: 'myshop',
    apiKey: 'sk_live_xxxxx'
});

Create Payment URL (Instant)

const paymentUrl = pakasir.createPaymentUrl({
    amount: 50000,
    order_id: 'ORD123',
    redirect_url: 'https://myshop.com/success'
});

// Redirect user: window.location.href = paymentUrl

Create Transaction (QRIS)

const result = await pakasir.createTransaction('qris', {
    amount: 50000,
    order_id: 'ORD456',
    customer_email: '[email protected]',
    customer_phone: '08123456789'
});

console.log(result.data?.payment_url);

Check Transaction Status

const txn = await pakasir.getTransaction({ order_id: 'ORD456' });
console.log(txn.data?.status); // 'pending' | 'success' | 'failed'

Poll Transaction Status (Alternative to Webhooks)

// Poll every 2 seconds, up to 30 attempts (1 minute timeout)
const result = await pakasir.pollTransaction(
    { order_id: 'ORD456' },
    { interval: 2000, maxAttempts: 30 }
);

console.log(result.data?.status); // Returns when status changes or timeout

API Reference

| Method | Params | Returns | | ----------------------------------- | ------------------------------------------------------------ | ------------------------------ | | createPaymentUrl(params) | amount, order_id, redirect_url?, qris_only? | string (URL) | | createTransaction(method, params) | method: 'qris' \| 'bni_va' \| ..., amount, order_id, ... | Promise<TransactionResponse> | | getTransaction(params) | order_id | Promise<TransactionResponse> | | pollTransaction(params, options) | order_id, interval?, maxAttempts? | Promise<TransactionResponse> | | cancelTransaction(params) | order_id | Promise<TransactionResponse> | | simulatePayment(params) | order_id | Promise<TransactionResponse> | | validateWebhook(payload) | webhook payload object | boolean |

Payment Methods

import { PaymentMethod } from 'pakasir-js';

PaymentMethod.QRIS;
PaymentMethod.BNI_VA;
PaymentMethod.BRI_VA;
PaymentMethod.CIMB_VA;
PaymentMethod.PERMATA_VA;
PaymentMethod.MAYBANK_VA;
PaymentMethod.PAYPAL;
// ... and 4 more

Webhook Handling

app.post('/webhook', (req, res) => {
    const payload = req.body;

    if (!pakasir.validateWebhook(payload)) {
        return res.status(401).json({ error: 'Invalid signature' });
    }

    // Process payment based on payload.status
    if (payload.status === 'success') {
        // Update order status in database
    }

    res.json({ ok: true });
});

Error Handling

import { PakasirError, HttpError } from 'pakasir-js';

try {
    await pakasir.getTransaction({ order_id: 'ORD999' });
} catch (err) {
    if (err instanceof HttpError) {
        console.error(`HTTP ${err.status}: ${err.body}`);
    } else if (err instanceof PakasirError) {
        console.error(err.message);
    }
}

Sandbox Mode

Automatically detected from API key prefix:

// Sandbox mode (auto-detected)
const pakasir = new Pakasir({
    project: 'myshop',
    apiKey: 'sk_test_xxxxx' // Triggers sandbox
});

// Or explicit
const pakasir = new Pakasir({
    project: 'myshop',
    apiKey: 'sk_live_xxxxx',
    sandbox: true // Force sandbox
});

Performance

  • Bundle Size: ~4KB minified + gzipped
  • Zero Dependencies: No external packages
  • Tree-Shakeable: Import only what you need
  • Payment URL: <1ms (no network call)
  • API Calls: Minimal overhead

License

ISC