khqr_sdk 1.1.1 copy "khqr_sdk: ^1.1.1" to clipboard
khqr_sdk: ^1.1.1 copied to clipboard

Standardization of QR Code (EMV) that will promote wider use of mobile retail payments in Cambodia.

🍃 KHQR SDK 🍃

Note

This KHQR SDK plugin is not officially release from NBC.

This is a simple interface layer that connects your Dart code directly to the original native platform-specific SDK, bridging Flutter and native functionality seamlessly.

KHQR SDK Document Reference #

The standardization of KHQR code specifications will help promote wider use of mobile retail payments in Cambodia and provide consistent user experience for merchants and consumers. It can enable interoperability in the payment industry. A common QR code would facilitate payments among different schemes, e-wallets and banks and would encourage small merchants to adopt KHQR code as payment method. KHQR is created for retail payment in Cambodia and Cross-Border payment within asean countries. It only requires a single QR for receiving payment from any mobile apps including Bakong app, making QR payment simple for both customers and merchants in Cambodia.


khqr sdk preview

Supported Platforms #

  • ✅ iOS
  • ✅ Android

Native KHQR SDK Version #

  • iOS using BakongKHQR (v1.0.0.16)
  • Android using kh.gov.nbc.bakong_khqr:sdk-java:1.0.0.14

Features Supported #

See the example app for detailed implementation information.

Features Android iOS
Generate Individual
Generate Merchant
Generate Deeplink
Verify
Decode
Decode Non-KHQR
KHQR Card Widget

Platform specific setup #

iOS #

1. Add source to Podfile (ios/Podfile)

source "https://sambo:ycfXmxxRbyzEmozY9z6n@gitlab.nbc.gov.kh/khqr/khqr-ios-pod.git"

Note

If you don't see Podfile, please disable Swift Package Manager in pubspec.yaml

flutter:
disable-swift-package-manager: true

After save, Podfile will be created automatically.

Example Podfile
source "https://sambo:ycfXmxxRbyzEmozY9z6n@gitlab.nbc.gov.kh/khqr/khqr-ios-pod.git"

# Uncomment this line to define a global platform for your project
# platform :ios, '12.0'

# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'

project 'Runner', {
'Debug' => :debug,
'Profile' => :release,
'Release' => :release,
}

def flutter_root
generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__)
unless File.exist?(generated_xcode_build_settings_path)
raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first"
end

File.foreach(generated_xcode_build_settings_path) do |line|
matches = line.match(/FLUTTER_ROOT\=(.*)/)
return matches[1].strip if matches
end
raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get"
end

require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)

flutter_ios_podfile_setup

target 'Runner' do
use_frameworks!

flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
target 'RunnerTests' do
inherit! :search_paths
end
end

post_install do |installer|
installer.pods_project.targets.each do |target|
flutter_additional_ios_build_settings(target)
end
end

2. Run pod install (make sure your terminal is in ios folder)

pod install

Android #

  • No need to do anything it's working out of the box.

Usage #

Create instance of KHQR SDK #

import 'package:khqr_sdk/khqr_sdk.dart';

final _khqrSdk = KhqrSdk();

Generate KHQR (Individual) #

final info = IndividualInfo(
  bakongAccountId: 'kimhak@dev',
  merchantName: 'Kimhak',
  accountInformation: '123456789',
);
final khqrData = await _khqrSdk.generateIndividual(info);

Generate KHQR (Merchant) #

final info = MerchantInfo(
  bakongAccountId: 'kimhak@dev',
  acquiringBank: 'Dev Bank',
  merchantId: '123456',
  merchantName: 'Kimhak',
);
final khqrData = await _khqrSdk.generateMerchant(info);

Note

Generate dynamic QR that set amount is required to set expiration

// 1 hour from now
final expire = DateTime.now().millisecondsSinceEpoch + 3600000;
final info = MerchantInfo(
bakongAccountId: 'kimhak@dev',
acquiringBank: 'Dev Bank',
merchantId: '123456',
merchantName: 'Kimhak',
amount: 1,
expirationTimestamp: expire,
);

Verify KHQR #

const qrCode = '00020101021129270010kimhak@dev01091234567895204599953031165802KH5906Kimhak6010Phnom Penh9917001317324625358296304B59E';
final isValid = await _khqrSdk.verify(qrCode);

Decode KHQR #

const qrCode = '00020101021129270010kimhak@dev01091234567895204599953031165802KH5906Kimhak6010Phnom Penh9917001317324625358296304B59E';
final khqrDecodeData = await _khqrSdk.decode(qrCode);

Decode Non-KHQR #

const qrCode = '00020101021129270010kimhak@dev01091234567895204599953031165802KH5906Kimhak6010Phnom Penh9917001317324625358296304B59E';
final nonKhqrDecodeData = await _khqrSdk.decodeNonKhqr(qrCode);
const qrCode = '00020101021129270010kimhak@dev01091234567895204599953031165802KH5906Kimhak6010Phnom Penh9917001317324625358296304B59E';

final sourceInfo = SourceInfo(
  appName: 'Example App',
  appIconUrl: 'http://cdn.example.com/icons.logo.png',
  appDeepLinkCallBack: 'http://app.example.com/callback',
);

final deeplinkInfo = DeeplinkInfo(
  qr: qrCode,
  url: 'http://api.example.com/v1/generate_deeplink_by_qr',
  sourceInfo: sourceInfo,
);

final deeplinkData = await _khqrSdk.generateDeepLink(deeplinkInfo);

KHQR Card Widget #

KhqrCardWidget(
  width: 300.0,
  receiverName: 'Kimhak',
  amount: 0.00,
  keepIntegerDecimal: false,
  currency: KhqrCurrency.khr,
  qr: khqrContent,
),

See the example for runnable examples of various usages.

Bugs or Requests #

If you encounter any problems feel free to open an issue. If you feel the library is missing a feature, please raise a ticket on GitHub and I'll look into it. Pull request are also welcome.

See Contributing.md.

Support #

Don't forget to give it a like 👍 or a star ⭐

Activities #

Alt

7
likes
160
points
307
downloads
screenshot

Publisher

verified publishermrrhak.com

Weekly Downloads

Standardization of QR Code (EMV) that will promote wider use of mobile retail payments in Cambodia.

Homepage
Repository (GitHub)
View/report issues
Contributing

Topics

#khqr #khqr-sdk #khqr-code #bakong-khqr #bakong

Documentation

API reference

Funding

Consider supporting this project:

ko-fi.com

License

MIT (license)

Dependencies

auto_size_text, flutter, flutter_svg, freezed_annotation, intl, json_annotation, plugin_platform_interface, pretty_qr_code

More

Packages that depend on khqr_sdk