flutter_elavon 1.0.2
flutter_elavon: ^1.0.2 copied to clipboard
Flutter plugin for Elavon Payment Gateway SDK
Flutter Elavon Plugin #
Flutter plugin for integrating Elavon Payment Gateway SDK (Converge Commerce SDK 6.8.0) into Flutter applications.
Features #
- Account creation and management
- Device discovery and connection
- Transaction processing (Sale, Refund, Pre-Auth, etc.)
- Real-time transaction event streaming
Setup #
Android #
- Add the plugin and required dependencies to your
pubspec.yaml:
dependencies:
flutter_elavon:
path: ../flutter_elavon
path_provider: ^2.1.0 # Required by Elavon SDK
Important: The path_provider plugin is required because the Elavon SDK uses it internally. Make sure to add it explicitly to your app's dependencies.
-
Add Elavon SDK Libraries: Due to size limitations, the Elavon SDK library files (JAR/AAR) are not included in the published package. You need to:
- Obtain the Elavon Commerce SDK 6.8.0 libraries from Elavon
- Copy all JAR and AAR files to your app's
android/libs/directory - Update your app's
android/app/build.gradleto include:dependencies { // Include all JAR files implementation fileTree(dir: '../flutter_elavon/android/libs', include: ['*.jar']) // Include required AAR files implementation(name: 'deckard-android-6.8.0', ext: 'aar') implementation(name: 'commerce-android-6.8.0', ext: 'aar') } - Add to your
android/app/build.gradle:repositories { flatDir { dirs '../flutter_elavon/android/libs' } }
-
The plugin requires the following permissions (already included in AndroidManifest.xml):
- Bluetooth permissions (BLUETOOTH_SCAN, BLUETOOTH_CONNECT for API 31+)
- Location permission (ACCESS_FINE_LOCATION)
- Phone state permission (READ_PHONE_STATE)
-
Minimum SDK: 28
-
Target SDK: 35
Usage #
import 'package:flutter_elavon/flutter_elavon.dart';
import 'package:flutter/widgets.dart';
void main() async {
// CRITICAL: Ensure Flutter binding is initialized FIRST, before any plugin usage
// This must be called before using path_provider or any other plugins
WidgetsFlutterBinding.ensureInitialized();
// Only after ensureInitialized() can you safely use plugins
runApp(MyApp());
}
// Initialize and create account
final elavon = FlutterElavon();
await elavon.createAccount(PaymentGatewayType.CONVERGE);
// Find and connect devices
final devices = await elavon.findDevices();
if (devices.isNotEmpty) {
await elavon.connectDevice(devices.first);
}
// Process a sale transaction
final result = await elavon.processSale(
amount: 10000, // Amount in cents
currencyCode: 'USD',
);
// Listen to transaction events
elavon.transactionEvents.listen((event) {
print('Transaction event: ${event.type}');
});
Troubleshooting #
PlatformException: Unable to establish connection on channel path_provider #
If you encounter this error:
PlatformException(channel-error, Unable to establish connection on channel: "dev.flutter.pigeon.path_provider_android.PathProviderApi.getApplicationDocumentsPath"., null, null)
Solution:
- Ensure
path_provider: ^2.1.0is explicitly added to your app'spubspec.yamldependencies - Make sure
WidgetsFlutterBinding.ensureInitialized()is called before any plugin usage in yourmain()function - Run a clean rebuild:
flutter clean flutter pub get flutter run - Verify your
main()function looks like this:void main() async { WidgetsFlutterBinding.ensureInitialized(); // Must be first! runApp(MyApp()); }
License #
See LICENSE file for details.