A Spring Boot web application for generating KHQR (Bakong KHQR) payment codes. This application provides a user-friendly interface to create QR codes for payment transactions in Cambodia using the Bakong KHQR standard.
- KHQR Code Generation: Generate QR codes compliant with Bakong KHQR standard
- Multiple Currencies: Support for both KHR (Cambodian Riel) and USD
- User-Friendly Interface: Clean, modern web interface built with HTML, CSS, and Tailwind CSS
- Real-Time Preview: Display generated KHQR codes immediately after generation
- Customizable Payment Details: Set amount, bill number, and purpose of transaction
- Error Handling: Comprehensive error handling and user feedback
- QR Code Base64 Encoding: Generated QR codes are encoded in Base64 for easy integration
- Java: JDK 21 or higher
- Gradle: 8.0 or higher
- Node.js: 20.11.1 or higher (for frontend build)
- npm: 10.2.4 or higher
- Backend: Spring Boot 4.0.2
- Frontend: HTML, CSS, Tailwind CSS, JavaScript
- QR Code Generation: ZXing (com.google.zxing)
- KHQR SDK: Bakong KHQR SDK (kh.gov.nbc.bakong_khqr)
- Build Tool: Gradle
- Node Integration: gradle-node plugin for npm builds
org.springframework.boot:spring-boot-starter-webmvc- Spring Web MVCorg.springframework.boot:spring-boot-starter-thymeleaf- Template enginecom.google.zxing:core:3.5.4- QR code generation (core)com.google.zxing:javase:3.5.4- QR code generation (Java SE)kh.gov.nbc.bakong_khqr:sdk-java:1.0.0.16- Bakong KHQR SDKorg.projectlombok:lombok- Boilerplate code reduction
org.springframework.boot:spring-boot-devtools- Development tools- Test frameworks for unit and integration testing
git clone <repository-url>
cd mond-pay# Using Gradle wrapper (Windows)
gradlew.bat build
# Or on Linux/Mac
./gradlew build# Using Gradle wrapper
gradlew.bat bootRun
# Or on Linux/Mac
./gradlew bootRunThe application will start on http://localhost:8080
- Open your browser and navigate to
http://localhost:8080 - Fill in the payment details:
- Amount: Enter the payment amount (e.g., 10.00)
- Currency: Select KHR (Cambodian Riel) or USD
- Bill Number: Enter a unique bill/invoice number
- Purpose of Transaction: Describe the purpose (optional)
- Click "Generate KHQR Code"
- The KHQR QR code will be displayed on the page
- Share or scan the QR code for payment
mond-pay/
├── src/
│ ├── main/
│ │ ├── java/
│ │ │ └── edu/student/mondpay/
│ │ │ ├── MondPayApplication.java # Spring Boot entry point
│ │ │ ├── feature/
│ │ │ │ └── pay/
│ │ │ │ └── khqr/
│ │ │ │ ├── KHQRController.java # REST/Web controller
│ │ │ │ ├── KHQRService.java # Service interface
│ │ │ │ ├── KHQRServiceImpl.java # Service implementation
│ │ │ │ ├── constant/
│ │ │ │ │ └── KHQRInfo.java # Configuration constants
│ │ │ │ └── request/
│ │ │ │ └── CreateKHQRCodeRequest.java # Request DTO
│ │ │ └── util/
│ │ │ └── QrCodeUtil.java # QR code utilities
│ │ ├── frontend/ # Frontend assets
│ │ │ ├── main.css
│ │ │ ├── package.json
│ │ │ └── tailwind.config.js
│ │ └── resources/
│ │ ├── application.properties # Application configuration
│ │ ├── static/ # Static assets
│ │ │ └── main.css
│ │ └── templates/
│ │ └── index.html # Main HTML template
│ └── test/
│ └── java/MondPayApplicationTests.java # Test classes
├── gradle/ # Gradle wrapper
├── build.gradle # Gradle build configuration
├── settings.gradle # Gradle settings
└── README.md # This file
Edit src/main/resources/application.properties to customize application settings:
spring.application.name=mond-payUpdate the KHQR merchant information in KHQRInfo.java:
bakongAccountId- Your Bakong account IDaccountInformation- Account information detailsacquiringBank- Acquiring bank namemerchantName- Your merchant namemerchantCity- Your merchant citymobileNumber- Contact mobile numberstoreLabel- Store labelterminalLabel- Terminal label
Handles HTTP requests for the web interface:
GET /- Display the main KHQR payment formPOST /generate-khqr- Generate KHQR code from form data
Core business logic for KHQR code generation:
- Constructs KHQR data with merchant and payment information
- Integrates with Bakong KHQR SDK
- Converts QR code to Base64 string
Utility class for QR code operations:
- Generates QR code Base64 strings using ZXing library
DTO (Data Transfer Object) for KHQR code creation requests:
amount- Payment amountcurrency- Currency code (USD/KHR)billNumber- Unique bill/invoice numberpurposeOfTransaction- Payment purpose