lokotro_pay 1.0.0
lokotro_pay: ^1.0.0 copied to clipboard
Lokotro Pay: A modern Flutter payment plugin with glassmorphism design for seamless payment collection via cards and mobile money.
Lokotro Pay ๐ณ #
Lokotro Pay is a modern Flutter payment plugin with glassmorphism design for seamless payment collection via cards, mobile money, e-wallets, and more. Built with enhanced UI/UX and inspired by Lokotro's modern design language.
โจ Features #
- ๐จ Modern Glassmorphism Design - Beautiful dark theme with glass-like effects
- ๐ณ Multiple Payment Methods - Cards, Mobile Money, E-Wallets, Bank Transfers
- ๐ Reactive State Management - Built with RxDart for smooth user experience
- ๐ Multi-Environment Support - Development and production configurations
- ๐ Multi-Language Support - 10 languages with easy language switching
- ๐ฑ Responsive Design - Optimized for all screen sizes
- ๐ฏ Haptic Feedback - Enhanced user interaction with tactile responses
- ๐ Secure Processing - Enterprise-grade security for payment handling
- ๐ Easy Integration - Simple API with comprehensive documentation
๐ Quick Start #
Installation #
Add lokotro_pay to your pubspec.yaml:
dependencies:
lokotro_pay: ^1.0.0
Run:
flutter pub get
Basic Usage #
import 'package:flutter/material.dart';
import 'package:lokotro_pay/lokotro_pay.dart';
class PaymentScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: ElevatedButton(
onPressed: () => _startPayment(context),
child: Text('Start Payment'),
),
),
);
}
void _startPayment(BuildContext context) {
// Configure payment settings
final configs = LokotroPayConfigs(
token: 'your_api_token_here',
isProduction: false, // Set to true for production
);
// Create payment request
final paymentBody = LokotroPaymentBody(
systemRef: 'PAYMENT_001',
customRef: 'ORDER_12345',
metadata: {
'customer_id': '12345',
'order_type': 'product_purchase',
},
);
// Launch payment flow
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) => LokotroPayCheckout(
title: 'Complete Payment',
configs: configs,
paymentBody: paymentBody,
onResponse: (response) {
// Handle successful payment
print('Payment successful: ${response.message}');
Navigator.of(context).pop();
},
onError: (error) {
// Handle payment error
print('Payment failed: ${error.message}');
Navigator.of(context).pop();
},
),
),
);
}
}
๐ Documentation #
Configuration #
LokotroPayConfigs
Configure your payment environment and authentication:
final configs = LokotroPayConfigs(
token: 'your_api_token', // Required: API authentication token
isProduction: false, // Optional: Environment (default: false)
customApiUrl: 'https://api.custom.com', // Optional: Custom API endpoint
timeout: Duration(seconds: 60), // Optional: Request timeout
);
LokotroPaymentBody
Define your payment request details:
final paymentBody = LokotroPaymentBody(
systemRef: 'UNIQUE_SYSTEM_REF', // Required: Unique system reference
customRef: 'CUSTOM_REFERENCE', // Optional: Your custom reference
metadata: { // Optional: Additional data
'customer_id': '12345',
'order_details': {...},
},
);
Payment Flow #
The plugin provides a complete payment flow with multiple screens:
- Payment Method Selection - Choose from available payment options
- Payment Form - Enter payment details (card info, phone number, etc.)
- Processing - Secure payment processing with loading indicators
- Result Screen - Success or error feedback with next actions
Supported Payment Methods #
- ๐ณ Payment Cards - Visa, Mastercard, American Express
- ๐ฑ Mobile Money - Various mobile money providers
- ๐ฐ E-Wallets - Digital wallet solutions
- ๐ฆ Bank Transfers - Direct bank account transfers
- โก E-Flash - Instant payment method
- ๐ฏ Lokotro Wallet - Native Lokotro wallet integration
- ๐ Virtual Cards - Virtual payment card support
๐ Multi-Language Support #
The plugin supports 10 languages out of the box. You can set the language when initializing the checkout widget:
import 'package:lokotro_pay/enums/lokotro_pay_language.dart';
LokotroPayCheckout(
// ... other parameters
language: LokotroPayLanguage.french, // Set specific language
// ... other parameters
)
Supported Languages
| Language | Code | Native Name |
|---|---|---|
| English | en |
English |
| French | fr |
Franรงais |
| German | de |
Deutsch |
| Spanish | es |
Espaรฑol |
| Italian | it |
Italiano |
| Russian | ru |
ะ ัััะบะธะน |
| Hindi | hi |
เคนเคฟเคเคฆเฅ |
| Japanese | ja |
ๆฅๆฌ่ช |
| Chinese | zh |
ไธญๆ๏ผๆฎ้่ฏ๏ผ |
| Lingala | ln |
Lingala |
Language Selection Examples
// English (default)
LokotroPayCheckout(
language: LokotroPayLanguage.english,
// ... other parameters
)
// French
LokotroPayCheckout(
language: LokotroPayLanguage.french,
// ... other parameters
)
// Dynamic language selection
LokotroPayLanguage selectedLanguage = LokotroPayLanguage.fromCode('es') ?? LokotroPayLanguage.english;
LokotroPayCheckout(
language: selectedLanguage,
// ... other parameters
)
// Use device locale (default behavior when language is null)
LokotroPayCheckout(
language: null, // Will use device locale or fallback to English
// ... other parameters
)
Language Utilities
// Get all supported languages
List<LokotroPayLanguage> languages = LokotroPayLanguage.values;
// Get language from code
LokotroPayLanguage? language = LokotroPayLanguage.fromCode('fr');
// Get supported locales
List<Locale> locales = LokotroPayLanguage.supportedLocales;
// Get language details
Map<String, String> languageInfo = LokotroPayLanguage.french.toMap();
// Returns: {'code': 'fr', 'label': 'Franรงais', 'flag': 'assets/flags/france.svg'}
Response Handling #
Success Response
void handlePaymentResponse(LokotroPayOnResponse response) {
print('Payment Amount: ${response.amount}');
print('Currency: ${response.currency}');
print('Status: ${response.paymentStatus.displayName}');
print('Transaction ID: ${response.transactionId}');
print('System Reference: ${response.systemRef}');
print('Custom Reference: ${response.customRef}');
print('Timestamp: ${response.timestamp}');
}
Error Handling
void handlePaymentError(LokotroPayOnError error) {
print('Error Title: ${error.title}');
print('Error Message: ${error.message}');
print('Error Code: ${error.errorCode?.code}');
print('Timestamp: ${error.timestamp}');
// Show user-friendly error message
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text(error.message)),
);
}
๐จ Customization #
Theme Customization #
The plugin uses Lokotro's modern design system with glassmorphism effects. You can customize colors and styling:
LokotroPayCheckout(
title: 'Custom Payment',
titleStyle: TextStyle(
color: Colors.white,
fontSize: 20,
fontWeight: FontWeight.bold,
),
backgroundColor: LokotroPayColors.backgroundDark,
padding: EdgeInsets.all(20),
enableHapticFeedback: true,
// ... other properties
)
Available Colors #
The plugin provides a comprehensive color palette:
// Primary colors
LokotroPayColors.primary
LokotroPayColors.secondary
LokotroPayColors.accent
// Status colors
LokotroPayColors.success
LokotroPayColors.error
LokotroPayColors.warning
LokotroPayColors.info
// Background colors
LokotroPayColors.backgroundDark
LokotroPayColors.cardDark
LokotroPayColors.surfaceDark
// Text colors
LokotroPayColors.textPrimaryDark
LokotroPayColors.textSecondaryDark
๐ง Advanced Usage #
Environment Configuration #
Set up different environments for development and production:
// Development
await LokotroPayEnv.initialize(isProduction: false);
// Production
await LokotroPayEnv.initialize(isProduction: true);
Custom API Endpoints #
Override default API endpoints:
final configs = LokotroPayConfigs(
token: 'your_token',
customApiUrl: 'https://your-custom-api.com',
timeout: Duration(minutes: 2),
);
Utility Functions #
The plugin provides helpful utility functions:
// Format currency
String formatted = LokotroPayUtils.formatCurrency(100.50, 'USD');
// Validate card number
bool isValid = LokotroPayUtils.isValidCardNumber('4111111111111111');
// Validate email
bool isValidEmail = LokotroPayUtils.isValidEmail('user@example.com');
// Show snackbar with Lokotro styling
LokotroPayUtils.showSnackBar(
context,
'Payment successful!',
type: LokotroPayResultScreen.successScreen,
);
๐ ๏ธ Development #
Running the Example #
- Clone the repository
- Navigate to the example directory:
cd lokotro_pay/example - Install dependencies:
flutter pub get - Run the example:
flutter run
Testing #
Run tests for the plugin:
cd lokotro_pay
flutter test
๐ Requirements #
- Flutter SDK: >=3.3.0
- Dart SDK: ^3.8.1
- Android: API level 21+
- iOS: 12.0+
๐ค Contributing #
We welcome contributions! Please see our Contributing Guide for details.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
๐ License #
This project is licensed under the MIT License - see the LICENSE file for details.
๐ Support #
- ๐ง Email: support@lokotro.com
- ๐ Issues: GitHub Issues
- ๐ Documentation: Full Documentation
- ๐ฌ Community: Discord
๐ Acknowledgments #
- Built with โค๏ธ by the Lokotro team
- Inspired by modern payment experiences
- Special thanks to the Flutter community
Made with โค๏ธ for the Flutter community