sofizpay_sdk_dart 1.0.5
sofizpay_sdk_dart: ^1.0.5 copied to clipboard
A powerful Dart SDK for Stellar blockchain DZT token payments with real-time transaction monitoring and comprehensive payment management.
SofizPay SDK for Dart #
π Table of Contents #
- Overview
- Features
- Installation
- Quick Start
- API Reference
- Usage Examples
- Real-time Transaction Monitoring
- Error Handling
- Best Practices
- Contributing
- Support
- License
π Overview #
SofizPay SDK is a powerful Dart library for Stellar blockchain DZT token payments with real-time transaction monitoring and comprehensive payment management.
Key Benefits:
- π Secure Stellar blockchain integration
- β‘ Real-time transaction monitoring
- π― Simple, intuitive API
- π± Cross-platform support
β¨ Features #
- β Send DZT Payments: Secure token transfers with memo support
- β Transaction History: Retrieve and filter transaction records
- β Balance Checking: Real-time DZT balance queries
- β Transaction Search: Find transactions by memo or hash
- β Real-time Streams: Live transaction monitoring with callbacks
- β Error Handling: Robust error management and reporting
π¦ Installation #
Add SofizPay SDK to your pubspec.yaml
:
dependencies:
sofizpay_sdk_dart: ^1.0.5
Then run:
dart pub get
For Flutter projects:
flutter pub get
π Quick Start #
1. Import the SDK #
import 'package:sofizpay_sdk_dart/sofizpay_sdk_dart.dart';
2. Initialize the SDK #
final sofizPay = SofizPaySDK();
3. Your First Payment #
// Send a DZT payment
final result = await sofizPay.submit(
secretkey: 'YOUR_SECRET_KEY',
destinationPublicKey: 'DESTINATION_PUBLIC_KEY',
amount: 10.0,
memo: 'Payment for services',
);
if (result.success) {
print('Payment successful! TX: ${result.transactionHash}');
} else {
print('Payment failed: ${result.error}');
}
π API Reference #
submit()
- Send Payment #
final result = await sofizPay.submit(
secretkey: 'YOUR_SECRET_KEY',
destinationPublicKey: 'DESTINATION_PUBLIC_KEY',
amount: 10.0,
memo: 'Payment memo',
);
getDZTBalance()
- Check Balance #
final result = await sofizPay.getDZTBalance(secretkey);
print('Balance: ${result.data!['balance']} DZT');
getTransactions()
- Transaction History #
final result = await sofizPay.getTransactions(secretkey, limit: 50);
startTransactionStream()
- Real-time Monitoring #
await sofizPay.startTransactionStream(secretkey, (transaction) {
print('New ${transaction['type']}: ${transaction['amount']} DZT');
});
Other Methods #
getPublicKey()
- Extract public key from secret keysearchTransactionsByMemo()
- Search transactions by memogetTransactionByHash()
- Get transaction by hash
π Real-time Transaction Monitoring #
// Start monitoring
await sofizPay.startTransactionStream(secretkey, (transaction) {
print('New ${transaction['type']}: ${transaction['amount']} DZT');
if (transaction['type'] == 'received') {
handleIncomingPayment(transaction);
}
});
// Check status
final status = await sofizPay.getStreamStatus(secretkey);
// Stop monitoring
await sofizPay.stopTransactionStream(secretkey);
π‘ Usage Examples #
Complete Payment Flow #
import 'package:sofizpay_sdk_dart/sofizpay_sdk_dart.dart';
void main() async {
final sofizPay = SofizPaySDK();
const secretKey = 'YOUR_SECRET_KEY';
try {
// Check balance
final balanceResult = await sofizPay.getDZTBalance(secretKey);
final balance = balanceResult.data!['balance'];
print('Balance: $balance DZT');
// Send payment
if (balance >= 10.0) {
final result = await sofizPay.submit(
secretkey: secretKey,
destinationPublicKey: 'DESTINATION_PUBLIC_KEY',
amount: 10.0,
memo: 'Service payment',
);
if (result.success) {
print('Payment successful: ${result.transactionHash}');
}
}
} finally {
sofizPay.dispose();
}
}
Payment Monitoring System #
class PaymentMonitor {
final SofizPaySDK _sdk = SofizPaySDK();
Future<void> startMonitoring(String secretKey) async {
await _sdk.startTransactionStream(secretKey, (transaction) {
if (transaction['type'] == 'received') {
print('π° Payment received: ${transaction['amount']} DZT');
print('From: ${transaction['from']}');
// Process payment...
}
});
}
void dispose() => _sdk.dispose();
}
β οΈ Error Handling #
All methods return structured response objects:
final result = await sofizPay.submit(/* parameters */);
if (result.success) {
print('Success: ${result.transactionHash}');
} else {
print('Error: ${result.error}');
}
Common errors:
'Secret key is required.'
'Valid amount is required.'
'Destination public key is required.'
π Best Practices #
// β
Store secret keys securely (use secure storage in production)
// β
Always check result.success before accessing data
// β
Dispose SDK instances when done: sofizPay.dispose()
// β
Validate inputs before API calls
// β
Use appropriate transaction limits for better performance
π€ Contributing #
- Fork the repository
- Create feature branch:
git checkout -b feature/amazing-feature
- Commit changes:
git commit -m 'Add amazing feature'
- Push to branch:
git push origin feature/amazing-feature
- Open a Pull Request
# Development setup
git clone https://github.com/kenandarabeh/sofizpay-sdk-dart.git
cd sofizpay-sdk-dart
dart pub get
dart test
π Support #
- π Documentation
- Report Issues
- οΏ½ Discussions
- β Star the Project
π License #
This project is licensed under the MIT License - see the LICENSE file for details.
π Acknowledgments #
- Built on the robust Stellar Network
- Powered by stellar_flutter_sdk
- Inspired by the growing DeFi ecosystem
Made by the SofizPay Team
GitHub β’ pub.flutter-io.cn β’ Support