ข้ามไปยังเนื้อหา

CLI

Sample CLI output card

Terminal window
# Zero-install — npx (umbrella package, single tarball)
npx thai-qr-payment 0812345678 --amount 50 -o qr.svg
npx tqp 0812345678 --amount 50 -o qr.svg
# Global install
pnpm add -g thai-qr-payment
thai-qr-payment 0812345678 --amount 50 --merchant "Acme Coffee" -o qr.svg
tqp 0812345678 --format payload

@thai-qr-payment/cli มีไบนารีสองตัว (thai-qr-payment และ tqp) แต่ ชื่อไบนารีไม่ตรงกับชื่อแพ็กเกจ npx จึงไม่สามารถ resolve @thai-qr-payment/cli ไปเป็นไบนารีชื่อ thai-qr-payment ได้โดยอัตโนมัติ ทำให้ npx @thai-qr-payment/cli 0812345678 ล้มเหลวด้วยข้อความ command not found ต้องระบุชื่อไบนารีอย่างชัดเจนผ่าน --package:

Terminal window
# Wrong — npx looks for a `@thai-qr-payment/cli` binary, finds none
npx @thai-qr-payment/cli 0812345678 --amount 50
# → sh: thai-qr-payment: command not found
# Right — use the umbrella (recommended, single tarball)
npx thai-qr-payment 0812345678 --amount 50
# Right — scoped CLI with --package
npx --package=@thai-qr-payment/cli thai-qr-payment 0812345678 --amount 50
npx --package=@thai-qr-payment/cli tqp 0812345678 --amount 50

แนะนำให้ใช้ umbrella เป็นหลัก (มี tarball เดียว รวม dependency ทั้งหมดไว้แล้ว) ใช้ scoped CLI เฉพาะกรณีที่ต้องการ pin เวอร์ชันของแพ็กเกจในสคริปต์ automation เท่านั้น

Terminal window
thai-qr-payment 0812345678 --amount 50 --merchant "Acme Coffee" -o qr.svg

การ์ด SVG เต็มรูปแบบ พร้อม header ของ Thai QR Payment + PromptPay ชื่อร้านค้า และป้ายแสดงยอดเงิน

Terminal window
thai-qr-payment 0812345678 --amount 50 --format matrix --size 512 -o qr.svg

เฉพาะ QR matrix ในรูปแบบ SVG สี่เหลี่ยมจัตุรัส ผู้เรียกควบคุมขนาดได้เอง

Terminal window
thai-qr-payment 0812345678 --amount 50 --format payload
# 00020101021229370016A00000067701011101130066812345678530376454065000.005802TH63041234

สตริง wire ดิบตามมาตรฐาน EMVCo เหมาะสำหรับ pipe ต่อไปยังเครื่องมืออื่น

FlagShortNotes
--recipient <id>-rphone, nationalId, eWallet
--amount <thb>-aละไว้สำหรับ QR แบบ static
--satangกำหนดให้มอง --amount เป็นจำนวนเต็มหน่วยสตางค์
--type <kind>mobile / nationalId / eWallet — override การตรวจจับอัตโนมัติ
--ecc <level>L / M / Q / H (default M)
--format <kind>-fcard (default) / matrix / payload
--theme <kind>color (default) / silhouette
--merchant <name>-mrender เหนือ QR (โหมด card)
--size <px>ขนาด output ของโหมด matrix
--output <path>-oเขียนลงไฟล์ (default คือ stdout)
--help-hแสดงข้อความช่วยเหลือ
--version-vแสดงเวอร์ชันของ CLI
Terminal window
# Dynamic 50 THB card written to file
thai-qr-payment 0812345678 --amount 50 --merchant "Acme" -o qr.svg
# Bare 512 px QR matrix with high error correction
thai-qr-payment 0812345678 --amount 50 --format matrix --size 512 --ecc H -o qr.svg
# Print just the payload (for piping)
thai-qr-payment 0812345678 --amount 50 --format payload | tee payload.txt
# Pay 50.50 from satang
thai-qr-payment 0812345678 --amount 5050 --satang -o qr.svg
# Silhouette theme (monochrome brand artwork)
thai-qr-payment 0812345678 --amount 50 --theme silhouette -o qr.svg
# National ID recipient
thai-qr-payment 1234567890123 --type nationalId --amount 100 -o qr.svg
# e-Wallet recipient
thai-qr-payment 123456789012345 --type eWallet --amount 200 -o qr.svg