π 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.
Supported Platforms
x
iOSx
Android
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 | β | β |
This Plugin Using Native KHQR SDK
- iOS using
BakongKHQR (1.0.0.17)
- Android using
kh.gov.nbc.bakong_khqr:sdk-java:1.0.0.15
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',
currency: KhqrCurrency.khr,
amount: 0,
);
final khqrData = await _khqrSdk.generateIndividual(info);
Generate KHQR (Merchant)
final info = MerchantInfo(
bakongAccountId: 'kimhak@dev',
acquiringBank: 'Dev Bank',
merchantId: '123456',
merchantName: 'Kimhak',
currency: KhqrCurrency.usd,
amount: 0,
);
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',
currency: KhqrCurrency.usd,
amount: 100,
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);
Generate KHQR Deeplink
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 β