flutter_nexi

⚠️ Unofficial Flutter plugin for integrating Nexi/XPay payments on Android and iOS.

Pub Pipeline Star on GitHub License: GPLv3

Overview

flutter_nexi is a cross-platform plugin that allows you to integrate Nexi's XPay SDK into your Flutter apps. It provides a simple interface to initiate and handle payments on both Android and iOS using the official native libraries under the hood.

Note: This is not an official Nexi package. Use it at your own discretion and verify compliance with Nexi's terms and security requirements.


Features

  • βœ… Payment processing via Nexi XPay
  • πŸ“± Native integration on Android and iOS
  • πŸ” Callback-based payment result handling
  • πŸ§ͺ Test and production environment support

Supported Platforms

  • βœ… Android (API 21+)
  • βœ… iOS (15.6+)

Installation

Add the plugin to your pubspec.yaml:

dependencies:
  flutter_nexi: ^1.0.0

How to Make a Payment

You can trigger a payment using the FlutterNexi class. Here's a minimal example of how to initiate a payment when a button is pressed:

import 'package:flutter/material.dart';
import 'package:flutter_nexi/flutter_nexi.dart';

class MyApp extends StatefulWidget {
  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  // Initialize the plugin with your secret key
  final _flutterNexiPlugin = FlutterNexi(secretKey: 'your_secret_key');

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(title: const Text('Nexi Payment Example')),
        body: Center(
          child: FilledButton(
            onPressed: () {
              _flutterNexiPlugin.pay(
                alias: 'your_alias',
                codTrans: 'your_transaction_code',
                amount: 1000, // in cents, i.e., €10.00
                currency: 'EUR',
              );
            },
            child: const Text('Pay'),
          ),
        ),
      ),
    );
  }
}

πŸ” ProGuard Configuration (Android)

If you're building a release version of your app with code shrinking and obfuscation enabled (e.g., using R8 or ProGuard), you must add the following rules to prevent breaking Nexi's SDK functionality.

βž• Add to android/app/proguard-rules.pro:

## Nexi Rules
-keep class it.angelocassano.flutter_nexi.**  { *; }
-keep class it.nexi.xpay.**  { *; }

# Suppress warnings for 3DS SDK classes
-dontwarn com.nets.igfs_3ds_sdk_android.dto.project.AuthenticationRequestParameters
-dontwarn com.nets.igfs_3ds_sdk_android.dto.project.ChallengeParameters
-dontwarn com.nets.igfs_3ds_sdk_android.dto.project.ConfigParameters
-dontwarn com.nets.igfs_3ds_sdk_android.dto.protocol.ErrorMessage
-dontwarn com.nets.igfs_3ds_sdk_android.event.CompletionEvent
-dontwarn com.nets.igfs_3ds_sdk_android.event.ProtocolErrorEvent
-dontwarn com.nets.igfs_3ds_sdk_android.event.RuntimeErrorEvent
-dontwarn com.nets.igfs_3ds_sdk_android.graphics.IUiCustomization
-dontwarn com.nets.igfs_3ds_sdk_android.graphics.UiCustomization
-dontwarn com.nets.igfs_3ds_sdk_android.service.IChallengeStatusReceiver
-dontwarn com.nets.igfs_3ds_sdk_android.service.ITransaction
-dontwarn com.nets.igfs_3ds_sdk_android.service.impl.ThreeDS2Service

License

flutter_nexi is available under the GPLv3 license. See the LICENSE file for more info.

Libraries

flutter_nexi