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

tokovoucher-api

v0.0.2

Published

TypeScript wrapper for Toko Voucher API

Downloads

6

Readme

Toko Voucher API TypeScript Wrapper

Wrapper TypeScript yang bersih dan type-safe untuk API Toko Voucher.

Fitur

  • 🔒 Type safety dengan TypeScript
  • 📚 Cakupan API lengkap
  • 🧰 Utilitas bawaan
  • 🔐 Pembuatan signature otomatis
  • 📈 Penanganan error yang baik

Instalasi

npm install tokovoucher-api

Memulai

Konfigurasi

Sebelum menggunakan API, Anda perlu mendapatkan Member Code dan Secret Key dari dashboard Toko Voucher Anda.

import { TokoVoucherApi } from 'tokovoucher-api';

const tokoVoucher = new TokoVoucherApi({
  memberCode: 'MEMBER_CODE_ANDA',
  secretKey: 'SECRET_KEY_ANDA',
  signatureDefault: 'DEFAULT_SIGNATURE_ANDA',
});

Cek Saldo

const balance = await tokoVoucher.checkBalance();
console.log(`Saldo Anda saat ini: ${balance.data.saldo}`);

Pencarian Produk

// Mencari produk Free Fire
const products = await tokoVoucher.searchProducts('FF');
console.log(`Ditemukan ${products.data.length} produk`);

// Menampilkan detail produk
products.data.forEach(product => {
  console.log(`${product.code}: ${product.nama_produk} - Rp ${product.price}`);
});

Membuat Deposit

// Buat permintaan deposit menggunakan QRIS
const deposit = await tokoVoucher.createDeposit(100000, 'QRIS');
console.log(`Deposit dibuat: ${deposit.data.metode}`);
console.log(`Bayar ke: ${deposit.data.pay}`);
console.log(`Kadaluarsa pada: ${deposit.data.expired_at}`);

Melakukan Transaksi

import { TokoVoucherApi, utils } from 'tokovoucher-api';

// Buat ID referensi unik
const refId = utils.generateRefId();

// Buat transaksi
const transaction = await tokoVoucher.createTransaction({
  ref_id: refId,
  produk: 'FF5',  // Kode produk
  tujuan: '12345678',  // ID Player
  server_id: '',  // Kosong untuk produk tanpa server ID
});

console.log(`Status transaksi: ${transaction.status}`);
console.log(`Pesan: ${transaction.message}`);

// Jika transaksi masih pending, periksa status nanti
if (transaction.status === 'pending') {
  // Implementasikan mekanisme retry yang tepat di production
  setTimeout(async () => {
    const status = await tokoVoucher.checkTransactionStatus(refId);
    console.log(`Status terupdate: ${status.status}`);
  }, 10000);
}

Memeriksa Status Transaksi

const status = await tokoVoucher.checkTransactionStatus('ref-id-anda');
console.log(`Status: ${status.status}`);
console.log(`SN: ${status.sn}`);

Penanganan Error

Semua metode API akan melempar error standar yang dapat ditangkap:

try {
  const balance = await tokoVoucher.checkBalance();
  console.log(`Saldo: ${balance.data.saldo}`);
} catch (error) {
  console.error(`Error: ${error.message}`);
  console.error(`Kode status: ${error.statusCode}`);
}

Catatan Penting

Sesuai dengan dokumentasi Toko Voucher:

⚠️ Penting

  • Semua HTTP Error harus diatur sebagai transaksi PENDING
  • NETWORK TIMEOUT harus diatur sebagai transaksi PENDING
  • Pastikan menunggu callback final dari Toko Voucher untuk mendapatkan status transaksi
  • Atau periksa status transaksi secara berkala setiap 10 menit
  • Documentation detail nya silahkan cek Docs Tokovoucher

Lisensi

MIT