| Crates.io | promptpay-rs |
| lib.rs | promptpay-rs |
| version | 0.5.0 |
| created_at | 2025-06-29 09:58:00.652803+00 |
| updated_at | 2025-12-23 19:58:43.62345+00 |
| description | A Rust library for generating PromptPay QR code compliant with EMVCo standards, supporting Thai phone numbers and Tax IDs. |
| homepage | |
| repository | https://github.com/mantvmass/promptpay-rs |
| max_upload_size | |
| id | 1730603 |
| size | 1,302,422 |
Welcome to promptpay-rs, a lightweight Rust library for generating PromptPay QR code compliant with EMVCo standards. This library is designed with modern Rust practices, providing a simple and efficient interface to create QR code for Thai payment systems, supporting phone numbers and Tax IDs.
Add promptpay-rs to your Cargo.toml:
[dependencies]
promptpay-rs = "0.5.0"
Then run:
cargo build
Here is a quick example of how to use promptpay-rs to generate a PromptPay QR code payload:
use promptpay_rs::PromptPayQR;
fn main() -> Result<(), Box<dyn std::error::Error>> {
// Initialize a new PromptPay QR object with a phone number
// This will be the recipient of the payment.
let mut qr = PromptPayQR::new("081-234-5678");
// Set the payment amount for the QR code
// The amount is in THB (Thai Baht)
qr.set_amount(250.75);
// Create the QR payload using the formatter
// This payload is a string representation following PromptPay's standard
let payload = qr.create()?;
// You can use this value with a QR code generation library (e.g., `qrcode`).
println!("Payload: {}", payload);
Ok(())
}
This will generate a value like:
00020101021229370016A000000677010111011300668123456785802TH53037645406100.506304XXXX
You can use this value with a QR code generation library (e.g., qrcode).
Comprehensive documentation is available at docs.rs/promptpay-rs.
Contributions are welcome! Please submit a pull request to branch develop or open an issue on the GitHub repository for bug reports, feature requests, or suggestions.
This library is unofficial and is not affiliated with or endorsed by PromptPay or the Bank of Thailand. Use it at your own risk.
This project is licensed under the MIT License. See the LICENSE file for details.