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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@prakrit_m/rdcw-slip

v1.1.2

Published

ไลบรารีสำหรับตรวจสอบสลิปโอนเงินผ่าน RDCW Slip API - A TypeScript library for verifying Thai bank transfer slips using RDCW Slip API

Readme

🚀 RDCW Slip SDK

NPM version NPM Downloads NPM Last Update Node Version License: ISC

SDK สำหรับตรวจสอบสลิปและโควต้าผ่าน RDCW Slip API อย่างง่ายดาย พร้อมรองรับ TypeScript แบบสมบูรณ์

📋 สารบัญ

✨ คุณสมบัติ

  • 🔄 ตรวจสอบสลิปและโควต้าแบบ Real-time
  • 📝 รองรับ TypeScript แบบสมบูรณ์
  • 🔒 ระบบจัดการ Error ที่ครอบคลุม
  • 🚀 Retry mechanism อัตโนมัติ
  • ⏱️ Timeout handling
  • 📊 Logging system

📦 การติดตั้ง

# npm
npm install @prakrit_m/rdcw-slip

# yarn
yarn add @prakrit_m/rdcw-slip

# pnpm
pnpm add @prakrit_m/rdcw-slip

🚀 การใช้งาน

Github Examples

การเริ่มต้นใช้งาน

import RdcwSlip from "@prakrit_m/rdcw-slip";

// สร้าง instance แบบพื้นฐาน
const rdcwSlip = new RdcwSlip("YOUR_CLIENT_ID", "YOUR_CLIENT_SECRET");

// หรือกำหนด config เพิ่มเติม
const rdcwSlip = new RdcwSlip("YOUR_CLIENT_ID", "YOUR_CLIENT_SECRET", {
  timeout: 5000,
  retries: 2,
  logger: console,
});

ตรวจสอบโควต้า

try {
  const response = await rdcwSlip.checkQuota();
  if (response.success) {
    console.log("โควต้าคงเหลือ:", response.quota.limit - response.quota.usage);
  } else {
    console.error("เกิดข้อผิดพลาด:", response.message);
  }
} catch (error) {
  console.error("เกิดข้อผิดพลาดในการเชื่อมต่อ:", error);
}

ตรวจสอบสลิป

try {
  const response = await rdcwSlip.checkSlip("QR_PAYLOAD_HERE");
  if (response.success) {
    console.log("ข้อมูลการโอน:", {
      จำนวนเงิน: response.data.data.amount, // หน่วยสตางค์
      วันที่โอน: response.data.data.transDate, // เช่น "20230708"
      เวลาที่โอน: response.data.data.transTime, // เช่น "12:51:57"
      ธนาคารผู้โอน: response.data.data.sendingBank, // รหัสธนาคาร
      ชื่อผู้โอน: response.data.data.sender.name, // ชื่อบัญชีภาษาอังกฤษ
    });
  } else {
    console.error("เกิดข้อผิดพลาด:", response.message);
  }
} catch (error) {
  console.error("เกิดข้อผิดพลาดในการเชื่อมต่อ:", error);
}

ตัวอย่างการใช้งานเพิ่มเติม

  • Basic Usage - ตัวอย่างการใช้งานพื้นฐาน
  • Advanced Usage - ตัวอย่างการใช้งานขั้นสูง
  • Error Handling - ตัวอย่างการจัดการข้อผิดพลาด

📚 API Reference

RdcwSlip

Constructor Options

interface RdcwSlipConfig {
  baseUrl?: string; // URL ของ API (default: https://suba.rdcw.co.th/v1/inquiry)
  testPayload?: string; // ข้อมูล qrCode ทดสอบ สำหรับดึง Quota
  timeout?: number; // ระยะเวลา timeout (default: 10000ms)
  retries?: number; // จำนวนครั้งที่จะ retry (default: 2)
  logger?: Logger; // ระบบ logging
}

Methods

| Method | Description | Parameters | Return Type | | -------------------- | -------------------- | ----------------- | ----------------------------------------------------- | | checkQuota() | ตรวจสอบโควต้าคงเหลือ | - | Promise<QuotaResponseSuccess \| QuotaResponseError> | | checkSlip(payload) | ตรวจสอบสลิป | payload: string | Promise<SlipResponseSuccess \| SlipResponseError> |

