emvqr 0.0.22 copy "emvqr: ^0.0.22" to clipboard
emvqr: ^0.0.22 copied to clipboard

A plugin by Fawry for scanning EMV QR Codes.

Fawry EMVQR SDK Integration Guide #

Welcome to the comprehensive Fawry EMVQR SDK Integration Guide. This guide will walk you through the seamless integration of Fawry's native Android and iOS SDKs into your Flutter projects for effortless EMVQR scanning.

Table of Contents #


Getting Started #

Adding Fawry EMVQR SDK Pub #

To begin, add the Fawry EMVQR SDK plugin to your Flutter project's dependencies. Open the terminal in the root project and install the pub using following command

flutter pub add emvqr
copied to clipboard

Android Setup #

  1. To integrate with Android, Update the minimum SDK version to 21 or higher in your build.gradle file:
android {
    compileSdkVersion flutter.compileSdkVersion
    minSdkVersion 21
    // ...
}
copied to clipboard
  1. Set your compile sdk version to 34
  compileSdkVersion 34
copied to clipboard
  1. In your build.gradle add the following code to the "buildscript" and "allprojects" blocks
repositories {
    google()
    mavenCentral()
    maven { url 'https://nexus.mobile.fawry.io/repository/maven-public/' }
}
copied to clipboard

iOS Setup #

For iOS integration, follow these steps:

  1. Set the minimum iOS version under "Deployment info" to 12.1 or higher in your Runner project in Xcode.

  2. Enhance pod distribution by adding the following code at the end of the pod file (Podfile):

post_install do |installer|
    installer.pods_project.targets.each do |target|
        target.build_configurations.each do |config|
            config.build_settings['BUILD_LIBRARY_FOR_DISTRIBUTION'] = 'YES'
        end
    end
end
copied to clipboard

Fawry EMVQR SDK Imports #

Before you proceed, make sure to import the necessary Fawry SDK packages at the beginning of your Dart file:

import 'package:emvqr/model/scan_result.dart';
import 'package:emvqr/emvqr.dart';
import 'package:emvqr/model/qr_model.dart';
copied to clipboard

Streaming Result Data #

  late StreamSubscription? _fawryCallbackResultStream;
  QrModel? qrModel;
  List<ScanResult> qrResponses = [];

  @override
  void initState() {
    super.initState();
    setupCallback();
  }

  @override
  void dispose() {
    _fawryCallbackResultStream?.cancel();
    super.dispose();
  }

  Future<void> setupCallback() async {
    try {
      _fawryCallbackResultStream =
          Emvqr.instance.callbackResultStream().listen((event) {
        setState(() {
          Map<Object?, Object?> eventData = event;
          ScanResult response = ScanResult.fromJson(eventData);
          qrResponses.add(response);
          QrModel? model = response.extractQrModel();

          qrModel = model ?? qrModel;
          if (qrModel != null) {
            debugPrint(qrModel.toString());
          }
        });
      });
    } catch (ex) {
      debugPrint("Error in setupCallback: $ex");
    }
  }

  Future<void> startScanning() async {
    await Emvqr.instance.scanQR();
  }
copied to clipboard

Models Explained : #

ScanResult #

PARAMETER NAME PARAMETER TYPE DESCRIPTION
status String The status of the scan operation. This can be a success or an error message.
data String? The optional data obtained from the scan operation. This may be null if no data was retrieved.
extractQrModel() QrModel? Method to return a [QrModel] object from [ScanResult].

QrModel #

PARAMETER NAME TYPE DESCRIPTION
merchantID String The merchant ID associated with the QR code.
mcc String? Merchant Category Code (MCC) - an optional field.
currency String? The currency used for the transaction - an optional field.
amount String The amount of the transaction.
feesAmount String? Fees associated with the transaction - an optional field.
countryCode String? The country code associated with the QR code - an optional field.
merchantName String? The name of the merchant - an optional field.
merchantCity String? The city where the merchant is located - an optional field.
postalCode String? The postal code of the merchant's location - an optional field.
ref1 String? Additional reference information (Reference 1) - an optional field.
ref2 String? Additional reference information (Reference 2) - an optional field.
additionalInfo AdditionalInfo? Additional information associated with the QR code - an optional field.
terminalId String? The terminal ID associated with the QR code - an optional field.
qrTimeStamp String? Timestamp associated with the QR code - an optional field.
unreservedTemplate Map<String, Map<String, String>> Unreserved Template - a map containing String keys and values, where each key is associated with an inner map of type Map<String, String>.

AdditionalInfo #

PARAMETER NAME PARAMETER TYPE DESCRIPTION
storeId String? Store Id information.
billNumber String? Bill number information.
mobileNumber String? Mobile number information.
loyaltyNumber String? Loyalty number information.
referenceLabel String? Reference label information.
customerLabel String? Customer label information.

Conclusion #

You've successfully integrated the Fawry EMVQR SDK into your Flutter project. Follow the streamlined steps for Android and iOS platforms outlined in this guide.

Utilize the startScanning function to initiate QR code scanning and the setupCallback method for result streaming. Extract relevant information using the ScanResult, QrModel, and AdditionalInfo models.

For any queries or assistance, consult the documentation or contact Fawry's support.

Thank you for choosing Fawry. Happy coding!

2
likes
125
points
23
downloads

Publisher

unverified uploader

Weekly Downloads

2024.07.06 - 2025.01.18

A plugin by Fawry for scanning EMV QR Codes.

Documentation

API reference

License

unknown (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on emvqr