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

qris-gatepay

v1.2.0

Published

SDK resmi QRIS GatePay (Node.js, zero-dependency) — buat transaksi QRIS, cek status, batalkan, verifikasi webhook HMAC.

Readme

qris-gatepay

SDK resmi QRIS GatePay untuk Node.js — buat transaksi QRIS, cek status, batalkan, dan verifikasi webhook (HMAC-SHA256). Zero-dependency (pakai fetch bawaan Node 18+ & modul crypto).

📖 Dokumentasi lengkap: https://gatepay.biz.id/gpa/docs

Instalasi

npm install qris-gatepay

Inisialisasi

const GatePay = require('qris-gatepay');

const gp = new GatePay({
  apiKey: 'gpk_live_xxxxxxxx',        // gpk_live_… (produksi) / gpk_test_… (sandbox)
  webhookSecret: 'whsec_xxxx',        // opsional, buat verifyWebhook
});

Mode live vs sandbox ditentukan oleh prefix API key (gpk_live_ / gpk_test_) — bukan setelan terpisah. Simpan key live di produksi, key test di staging.

Buat Transaksi

const tx = await gp.createPayment({
  amount: 10000,            // wajib, minimal 500
  orderId: 'INV-123',       // opsional — ID pesananmu, dibalikin di webhook & status
  note: 'Order #123',       // opsional (keterangan bebas)
  expiryMinutes: 15,        // opsional (1–1440, default 5)
  adminMode: 'merchant',    // opsional: 'merchant' (default) / 'customer'
});
// tx.order_id ada di respons; webhook & getPayment juga membawanya → lookup order gampang

console.log(tx.reference);      // PAY-...
console.log(tx.total_pay);      // nominal yang harus dibayar customer
console.log(tx.payment_link);   // halaman checkout siap pakai → redirect customer ke sini
console.log(tx.qr_string);      // atau render QR sendiri dari string ini

Cek Status

const status = await gp.getPayment(tx.reference);
console.log(status.status); // pending | paid | expired | cancelled

Batalkan (hanya saat pending)

await gp.cancelPayment(tx.reference, { reason: 'Dibatalkan pembeli' });

Tunggu Pembayaran (polling built-in)

Nggak mau setup webhook? Pakai polling bawaan — otomatis cek status sampai selesai.

const ac = new AbortController();          // ac.abort() untuk stop polling
const final = await gp.watchPayment(tx.reference, {
  interval: 5000,                          // cek tiap 5 detik (default)
  timeout: 5 * 60 * 1000,                  // menyerah setelah 5 menit (default)
  signal: ac.signal,
  onStatusChange: (p) => console.log('berubah:', p.status),
  onTimeout: () => console.log('waktu habis, masih pending'),
  onError: (e) => console.warn('poll error (lanjut):', e.message),
});
if (final.status === 'paid') console.log('Lunas!');

Verifikasi Webhook (Express)

Gunakan raw body — jangan di-JSON.parse sebelum verifikasi.

const express = require('express');
const app = express();

app.post('/webhook/gatepay',
  express.raw({ type: 'application/json' }),   // penting: raw body
  (req, res) => {
    const rawBody = req.body.toString('utf8');
    const ok = gp.verifyWebhook({
      rawBody,
      timestamp: req.header('X-Gatepay-Timestamp'),
      signature: req.header('X-Gatepay-Signature'),
    });
    if (!ok) return res.status(401).send('invalid signature');

    const evt = JSON.parse(rawBody);
    if (evt.event === 'payment.paid') {
      // tandai order lunas — evt.data.reference, evt.data.total_pay, dst.
    }
    res.sendStatus(200); // balas 2xx secepatnya
  }
);

Error handling

const { GatePayError } = GatePay;
try {
  await gp.createPayment({ amount: 100 }); // di bawah minimum (min Rp500)
} catch (e) {
  if (e instanceof GatePayError) console.log(e.status, e.message, e.data);
}

API

| Method | Keterangan | |---|---| | createPayment({ amount, note?, expiryMinutes?, adminMode? }) | Buat transaksi QRIS | | getPayment(reference) | Cek status transaksi | | cancelPayment(reference, { reason? }) | Batalkan (hanya pending) | | watchPayment(reference, { interval?, timeout?, onUpdate? }) | Poll status sampai selesai (paid/expired/cancelled) atau timeout | | verifyWebhook({ rawBody, timestamp, signature, secret? }) | Verifikasi tanda tangan webhook → boolean |

MIT © GatePay