Socket
Book a DemoInstallSign in
Socket

wahdx-api

Package Overview
Dependencies
Maintainers
1
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

Source
npmnpm
Version
1.0.0
Version published
Maintainers
1
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)

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

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
};

// 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'
};

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',
    ...
  }
}
*/

Persyaratan Sistem

  • Node.js >= 20.18.3

Lisensi

MIT

Keywords

payment

FAQs

Package last updated on 14 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