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
int transactionPlatformsTypeId = 0;
@override
void initState() {
super.initState();
if (kIsWeb) {
transactionPlatformsTypeId = 1; // Web
} else if (Platform.isAndroid) {
transactionPlatformsTypeId = 2; // Android
} else if (Platform.isIOS) {
transactionPlatformsTypeId = 3; // iOS
} else if (Platform.isWindows || Platform.isLinux || Platform.isMacOS) {
transactionPlatformsTypeId = 1; // Desktop treated as Web
}
}
// 1. Text Controllers for Live Credentials
final _userEmailController = TextEditingController();
final _passwordController = TextEditingController();
final _hashKeyController = TextEditingController();
final _merchantIdController = TextEditingController();
final _storeIdController = TextEditingController();
// live
// final initializer = EpsInitialization(
// environment: EpsEnvironment.live,
// userName: 'LIVE_USERNAME',
// password: 'LIVE_PASSWORD',
// hashKey: 'LIVE_HASH_KEY',
// merchantId: 'LIVE_MERCHANT_ID',
// storeId: 'LIVE_STORE_ID',
// );
Future<void> _initiatePayment() async {
final String txnId = DateTime.now().millisecondsSinceEpoch.toString();
// 2. Initialize Config (Uses Controllers for Live, Defaults for Test)
final initializer = EpsInitialization(
environment: _selectedEnv,
userName: _selectedEnv == EpsEnvironment.live
? _userEmailController.text
: 'Epsdemo@gmail.com',
password: _selectedEnv == EpsEnvironment.live
? _passwordController.text
: 'Epsdemo258@',
hashKey: _selectedEnv == EpsEnvironment.live
? _hashKeyController.text
: 'FHZxyzeps56789gfhg678ygu876o=',
merchantId: _selectedEnv == EpsEnvironment.live
? _merchantIdController.text
: "29e86e70-0ac6-45eb-ba04-9fcb0aaed12a",
storeId: _selectedEnv == EpsEnvironment.live
? _storeIdController.text
: "d44e705f-9e3a-41de-98b1-1674631637da",
);
final eps = EpsController(initializer: initializer);
final request = EpsPaymentRequest(
merchantId: initializer.merchantId,
transactionTypeId: transactionPlatformsTypeId,
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: "example@gmail.com",
customerAddress: "Dhaka",
customerCity: "Dhaka",
customerPostcode: "1212",
customerCountry: "BD",
customerPhone: "01777777777",
productName: "Demo Product",
);
setState(() => _statusLog = "Initializing...");
final response = await eps.initializePayment(request);
if (response['RedirectURL'] != null) {
if (!mounted) return;
Navigator.push(
context,
MaterialPageRoute(
builder: (_) => EpsWebView(
url: response['RedirectURL'],
onPaymentFinished: (status) async {
if (status == 'SUCCESS') {
final verifyRes = await eps.verifyTransaction(txnId);
setState(
() =>
_statusLog = "SUCCESS: ${verifyRes['EpsTransactionId']}",
);
} else {
setState(() => _statusLog = "Payment $status");
}
},
),
),
);
} else {
setState(() => _statusLog = "Error: ${response['ErrorMessage']}");
}
}
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