securepay_api 0.0.2
securepay_api: ^0.0.2 copied to clipboard
A Flutter package for seamlessly integrating the SecurePay payment platform API. Supports key management, transfers, direct-debit, checkout, and more.
securepay_api #
(dart analyze) (dart pub publish --dry-run) (dart pub publish)
A Flutter package that wraps the SecurePay payment platform API, giving Flutter developers a clean, typed, and idiomatic Dart interface — no need to read the raw docs or wire up HTTP calls yourself.
Features #
- ✅ Full Dart type safety — every request and response is a named model class
- ✅ Dio-powered HTTP with automatic auth header injection
- ✅ UUID-based
X-Request-IDtracing on every request - ✅ Automatic retry with exponential back-off on transient errors
- ✅ Colour-coded request/response logging (staging only)
- ✅ Staging and production environment configs
- ✅ Meaningful
SecurePayExceptiontypes for easy error handling
Getting started #
Add to your pubspec.yaml:
dependencies:
securepay_api: ^0.0.2
Then run:
flutter pub get
Usage #
Initialise the client #
import 'package:securepay_api/securepay_api.dart';
// Staging (development)
final securePay = SecurePayApi(
apiKey: 'YOUR_API_KEY',
config: SecurePayConfig.staging(enableLogging: true),
);
// Production
final securePay = SecurePayApi(
apiKey: 'YOUR_API_KEY',
config: SecurePayConfig.production(),
);
Key Management — Generate a key #
try {
final response = await securePay.keyManagement.generateKey(
merchantEmail: jondoe@gmail.com,
);
if (response.success) {
final newKey = response.data["publicKey"];
print('Generated key: $newKey');
}
} on SecurePayException catch (e) {
print('SecurePay error: ${e.message} (HTTP ${e.statusCode})');
}
Error handling #
All API errors are thrown as SecurePayException:
try {
await securePay.keyManagement.generateKey(...);
} on SecurePayException catch (e) {
switch (e.errorCode) {
case 'UNAUTHORIZED':
// Handle invalid API key
case 'BAD_REQUEST':
// Handle validation errors
case 'SERVER_ERROR':
// Handle server-side failures
case 'NETWORK_ERROR':
// Handle no internet / timeout
}
}
Configuration options #
| Option | Type | Default | Description |
|---|---|---|---|
baseUrl |
String |
Staging URL | API base URL |
connectTimeout |
Duration |
30s | Connection timeout |
receiveTimeout |
Duration |
30s | Response timeout |
enableLogging |
bool |
false |
Log requests/responses |
enableRetry |
bool |
true |
Auto-retry on transient errors |
maxRetryAttempts |
int |
3 |
Max retry attempts |
API Coverage #
| Section | Status |
|---|---|
| Key Management and Bearer Token Generation | |
| Transfers | |
| Direct Debits | |
| Checkouts | |
| Payments | |
| Split Rules | |
| Sub Accounts | |
| Virtual Accounts |
License #
MIT