thai_promptpay 0.1.0 copy "thai_promptpay: ^0.1.0" to clipboard
thai_promptpay: ^0.1.0 copied to clipboard

Pure-Dart PromptPay (Thai EMVCo QR) toolkit: build and parse the QR payload for mobile, National ID / Tax ID and e-Wallet, with amount and CRC validation.

example/example.dart

// A tour of thai_promptpay. Run with: dart run example/example.dart
import 'package:thai_promptpay/thai_promptpay.dart';

void main() {
  // ── Encode ────────────────────────────────────────────────────────────────
  // Mobile, static (no amount):
  print(promptPayMobile('0812345678'));
  // Mobile (formatted input is fine), 100.00 baht = 10000 satang → dynamic QR:
  print(promptPayMobile('081-234-5678', amountSatang: 10000));
  // 13-digit National ID / personal Tax ID (MOD-11 validated), 250.75 baht:
  print(promptPayNationalId('1101700230708', amountSatang: 25075));
  // 15-digit e-Wallet ID:
  print(promptPayEWallet('004999000000001'));

  // Render the returned string as a QR with any package (qr_flutter, qr, ...).

  // ── Decode (verifies the CRC) ────────────────────────────────────────────
  final p = decodePromptPay(promptPayMobile('0812345678', amountSatang: 5000));
  print('${p.target.type.name} ${p.target.value} '
      '${p.amountSatang} satang dynamic=${p.isDynamic}');
  // mobile 0812345678 5000 satang dynamic=true

  // Non-throwing: returns null on a bad payload / CRC mismatch.
  print(tryDecodePromptPay('not a promptpay qr')); // null

  // CRC-16/CCITT-FALSE is exported too.
  print(crc16ccitt('123456789').toRadixString(16)); // 29b1
}
0
likes
0
points
171
downloads

Publisher

verified publisher10v3n4m.cc

Weekly Downloads

Pure-Dart PromptPay (Thai EMVCo QR) toolkit: build and parse the QR payload for mobile, National ID / Tax ID and e-Wallet, with amount and CRC validation.

Repository (GitHub)
View/report issues

Topics

#promptpay #thai #qr #payment #emvco

License

unknown (license)

Dependencies

thainum

More

Packages that depend on thai_promptpay