🚨 Error Handling

ตัวอย่างการจัดการข้อผิดพลาดเบื้องต้น

import RdcwSlip, { RdcwSlipError, RdcwErrorCode } from "@prakrit_m/rdcw-slip";

const slip = new RdcwSlip("YOUR_CLIENT_ID", "YOUR_CLIENT_SECRET");

try {
  const result = await slip.checkSlip("QR_PAYLOAD");

  // จัดการ Error จาก API Response
  if (!result.success) {
    switch (result.code) {
      case 10001: // Invalid QR Payload
        console.error("QR Code ไม่ถูกต้อง");
        break;
      case 10002: // Not a Slip Verify API QR
        console.error("QR Code นี้ไม่ใช่ QR สำหรับตรวจสอบสลิป");
        break;
      case 21001: // Subscription Required
        console.error("กรุณาต่ออายุ subscription");
        break;
      case 40000: // IP Not Allowed
        console.error("IP ของคุณไม่ได้รับอนุญาตให้เข้าถึง API");
        break;
    }
    return;
  }

  // จัดการกรณีสำเร็จ
  console.log("ข้อมูลการโอน:", result.data);
} catch (error) {
  // จัดการ Error จาก SDK
  if (error instanceof RdcwSlipError) {
    switch (error.code) {
      case RdcwErrorCode.INVALID_CLIENT:
        console.error("ข้อมูล Client ID หรือ Client Secret ไม่ถูกต้อง");
        break;
      case RdcwErrorCode.NETWORK_ERROR:
        console.error("เกิดปัญหาในการเชื่อมต่อเครือข่าย");
        break;
    }
  }
}

รหัสข้อผิดพลาด (Error Codes)

| รหัส | คำอธิบาย | การแก้ไข | | ------------ | ----------------------------------- | ---------------------------------- | | 10001 | QR Code ไม่ถูกต้อง | ตรวจสอบความถูกต้องของ QR Code | | 10002 | ไม่ใช่ QR สำหรับตรวจสอบสลิป | ใช้ QR Code จากสลิปโอนเงินเท่านั้น | | 20001, 20002 | ไม่สามารถเชื่อมต่อกับ API ของธนาคาร | ลองใหม่ภายหลัง | | 21001 | Subscription หมดอายุ/เต็มโควต้า | ต่ออายุ subscription | | 40000 | IP ไม่ได้รับอนุญาต | ตรวจสอบ IP ที่ลงทะเบียน |

SDK Error Codes

| รหัส | คำอธิบาย | การแก้ไข | | -------------- | -------------------------- | ------------------------------- | | INVALID_CLIENT | ข้อมูล Client ไม่ถูกต้อง | ตรวจสอบ Client ID และ Secret | | NETWORK_ERROR | ปัญหาการเชื่อมต่อเครือข่าย | ตรวจสอบการเชื่อมต่ออินเทอร์เน็ต |

สำหรับตัวอย่างการจัดการข้อผิดพลาดแบบละเอียดเพิ่มเติม สามารถดูได้ที่ Error Handling Example

🤝 การมีส่วนร่วมในการพัฒนา

  1. Fork โปรเจกต์
  2. สร้าง branch สำหรับฟีเจอร์ของคุณ (git checkout -b feature/amazing-feature)
  3. Commit การเปลี่ยนแปลง (git commit -m 'เพิ่มฟีเจอร์ใหม่')
  4. Push ไปยัง branch (git push origin feature/amazing-feature)
  5. เปิด Pull Request

สำหรับการรายงานปัญหาหรือข้อเสนอแนะ สามารถเปิด Issue ได้

📄 License

This is a third-party SDK, not an official RDCW Slip SDK.
SDK นี้พัฒนาโดยบุคคลภายนอก ไม่ใช่ผลิตภัณฑ์อย่างเป็นทางการจาก RDCW Slip

Licensed under ISC

📚 เอกสารเพิ่มเติม

สำหรับข้อมูลเพิ่มเติมเกี่ยวกับ API สามารถอ่านได้ที่ RDCW Slip API Documentation