Skip to content

prox-dex/kb-manual

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Mond Pay - KHQR Payment Code Generator

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.

Features

  • 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

Prerequisites

  • 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

Technology Stack

  • 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

Dependencies

Core Dependencies

  • org.springframework.boot:spring-boot-starter-webmvc - Spring Web MVC
  • org.springframework.boot:spring-boot-starter-thymeleaf - Template engine
  • com.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 SDK
  • org.projectlombok:lombok - Boilerplate code reduction

Development Dependencies

  • org.springframework.boot:spring-boot-devtools - Development tools
  • Test frameworks for unit and integration testing

Getting Started

1. Clone the Repository

git clone <repository-url>
cd mond-pay

2. Build the Project

# Using Gradle wrapper (Windows)
gradlew.bat build

# Or on Linux/Mac
./gradlew build

3. Run the Application

# Using Gradle wrapper
gradlew.bat bootRun

# Or on Linux/Mac
./gradlew bootRun

The application will start on http://localhost:8080

Usage

  1. Open your browser and navigate to http://localhost:8080
  2. 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)
  3. Click "Generate KHQR Code"
  4. The KHQR QR code will be displayed on the page
  5. Share or scan the QR code for payment

Project Structure

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

Configuration

Edit src/main/resources/application.properties to customize application settings:

spring.application.name=mond-pay

KHQR Configuration

Update the KHQR merchant information in KHQRInfo.java:

  • bakongAccountId - Your Bakong account ID
  • accountInformation - Account information details
  • acquiringBank - Acquiring bank name
  • merchantName - Your merchant name
  • merchantCity - Your merchant city
  • mobileNumber - Contact mobile number
  • storeLabel - Store label
  • terminalLabel - Terminal label

Key Classes

KHQRController

Handles HTTP requests for the web interface:

  • GET / - Display the main KHQR payment form
  • POST /generate-khqr - Generate KHQR code from form data

KHQRServiceImpl

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

QrCodeUtil

Utility class for QR code operations:

  • Generates QR code Base64 strings using ZXing library

CreateKHQRCodeRequest

DTO (Data Transfer Object) for KHQR code creation requests:

  • amount - Payment amount
  • currency - Currency code (USD/KHR)
  • billNumber - Unique bill/invoice number
  • purposeOfTransaction - Payment purpose

About

Build for testing generate to pay and polling for status

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors