Skip to content

Repository files navigation

MindPaystack Logo

MindPaystack

The Dart-First Paystack SDK

Built from the ground up for Dart and Flutter developers

Pub VersionDart SDK VersionFlutterLicense: MITVery Good Analysis


Pure Dart CoreType-SafeProduction-ReadyTransaction-Focused

Unlike generic API wrappers, MindPaystack is architected specifically for the Dart ecosystem

DocumentationQuick StartExamplesContributing

Why MindPaystack?

// Other SDKs: Dynamic types and unclear errorsfinal response =await http.post(url, body: data);
final result = json.decode(response.body); // Map<String, dynamic>// MindPaystack: Strongly typed, clean, and predictablefinal transaction =awaitMindPaystack.instance.transaction.initialize(
InitializeTransactionOptions(
email:'customer@example.com',
amount:Money.fromCents(50000, Currency.ngn), // Type-safe money handling
),
);
// Returns: Resource<TransactionInitialization>

Built for Modern Dart Development

FeatureMindPaystackGeneric HTTP Client
Type SafetyAvailable - Strongly typed responsesMissing - Dynamic Map<String, dynamic>
Error HandlingAvailable - Structured MindException hierarchyMissing - Generic HTTP errors
Dependency InjectionAvailable - Built-in Injectable supportMissing - Manual setup required
TestingAvailable - Mockable services & interfacesMissing - HTTP mocking complexity
Money/CurrencyAvailable - Dedicated value objectsMissing - Raw integers (error-prone)
Dart ConventionsAvailable - Follows Dart/Flutter patternsMissing - Generic API wrapper

Quick Start

Installation

For Pure Dart projects (CLI, server, backend):

dart pub add mind_paystack

For Flutter applications:

dart pub add mind_paystack
# Note: mind_paystack_flutter coming soon!

3-Step Integration

Step 1: Initialize the SDK

import'package:mind_paystack/mind_paystack.dart';
Future<void> main() async {
// 🔧 One-time setupawaitMindPaystack.initialize(
PaystackConfig(
publicKey:'pk_test_your_public_key',
secretKey:'sk_test_your_secret_key',
environment:Environment.test,
),
);
// 🚀 Ready to use!print('MindPaystack initialized successfully!');
}

Step 2: Create a Payment

final sdk =MindPaystack.instance;
try {
final transaction =await sdk.transaction.initialize(
InitializeTransactionOptions(
email:'customer@example.com',
amount:Money.fromCents(50000, Currency.ngn), // ₦500.00
metadata: {'product_id':'12345'},
),
);
// ✅ Type-safe access to all propertiesprint('Payment URL: ${transaction.data.authorizationUrl}');
print('Reference: ${transaction.data.reference}');
} onMindExceptioncatch (e) {
// 🛡️ Structured error handlingprint('Payment failed: ${e.message} (${e.code})');
}

Step 3: Verify Payment

final verification =await sdk.transaction.verify(
VerifyTransactionOptions(reference:'your-transaction-reference'),
);
if (verification.data.status =='success') {
print('💰 Payment successful!');
// Fulfill the order
} else {
print('❌ Payment failed or pending');
}

Examples

E-commerce Checkout
classCheckoutService {
staticFuture<String?> createPayment({
requiredString customerEmail,
requiredList<CartItem> items,
}) async {
final total = items.fold(0, (sum, item) => sum + item.price);
final sdk =MindPaystack.instance;
try {
final result =await sdk.transaction.initialize(
InitializeTransactionOptions(
email: customerEmail,
amount:Money.fromCents(total, Currency.ngn),
metadata: {
'order_items': items.map((e) => e.toJson()).toList(),
'customer_id':awaitgetUserId(),
},
),
);
return result.data.authorizationUrl;
} onMindExceptioncatch (e) {
_logger.error('Checkout failed', e);
returnnull;
}
}
}
Testing with Mocks
classMockTransactionServiceextendsMockimplementsITransactionService {}
voidmain() {
group('PaymentService Tests', () {
lateMockTransactionService mockTransaction;
latePaymentService paymentService;
setUp(() {
mockTransaction =MockTransactionService();
// Inject mock via dependency injectionGetIt.instance.registerSingleton<ITransactionService>(mockTransaction);
paymentService =PaymentService();
});
test('should create payment successfully', () async {
// Arrangewhen(() => mockTransaction.initialize(any()))
.thenAnswer((_) async=> mockTransactionResponse);
// Actfinal result =await paymentService.createPayment(testRequest);
// Assertexpect(result.isSuccess, true);
verify(() => mockTransaction.initialize(any())).called(1);
});
});
}

What Developers Love About MindPaystack

"Finally, a Paystack SDK that feels like it was built by Dart developers, for Dart developers."
— Flutter Developer

