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

nusapay-payment-sdk

v1.0.4

Published

NusaPay Payment SDK for JavaScript/TypeScript

Readme

NusaPay Payment SDK

SDK untuk integrasi pembayaran via API. Bisa digunakan di browser atau Node.js.

Installation

npm install nusapay-payment-sdk

1. Inisialisasi Client

import { PaymentClient } from 'nusapay-payment-sdk';

const client = new PaymentClient({
  username: 'NP2023x8tudzzLRh',
  api_key: 'e4f8c2a1b3d4e5f6a7b8c9d0e1f2a3b4',
});

2. createPaymentSession() – Buat Sesi Pembayaran

Buat sesi pembayaran baru dengan daftar item. Sudah termasuk generateToken()

try {
  const session = await client.createPaymentSession({
    payment_method_id: 1,
    total_amount: 100.0,
    items: [
      {
        name: 'iPhone 14 Pro',
        qty: 1,
        price: 100.0,
        code: 'IPH-001'
      }
    ],
    redirect_url: "google.com", //optional
    callback_url: "https://webhook.site/37e3c1e4-5959-4a44-affc-4a3bcc4b8261", //optional
    payment_identifier: "NPay-001" // wajib
  });
  console.log('Session ID:', session.session_id);
  console.log('Total:', session.total_amount);
} catch (error) {
  console.error('Gagal buat sesi:', error.message);
}

Contoh Response

{
  "session_id": "4ba8d8bd-2d8c-4d37-b698-f15e904a8102",
  "access_token": "bc27aef9-f15b-4c55-89ca-87e5f8934fc8",
  "payment_method": null,
  "payment_code": null,
  "payment_identifier": null,
  "total_amount": 100,
  "items": [
    {
      "name": "iPhone 14 Pro",
      "qty": 1,
      "price": 100,
      "code": "IPH-001"
    }
  ],
  "redirect_url": "",
  "status": "created",
  "created_at": "2025-08-11 01:50:05",
  "updated_at": "2025-08-11 01:50:05",
  "url": "?token=bc27aef9-f15b-4c55-89ca-87e5f8934fc8"
}

3. checkStatusPayment() – Check payment status

cek status pembayaran yang telah dibuat.

try {
  const session = await client.checkStatusPayment();
} catch (error) {
}

Contoh Response

{
  "detail": "Payment session rechecked successfully",
  "data": {
    "session_id": "934c2102-6685-4691-b1bf-6b958377a143",
    "access_token": {
      "id": 61,
      "token": "8fbb84c0-9561-4b26-84f7-90ae1c6abf1e",
      "merchant_id": 1,
      "expires_at": "2025-08-18 04:54:55",
      "created_at": "2025-08-18 04:39:53",
      "updated_at": "2025-08-18 04:39:56"
    },
    "payment_method": {
      "id": 1,
      "name": "QRIS",
      "description": "[\n    \"Pilih aplikasi pembayaran digital yang sudah terhubung dengan rekening bank atau dompet digital Anda.\",\n    \"Arahkan kamera pada smartphone Anda ke kode QR yang tertera di struk pembayaran.\",\n    \"Tunggu hingga aplikasi mengenali kode QR tersebut.\",\n    \"Periksa kembali nominal pembayaran yang tertera di aplikasi.\",\n    \"Masukkan PIN atau kata sandi untuk melakukan verifikasi dan tunggu hingga muncul notifikasi pembayaran berhasil.\"\n]",
      "is_active": true,
      "created_at": "2025-08-14 10:14:39",
      "updated_at": "2025-08-14 10:14:39"
    },
    "payment_code": "00020101021226550017ID.CO.NUSAPAY.WWW0118936008360000000002020120303P2G51330017ID.CO.NUSAPAY.WWW020120303P2G5204383553033605406100.005502015802ID5912NUSAPAY DEMO6009TANGERANG610515331626201100EHUSDH7WF0211089788978890520NQ272_36536_68A2AE9B0705365366304438C",
    "order_id": null,
    "total_amount": 100,
    "items": [
      {
        "qty": 1,
        "code": "IPH-001",
        "name": "iPhone 14 Pro",
        "price": 100
      }
    ],
    "redirect_url": "https://payment-page.nusapay.co.id/invoice?token=8fbb84c0-9561-4b26-84f7-90ae1c6abf1e",
    "status": "pending",
    "created_at": "2025-08-18 04:39:53",
    "updated_at": "2025-08-18 04:39:56"
  }
}

SSR Next.js

import { headers } from 'next/headers';
import { PaymentClient } from 'nusapay-payment-sdk';

export default async function Home() {
  const client = new PaymentClient({
    username: 'NP2023x8tudzzLRh',
    api_key: 'e4f8c2a1b3d4e5f6a7b8c9d0e1f2a3b4',
  });

  const request = await headers();
  const session = await client.createPaymentSession({
    payment_method_id: 1,
    total_amount: 100.0,
    items: [
      {
        name: "iPhone 14 Pro",
        qty: 1,
        price: 100.0,
        code: "IPH-001",
      },
    ],
  }, request);

  return (
    <div>{JSON.stringify(session)}</div>
  );
}

Client Side Next.js

"use client"
import { PaymentClient } from 'nusapay-payment-sdk';
import { useEffect, useState } from "react";

export default function Home() {
  const [session, setSession] = useState({});

  useEffect(() => {
    async function fetchData() {
      const client = new PaymentClient({
        username: 'NP2023x8tudzzLRh',
        api_key: 'e4f8c2a1b3d4e5f6a7b8c9d0e1f2a3b4',
      });

      const session = await client.createPaymentSession({
        payment_method_id: 1,
        total_amount: 100.0,
        items: [
          {
            name: "iPhone 14 Pro",
            qty: 1,
            price: 100.0,
            code: "IPH-001",
          },
        ],
      });

      setSession(session);
    }

    fetchData();
  }, []);

  return (
    <div>{JSON.stringify(session)}</div>
  );
}

Browser (via CDN)

Jika tidak pakai bundler, bisa langsung pakai di browser:

<script src="https://cdn.jsdelivr.net/npm/nusapay-payment-sdk/dist/nusapay-payment-sdk.umd.js"></script>
<script>
  const client = new nusapay_payment_sdk.PaymentClient({
    username: 'NP2023x8tudzzLRh',
    api_key: 'e4f8c2a1b3d4e5f6a7b8c9d0e1f2a3b4'
  });

  client.createPaymentSession({ /* ... */ }).then(console.log);
</script>

NusaPay Payment SDK – Dokumentasi v1.0