Socket
Book a DemoInstallSign in
Socket

wahdx-api

Package Overview
Dependencies
Maintainers
0
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

wahdx-api

Package untuk generate QRIS dan cek payment status secara realtime dengan API OrderKuota dari https://api.wahdx.co

1.0.4
latest
Source
npmnpm
Version published
Weekly downloads
9
800%
Maintainers
0
Weekly downloads
 
Created
Source

wahdx-api

Package untuk generate QRIS dan cek payment status secara realtime dengan API OrderKuota dari https://api.wahdx.co.

Fitur

  • Membaca dan ekstrak kode QR dari gambar
  • Generate kode QR dengan nominal tertentu
  • Cek status pembayaran secara realtime
  • Generate bukti transaksi (receipt)
  • Kompatibel di semua platform (Windows, Linux, Mac)

Instalasi

npm install wahdx-api

Konfigurasi

Buat file .env di root project Anda:

WAHDX_TOKENKEY=your_wahdx_token_key
ORKUT_TOKEN_AUTH=your_orkut_token_auth
ORKUT_USERNAME=your_orkut_username

Catatan: Untuk mendapatkan tokenKey, Anda bisa membelinya di halaman https://api.wahdx.co

Opsi Konfigurasi

OpsiDeskripsiDefault
storeNameNama toko yang akan ditampilkan pada receipt-
defaultQrPathPath ke QRIS static yang didownload di merchant orderkuota-
tokenKeyToken key dari WAHDX-
auth_tokenToken autentikasi OrderKuota-
auth_usernameUsername OrderKuota-
autoGenerateReceiptMengaktifkan/menonaktifkan pembuatan receipt otomatistrue

Penggunaan

Contoh Lengkap

import QRISPayment from 'wahdx-api';
import '@dotenvx/dotenvx/config';
import fs from 'fs';

// Konfigurasi
const config = {
    storeName: 'AHDX STORE',
    defaultQrPath: 'QRIS.png', // Path ke QRIS static yang didownload di merchant orderkuota
    tokenKey: process.env.WAHDX_TOKENKEY,
    auth_token: process.env.ORKUT_TOKEN_AUTH,
    auth_username: process.env.ORKUT_USERNAME,
    autoGenerateReceipt: true // Atur false jika tidak ingin otomatis membuat receipt
};

// Membuat instance QRISPayment
const qrisPayment = new QRISPayment(config);

async function main() {
    try {
        console.log('=== TEST REALTIME QRIS PAYMENT ===\n');
        const randomAmount = Math.floor(Math.random() * 99) + 1; // Random 1-99
        const amount = 100 + randomAmount; // Base 100 + random amount
        const reference = 'REF' + Date.now();
        
        // Generate QR code
        const { qrBuffer } = await qrisPayment.generateQRFromImage(amount);
        
        // Save QR code image
        fs.writeFileSync(`qr-${amount}.png`, qrBuffer);
        
        console.log('=== TRANSACTION DETAILS ===');
        console.log('Reference:', reference);
        console.log('Amount:', amount);
        console.log('QR Image:', `qr-${amount}.png`);
        console.log('\nSilakan scan QR code dan lakukan pembayaran');
        console.log('\nMenunggu pembayaran...\n');

        // Check payment status with 5 minutes timeout
        const startTime = Date.now();
        const timeout = 5 * 60 * 1000;

        while (Date.now() - startTime < timeout) {
            const result = await qrisPayment.checkPayment(reference, amount);
            
            if (result.success && result.data.status === 'PAID') {
                console.log('✓ Pembayaran berhasil!');
                if (result.receipt) {
                    console.log('✓ Bukti transaksi:', result.receipt.filePath);
                }
                return;
            }

            await new Promise(resolve => setTimeout(resolve, 10000));   // delay 10 detik
            console.log('Menunggu pembayaran...');
        }

        throw new Error('Timeout: Pembayaran tidak diterima dalam 5 menit');
        
    } catch (error) {
        console.error('Error:', error.message);
    }
}

main();

API Reference

Inisialisasi

import QRISPayment from 'wahdx-api';

const config = {
    storeName: 'NAMA TOKO',
    defaultQrPath: 'path/to/qris/template.png',
    tokenKey: 'your_wahdx_token_key',
    auth_token: 'your_orkut_token_auth',
    auth_username: 'your_orkut_username',
    autoGenerateReceipt: true // Atur false jika tidak ingin otomatis membuat receipt
};

const qrisPayment = new QRISPayment(config);

Generate QR dari Template

const amount = 10000; // Rp 10.000
// Menggunakan default QR yang sudah diatur
const { qrString, qrBuffer } = await qrisPayment.generateQRFromImage(amount);
// Atau dengan path QR spesifik
// const { qrString, qrBuffer } = await qrisPayment.generateQRFromImage(amount, 'path/to/qris/template.png');

// Simpan QR ke file
fs.writeFileSync('qr-output.png', qrBuffer);

Cek Status Pembayaran

const reference = 'REF' + Date.now();
const amount = 10000;

const result = await qrisPayment.checkPayment(reference, amount);
console.log(result);
/*
Output jika berhasil:
{
  success: true,
  data: {
    status: 'PAID',
    amount: 10000,
    reference: 'REF1234567890',
    ...
  },
  receipt: {
    filePath: 'path/to/receipt.pdf',
    ...
  }
}
*/

Generate Receipt Secara Manual

Jika Anda telah menonaktifkan autoGenerateReceipt dalam konfigurasi, Anda dapat menghasilkan receipt secara manual dengan metode berikut:

// Ketika pembayaran sudah diterima
const result = await qrisPayment.checkPayment(reference, amount);

if (result.success && result.data.status === 'PAID') {
  // Generate receipt secara manual
  const receipt = await qrisPayment.generateReceipt(result.data);
  console.log('Receipt berhasil dibuat:', receipt.filePath);
}

FAQ

Q: Bagaimana cara mendapatkan tokenKey agar bisa menggunakan module ini?

A: Anda bisa membeli tokenKey di halaman utama https://api.wahdx.co

Q: Bagaimana cara mendapatkan kredensial API OrderKuota?

A: Silahkan kunjungi dokumentasi api https://api.wahdx.co/api-docs untuk mendapatkan token pada akun orderkuota anda.

Q: Apakah module ini bisa digunakan di project CommonJS?

A: Ya! Package ini mendukung dual module system (ESM dan CommonJS). Anda bisa menggunakan dengan dua cara:

  • Dengan ES Modules (dalam file .js dengan type: "module" di package.json):
import QRISPayment from 'wahdx-api';

const qrisPayment = new QRISPayment(config);
// gunakan qrisPayment
  • Dengan CommonJS (dalam file .cjs atau project tanpa type: "module"):
const QRISPayment = require('wahdx-api');

const qrisPayment = new QRISPayment(config);
// gunakan qrisPayment

Package secara otomatis mendeteksi format yang digunakan dan menyediakan versi yang sesuai.

Lisensi

MIT

Keywords

payment

FAQs

Package last updated on 22 Jul 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.