"The type safety and error handling saved us hours of debugging. No more dynamic nightmares!"
— Backend Developer

"Injectable integration made testing our payment flows so much cleaner."
— QA Engineer

Perfect For

Use CaseWhy MindPaystack Excels
E-commerce AppsType-safe money handling, structured error handling
Fintech PlatformsEnterprise-grade architecture, comprehensive testing
SaaS BillingTransaction management, webhook handling (coming soon)
Banking AppsSecurity-first design, audit trails
Mobile AppsFlutter-core support, with UI components coming soon

Package Ecosystem

PackagePlatformStatusFeatures
mind_paystackPure DartAvailableCore SDK, Transaction APIs
mind_paystack_flutterFlutterComing SoonUI widgets, platform integration

Platform Support

PlatformSupport LevelPackage Required
Flutter MobileCore Featuresmind_paystack
Flutter WebCore Featuresmind_paystack
Flutter DesktopCore Featuresmind_paystack
Dart VM (Server)Full Supportmind_paystack
Dart CLI ToolsFull Supportmind_paystack

Advanced Features

Dependency Injection Ready

@injectableclassPaymentService {
PaymentService(this._transactionService);
finalITransactionService _transactionService;
Future<PaymentResult> processPayment(PaymentRequest request) async {
// Fully testable and mockable
}
}

Type-Safe Money Handling

// Error-prone raw integersfinal amount =50000; // Is this ₦500 or ₦50,000?// Clear, type-safe money valuesfinal amount =Money.fromCents(50000, Currency.ngn); // Clearly ₦500.00final naira =Money.fromNaira(500.00); // Alternative constructor

Structured Error Handling

try {
final result =await sdk.transaction.initialize(request);
} onMindExceptioncatch (e) {
switch (e.category) {
caseErrorCategory.network:_handleNetworkError(e);
caseErrorCategory.validation:_showValidationErrors(e.validationErrors);
caseErrorCategory.paystack:_handlePaystackError(e);
}
}

🗺️ Roadmap

✅ Current Features (Available Now)

  • Transaction Management: Initialize, verify, list transactions
  • Type-Safe Money Handling: Structured money/currency objects
  • Error Handling: Comprehensive MindException system
  • Dependency Injection: Built-in Injectable support
  • Pure Dart Support: CLI tools, server applications, web

🚧 Coming Soon

  • Charge Operations: Direct card charging and tokenization
  • Payment Channels: Available payment methods management
  • Payment Methods: Customer payment method storage
  • Flutter Package: UI widgets and platform integration
  • Webhooks: Event handling and verification
  • Subscriptions: Recurring billing management

🔮 Future Releases

  • Advanced Analytics: Transaction insights and reporting
  • Multi-tenant Support: Organization-level configurations
  • Offline Capabilities: Queue transactions for later processing
  • Enhanced Security: Additional fraud prevention tools

Documentation

ResourceDescription
Full DocumentationComplete guides and API reference
Getting Started3-step integration guide
Architecture GuideUnderstanding the SDK design
Testing GuideMocking and unit testing
ConfigurationEnvironment setup and options

Contributing

We welcome and appreciate contributions from developers of all skill levels!

Our detailed contribution guide covers:

  • Quick Start - Get up and running in minutes
  • Project Structure - Understanding the monorepo architecture
  • Development Workflow - Step-by-step contribution process
  • Code Standards - Dart/Flutter style guidelines with examples
  • Testing Guidelines - TDD approach, mocking, and coverage requirements
  • Pull Request Process - Templates, checklists, and review process
  • Security Guidelines - Best practices for handling sensitive data
  • Development Tools - VS Code settings, Melos commands, Git hooks

Quick Links

I Want To...Action
Report a BugOpen an Issue
Request a FeatureRequest Feature
Ask QuestionsStart a Discussion
Contribute CodeSee Contributing Guide

Quick Development Setup

# 1. Fork and clone the repository
git clone https://github.com/Dartmind-OpenSource/mind-paystack.git
cd mind-paystack
# 2. Install Melos and bootstrap packages
dart pub global activate melos
melos bootstrap
# 3. Verify setup
melos run test&& melos run analyze
# You're ready to contribute!

New to open source? We're here to help! Check out issues labeled good first issue for beginner-friendly contributions.


📄 License

This project is licensed under the MIT License - see the LICENSE file for details.


Made with ❤️ by the Dart community

Star us on GitHubFollow us on TwitterJoin our Discord

Building the future of payments in Dart

About

MindPaystack is a Dart-First Paystack SDK that delivers a production-ready payment integration with clean architecture, type safety, and dependency injection out of the box.

Topics

Resources

Stars

27 stars

Watchers

3 watching

Forks

Releases

Packages

Used by

Contributors

Languages