Logo
Flutter

Usage

Import the module

import 'package:n2app/n2app.dart';

Call gesture

The n2app-flutter-plugin currently expose the following n2Tap SoftPOS operations:

  • Check Installation: to check if SoftPOS app has been installed on the device
  • Activation: to activate the app and load configs from the backend
  • WarmUp: to warm up the SoftPOS app, perform the runtime checking on device and application
  • Transaction: to perform a transaction like card-present sales and qr sales

Check Installation

bool isSoftPOSInstalled = await N2app.isSoftPOSInstalled();
if (isSoftPOSInstalled) {
    // SoftPOS is installed — proceed to warm-up and transactions
} else {
    // SoftPOS not installed — prompt user to install or show an alternative flow
}

N2app.isSoftPOSInstalled() — Returns: bool? - true if installed, false otherwise, null on error

Warm up

Call warmUp before performing transactions so the SoftPOS app can initialize required services.

N2app.warmUp(
    onSuccess: (String message) {
        // Handle warm-up success: update UI state or proceed to activation/transaction
        // e.g. show a success toast or enable action buttons
    },
    onFailed: (String error) {
        // Handle warm-up failure: show error, retry, or fallback
    },
);

Parameters:

  • onSuccess: Callback function called when warm up succeeds
  • onFailed: Callback function called when warm up fails

INFO: Call warmUp() early in your app lifecycle to reduce latency when processing transactions.

Activate

Provide the activation code returned by your vendor or backend. Handle both callbacks.

N2app.activation(
    activationCode: 'YOUR_ACTIVATION_CODE',
    onSuccess: (String message) {
        // Activation succeeded: store state and enable transactions
    },
    onFailed: (String error) {
        // Activation failed: show error and allow retry
    },
);

Parameters:

  • code: Activation code provided by Neurogine
  • onSuccess: Callback function called when activation succeeds
  • onFailed: Callback function called when activation fails

posMessageId Helper Function (Optional)

String genPosMessageId() => DateTime.now().millisecondsSinceEpoch.toString();

posMessageId should be unique per transaction. Use timestamps, UUIDs, or server-generated IDs so you can reconcile transactions later.

Card-Present Transaction

Process a card-present sale transaction:

N2app.triggerSaleTransaction(
    amount: 0.10,
    posMessageId: genPosMessageId(),
    onSuccess: (Transactionsuccess result) {
        // Transaction succeeded: inspect result.transactionResponse
        debugPrint("Sale success: ${result.message}");
        debugPrint("Response: ${result.transactionResponse?.toJson()}");
    },
    onFailed: (String error) {
        // Transaction failed: show error and allow retry
        debugPrint("Sale failed: $error");
    },
);

Parameters:

  • amount: Transaction amount (double)
  • posMessageId: Unique identifier for the transaction (String)
  • onSuccess: Callback with Transactionsuccess object
  • onFailed: Callback with error message

Merchant QR Transaction

Generate a merchant QR code for payment:

N2app.triggerMerchantQRTransaction(
    amount: 0.10,
    posMessageId: genPosMessageId(),
    onSuccess: (Transactionsuccess result) {
        // Merchant QR succeeded
        debugPrint("Merchant QR success: ${result.message}");
    },
    onFailed: (String error) {
        // Merchant QR failed: show error to merchant and allow retry
        debugPrint("Merchant QR failed: $error");
    },
);

Parameters:

  • amount: Transaction amount (double)
  • posMessageId: Unique identifier for the transaction (String)
  • onSuccess: Callback with Transactionsuccess object
  • onFailed: Callback with error message

Guest QR Transaction

Process a guest-initiated QR code payment:

N2app.triggerGuestQRTransaction(
    amount: 0.10,
    posMessageId: genPosMessageId(),
    onSuccess: (Transactionsuccess result) {
        // Guest QR succeeded: show confirmation to buyer
        debugPrint("Guest QR success: ${result.message}");
    },
    onFailed: (String error) {
        // Guest QR failed: inform buyer and optionally retry
        debugPrint("Guest QR failed: $error");
    },
);

Parameters:

  • amount: Transaction amount (double)
  • posMessageId: Unique identifier for the transaction (String)
  • onSuccess: Callback with Transactionsuccess object
  • onFailed: Callback with error message

Notes:

  • Always implement onSuccess and onFailed callbacks and update UI/state accordingly.

On this page