naps_flutter 0.0.7 copy "naps_flutter: ^0.0.7" to clipboard
naps_flutter: ^0.0.7 copied to clipboard

A Flutter package for integrating NAPS SUNMI P2 payment terminals using the M2M TLV protocol via TCP/IP and Serial.

NAPS Flutter SDK #

A Flutter package for integrating NAPS SUNMI P2 payment terminals using the M2M TLV protocol over TCP/IP and Serial connections.

Features #

  • Multiple Connectivity Options: Connect to your SUNMI P2 terminal via Wi-Fi (TCP/IP socket on port 4444) or USB (Serial COM port).
  • Payment Processing: Initiate payments and handle terminal responses seamlessly.
  • Confirmation & Cancellation: Confirm approved payments and initiate manual cancellations directly from your POS application.
  • Duplicate Receipts: Retrieve duplicate payment receipts using the transaction STAN.
  • Payment Totals: Request the daily payment totals statement from the terminal.

Getting Started #

To use this package, ensure that your POS device and the SUNMI P2 terminal are on the same local network (for Wi-Fi) or correctly connected via USB Type-C.

Wi-Fi Configuration #

  1. Open the SUNMI P2 terminal settings.
  2. Navigate to About device to find the terminal's IP address.
  3. The terminal listens on port 4444 by default.

Usage #

Here is a basic example of how to use the NAPS SDK to process a payment:

import 'package:naps_flutter/naps_flutter.dart';

void main() async {
  // 1. Initialize the Naps connection and SDK (example via Wi-Fi)
  final connection = NapsTcpConnection(host: '192.168.1.26', port: 4444);
  final napsSdk = NapsSdk(
    connection: connection,
    posId: '0030007', // 7 chars limit
  );

  // 2. Initiate a Payment (e.g., 35.00 MAD)
  final response = await napsSdk.pay(
    amountInCents: 3500, // 35.00 MAD
    currencyCode: '504', // 504 for MAD
  );

  if (response.isSuccess) {
    print('Payment Approved! STAN: ${response.stan}');
    
    // 3. Confirm the payment within 40 seconds
    final confirmationResponse = await napsSdk.confirmPayment(
      originalStan: response.stan!,
      amountInCents: 3500,
      currencyCode: '504',
      sequenceNumber: 1, // original sequence number
      cardMasked: response.cardNumber!,
      expirationDate: response.cardExpirationDate!,
    );
    
    if (confirmationResponse.isSuccess) {
      print('Payment confirmed successfully.');
      // Print customer receipt using confirmationResponse.customerReceipt
    }
  } else {
    print('Payment Failed or Declined.');
  }
}

Supported M2M TLV Commands #

This SDK implements the full M2M TLV API specifications for SUNMI P2:

  • 001 / 101 - Payment Request / Response
  • 002 / 102 - Payment Confirmation
  • 003 / 103 - Cancellation Request
  • 004 / 104 - Cancellation Confirmation
  • 008 / 108 - Duplicate Request
  • 010 / 110 - Totals Request
0
likes
160
points
--
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

A Flutter package for integrating NAPS SUNMI P2 payment terminals using the M2M TLV protocol via TCP/IP and Serial.

Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

flutter, flutter_libserialport

More

Packages that depend on naps_flutter