khqr_sdk 3.0.0 copy "khqr_sdk: ^3.0.0" to clipboard
khqr_sdk: ^3.0.0 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 package is not officially release from NBC.

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

Features Supported #

Features Android iOS Web Windows macOS Linux
Generate Individual
Generate Merchant
Generate Deeplink
Verify
Decode
Decode Non-KHQR
Check Bakong Account
KHQR Card Widget

Installation #

Run the following command in your Flutter project:

flutter pub add khqr_sdk

Tip

Check the pub.dev page for the minimum required Dart/Flutter SDK version.

Usage #

Import KHQR SDK Package #

import 'package:khqr_sdk/khqr_sdk.dart';

Generate Individual KHQR #

final info = IndividualInfo(
  bakongAccountId: 'kimhak@dev',
  merchantName: 'Kimhak',
  accountInformation: '123456789',
  currency: KhqrCurrency.khr,
  amount: 0,
);
final res = KhqrSdk.generateIndividual(info);

Generate Merchant KHQR #

final info = MerchantInfo(
  bakongAccountId: 'kimhak@dev',
  acquiringBank: 'Dev Bank',
  merchantId: '123456',
  merchantName: 'Kimhak',
  currency: KhqrCurrency.usd,
  amount: 0,
);
final res = KhqrSdk.generateMerchant(info);

Note

To generate Dynamic QR required to set amount more than zero with 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,
);
final res = KhqrSdk.generateMerchant(info);

Verify / Decode / Decode Non-KHQR #

const qrCode = '00020101021129270010kimhak@dev01091234567895204599953031165802KH5906Kimhak6010Phnom Penh9917001317324625358296304B59E';

final verifyRes = KhqrSdk.verify(qrCode);
final decodeRes = KhqrSdk.decode(qrCode);
final decodeNonKhqrRes = KhqrSdk.decodeNonKhqr(qrCode);
const qrCode = '00020101021129270010kimhak@dev01091234567895204599953031165802KH5906Kimhak6010Phnom Penh9917001317324625358296304B59E';
final url = 'http://api.example.com/v1/generate_deeplink_by_qr';

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

// generateDeepLink and checkBakongAccount are async, call them from an async context
final res = await KhqrSdk.generateDeepLink(url, qrCode, sourceInfo);

Check Bakong Account #

final url = 'https://api-bakong.nbc.gov.kh/v1/check_account_by_id';
final bakongAccount = 'kimhak@dev';
final res = await KhqrSdk.checkBakongAccount(url, bakongAccount);

KHQR Card Widget #

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

Tip

KhqrCardWidget also supports dynamic QR countdown (duration, onRegenerate), loading/error overlays (isLoading, loadingWidget, isError, errorOverlay), QR customization (qrTypeNumber, qrErrorCorrectLevel, qrMarginHorizontalRatio, qrMarginVerticalRatio), and display toggles (showEmptyAmount, showCurrencySymbol, showCurrencyLabel, alwaysShowBakongIcon, isDark, showShadow, onAmountTap). 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.

License #

This project is licensed under the MIT License.

Support #

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

Activities #

Alt

12
likes
160
points
297
downloads
screenshot

Documentation

API reference

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

Funding

Consider supporting this project:

ko-fi.com

License

MIT (license)

Dependencies

auto_size_text, crypto, flutter, flutter_svg, http, intl, pretty_qr_code

More

Packages that depend on khqr_sdk