flutter_eps 0.0.2
flutter_eps: ^0.0.2 copied to clipboard
Cross-platform EPS payment integration for Flutter (Android, iOS, Desktop, Web coming soon)
EPS BD Flutter Package #
A Flutter package to integrate EPS Bangladesh Payment Gateway into Flutter apps.
Supports token generation, checkout via WebView, payment callbacks, and transaction verification.
Supported Platforms #
| Platform | Status |
|---|---|
| Android | ✅ Supported |
| iOS | ✅ Supported |
| macOS | ✅ Supported |
| Windows | ✅ Supported |
| Linux | ✅ Supported |
Features #
- EPS token request
- WebView checkout
- Success / fail / cancel callback handling
- Transaction verification
- Sandbox & live environment support
Requirements #
- Flutter >= 3.10.0
- Dart >= 3.0.0
environment:
sdk: ">=3.0.0 <4.0.0"
flutter: ">=3.10.0"
Installation #
flutter pub add flutter_eps
Or add manually:
dependencies:
flutter_eps: ^latest
Then run:
flutter pub get
Import #
import 'package:flutter_eps/flutter_eps.dart';
Usage Example #
Initialize and Start Payment #
Future<void> initiatePayment(BuildContext context) async {
// Generate a unique transaction ID
final txnId = DateTime.now().millisecondsSinceEpoch.toString();
// Initialize EPS (Test environment)
final initializer = EpsInitialization(
environment: EpsEnvironment.testBox,
userName: 'Epsdemo@gmail.com',
password: 'Epsdemo258@',
hashKey: 'FHZxyzeps56789gfhg678ygu876o=',
merchantId: '29e86e70-0ac6-45eb-ba04-9fcb0aaed12a',
storeId: 'd44e705f-9e3a-41de-98b1-1674631637da',
);
// Uncomment for LIVE environment
/*
final initializer = EpsInitialization(
environment: EpsEnvironment.live,
userName: 'LIVE_USERNAME',
password: 'LIVE_PASSWORD',
hashKey: 'LIVE_HASH_KEY',
merchantId: 'LIVE_MERCHANT_ID',
storeId: 'LIVE_STORE_ID',
);
*/
final eps = EpsController(initializer: initializer);
// Build the payment request
final request = EpsPaymentRequest(
merchantId: initializer.merchantId,
storeId: initializer.storeId,
customerOrderId: 'ORD-$txnId',
merchantTransactionId: txnId,
totalAmount: 5.0,
successUrl: 'https://example.com/success',
failUrl: 'https://example.com/fail',
cancelUrl: 'https://example.com/cancel',
customerName: 'Roman Hossen',
customerEmail: 'romangazi@gmail.com',
customerAddress: 'Dhaka',
customerCity: 'Gazipur',
customerPostcode: '1212',
customerCountry: 'BD',
customerPhone: '01700000000',
productName: 'Demo Product',
);
try {
final response = await eps.initializePayment(request);
// Open WebView if redirect URL is provided
final redirectUrl = response['RedirectURL'];
if (redirectUrl != null) {
Navigator.push(
context,
MaterialPageRoute(
builder: (_) => EpsWebView(
url: redirectUrl,
onPaymentFinished: (status) async {
if (status == 'SUCCESS') {
await eps.verifyTransaction(txnId);
}
},
),
),
);
} else {
// Handle failure to get RedirectURL
debugPrint('EPS payment failed: RedirectURL not returned.');
}
} catch (e) {
debugPrint('Error initiating EPS payment: $e');
}
}
Environments #
| Environment | Description |
|---|---|
EpsEnvironment.testBox |
Sandbox testing |
EpsEnvironment.live |
Production payments |
Notes #
- Always verify transactions after a successful payment
- Do not hardcode live credentials in production apps
- Use HTTPS callback URLs in live mode
- Server-side verification is recommended for high-value transactions