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

@starvale-sdk/svalepay

v1.0.8

Published

Official Node.js & TypeScript SDK for SValePay Core API (Create & Status)

Readme

SValePay Node.js SDK

Official SDK untuk integrasi SValePay Core API. Cepat, ringan (Zero Dependency), dan mendukung penuh TypeScript & JavaScript.

🚀 Fitur Utama

  • Core API Focus: Hanya fitur esensial (createPayment & getStatus).
  • TypeScript Support: Definisi tipe data lengkap untuk kenyamanan coding.
  • White Label Error: Pesan error otomatis disesuaikan dengan brand SValePay.
  • Node.js 18+ Ready: Menggunakan standar fetch modern.

📦 Instalasi

Gunakan npm atau yarn untuk menginstal:

npm install @starvale-sdk/svalepay
# atau
yarn add @starvale-sdk/svalepay

🛠️ Penggunaan (Usage)

1. Inisialisasi Client

Anda membutuhkan Business ID dan Secret Key yang bisa didapatkan dari Dashboard Merchant SValePay.

JavaScript (CommonJS):

const { SValePay } = require('@starvale-sdk/svalepay');

const svale = new SValePay({
  businessId: 'SVP-XXXXX', // Business ID Anda
  secretKey: 'svp_live_xxxx', // Secret Key Anda
  timeout: 10000 // Opsional: default 10 detik
});

TypeScript (ES Modules):

import { SValePay } from '@starvale-sdk/svalepay';

const svale = new SValePay({
  businessId: 'SVP-XXXXX',
  secretKey: 'svp_live_xxxx'
});

2. Membuat Pembayaran (Create Payment)

Gunakan fungsi ini untuk menginisialisasi transaksi baru. Jika Anda mengisi payment_method dengan QRIS, Anda akan langsung mendapatkan kode QR (QR String).

async function handleCreatePayment() {
  try {
    const response = await svale.createPayment({
      amount: 25000,
      customer_email: '[email protected]',
      description: 'Pembayaran Order #123',
      payment_method: 'QRIS', // Opsional: Isi 'QRIS' untuk mendapatkan kode QR langsung
      external_id: 'ORDER-123' // ID unik dari sistem Anda (Invoice ID)
    });

    console.log('Transaction ID:', response.data.trx_id);
    console.log('Checkout URL:', response.data.checkout_url);
    
    // Jika menggunakan QRIS, gunakan payment_code untuk generate QR
    if (response.data.payment_code) {
      console.log('QRIS String:', response.data.payment_code);
    }
  } catch (error) {
    console.error('Error:', error.message);
  }
}

Parameter Request (CreatePaymentRequest): | Field | Tipe | Wajib | Deskripsi | | :--- | :--- | :--- | :--- | | amount | number | Ya | Nominal pembayaran dalam IDR. | | customer_email | string | Ya | Alamat email pelanggan. | | external_id | string | Tidak | ID unik dari sistem Anda (direkomendasikan). | | description | string | Tidak | Deskripsi transaksi. | | payment_method | string | Tidak | Contoh: QRIS atau OVO. | | success_url | string | Tidak | URL pengalihan saat sukses (untuk Payment Link). |


3. Cek Status Pembayaran (Check Status)

Gunakan fungsi ini untuk memverifikasi apakah pelanggan sudah membayar.

async function checkStatus(trx_id) {
  try {
    const status = await svale.getStatus(trx_id);
    
    if (status.data.status === 'success') {
      console.log('Pembayaran Lunas!');
    } else {
      console.log('Status Saat Ini:', status.data.status); // 'pending', 'expired', dsb.
    }
  } catch (error) {
    console.error('Gagal Cek Status:', error.message);
  }
}

🛡️ Penanganan Error (Error Handling)

SDK ini menggunakan class SValePayError. Jika terjadi kesalahan pada API, pesan error akan otomatis disesuaikan agar tetap menjaga brand SValePay (White Label).

try {
  await svale.createPayment({...});
} catch (err) {
  console.log(err.name); // 'SValePayError'
  console.log(err.code); // Kode status HTTP (401, 400, 500, dsb.)
  console.log(err.message); // Pesan error yang sudah disanitasi
}

📄 Lisensi

MIT License - © 2024 StarVale Technology.