Deprecated - This documentation is for Flutter SDK v0.0.15, which is past end of life and is no longer supported. Versions
1.0.3and below are deprecated. For the latest version, see Flutter SDK v2.
The GlomoPay Flutter SDK provides a seamless, secure, and customizable payment checkout experience for your Flutter applications. Supports all Glomo payment flows (like 3DS auth or bank redirects), built-in security compliance checks, and error handling.
Before using this SDK, you need:
- API credentials (Public Key) from your GlomoPay dashboard
- Flutter >= 3.7.0
- Dart SDK >= 3.0.0
| Platform | Minimum Version |
|---|---|
| Android | API 21+ |
| iOS | 13.0+ |
| Flutter | 3.7.0+ |
| Dart | 3.0.0+ |
Add to your pubspec.yaml:
dependencies:
flutter:
sdk: flutter
glomopay_sdk: ^0.0.15Or run:
flutter pub add glomopay_sdkimport 'package:glomopay_sdk/glomopay_sdk.dart';Add the following to android/app/src/main/AndroidManifest.xml:
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Required for the checkout flow -->
<uses-permission android:name="android.permission.INTERNET"/>
<!-- Required if you need users to upload images/documents during checkout -->
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"
android:maxSdkVersion="32" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"
android:maxSdkVersion="29" />
</manifest>Add the following to ios/Runner/Info.plist:
<dict>
<key>NSCameraUsageDescription</key>
<string>This app requires access to the camera to upload documents required
for payment verification.</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>This app requires access to the photo library to select documents
for payment verification.</string>
</dict>Before starting the checkout flow, you need to create an order and obtain the Order ID (starts with order_).
import 'package:flutter/material.dart';
import 'package:glomopay_sdk/glomopay_sdk.dart';
class PaymentScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('Complete Payment')),
body: GlomoPayCheckout(
config: const GlomoPayConfig(
publicKey: 'test_pk_12345',
orderId: 'order_abc123',
),
onPaymentSuccess: (GlomoPayPayload payload) {
print('Payment succeeded! Payment ID: ${payload.paymentId}');
// Navigate to success screen
},
onPaymentFailure: (GlomoPayPayload payload) {
print('Payment failed with Order ID: ${payload.orderId}');
// Show error message
},
onSdkError: (List<SdkError> errors) {
print('SDK Error: ${errors.first.message}');
},
onConnectionError: (ConnectionError error) {
print('Connection error: ${error.message}');
},
onPaymentTerminate: (TerminationSource source) {
print('User cancelled checkout via $source');
Navigator.pop(context);
},
),
);
}
}- Glomo Payment Stack Support - Handles standard checkout flows and overlay redirects (3DS, bank pages) seamlessly.
- Robust Security - Built-in jailbreak and root detection to ensure transactions happen on secure devices.
- Error Monitoring - Built-in error tracking and diagnostics.
- Comprehensive Error Handling - Handles connection drops, DNS issues, HTTP errors, and validation errors gracefully.
- Native Support - Full support for Android and iOS native features like the camera and file pickers required by certain payment methods.
- Mock Mode - Easy testing with test keys (
test_...,mock_...).
| Prop | Type | Required | Description |
|---|---|---|---|
config | GlomoPayConfig | Yes | Configuration details for the checkout session |
onPaymentSuccess | Function(GlomoPayPayload) | Yes | Called when payment completes successfully |
onPaymentFailure | Function(GlomoPayPayload) | Yes | Called when the transaction declines or fails |
onSdkError | Function(List<SdkError>) | Yes | Called on SDK-level validation or configuration errors |
onConnectionError | Function(ConnectionError) | Yes | Called on internet drops, DNS failures, or HTTP errors |
onPaymentTerminate | Function(TerminationSource)? | No | Called when the user dismisses the modal or presses back |
autoCloseOnConnectionError | bool | No | Auto-close widget on connection error (default: true) |
| Property | Type | Default | Description |
|---|---|---|---|
publicKey | String | - | Your GlomoPay public key. If it starts with test_ or mock_, mock mode is enabled automatically |
orderId | String | - | The order ID for this transaction. Must start with order_ |
Returned via onPaymentSuccess and onPaymentFailure:
class GlomoPayPayload {
final String orderId; // The order ID (e.g., "order_abc123")
final String? paymentId; // The transaction reference, if generated
final String? signature; // Validation signature for backend verification
}The SDK provides validation and error reporting through the onSdkError callback:
class SdkError {
final SdkErrorType type; // validationError, deviceForbidden, networkError, or unknown
final String message; // Human-readable description of the error
final String? field; // Field name that caused the error (e.g., "orderId")
}Error Types:
validationError- Input validation failed (invalidpublicKeyororderId)deviceForbidden- Device does not meet compliance requirements (rooted or jailbroken devices are not permitted)networkError- A network-level error occurred before reaching the checkoutunknown- An unclassified error
class ConnectionError {
final ConnectionErrorType type; // noInternet, timeout, dnsFailure, sslError, etc.
final String message; // Error description or HTTP status phrase
final int? errorCode; // Internal WebKit/Android error code
final int? statusCode; // HTTP status code, if applicable
final bool isRecoverable; // Whether it is safe to offer a retry option
}Connection Error Types:
noInternet- No internet connectivitytimeout- Request timed outdnsFailure- DNS resolution failedsslError- SSL/TLS certificate errorhttpClientError- HTTP 4xx errorhttpServerError- HTTP 5xx errorwebResourceError- WebView resource loading errorunknown- Unclassified connection error
Indicates how the user exited the checkout:
userDismiss- User swiped down or tapped a close buttonbackButton- User pressed the Android back button
The SDK tracks the checkout lifecycle through the following states:
| Status | Description |
|---|---|
validating | Input keys and device compliance are being checked |
ready | Validation passed; loading the checkout UI |
paymentInProgress | User is actively completing the payment |
paymentSuccessful | Payment completed successfully |
paymentFailed | Payment was declined or failed |
paymentCancelled | User dismissed or cancelled the checkout |
- Checkout appears inside a modal
- Users can dismiss by swiping down, which triggers
onPaymentTerminatewithTerminationSource.userDismiss - The SDK intercepts iOS swipe gestures to ensure the termination callback fires correctly
- Checkout appears in full-screen mode
- Pressing the hardware back button triggers
onPaymentTerminatewithTerminationSource.backButton - The SDK checks if the overlay WebView (e.g., 3DS bank page) can go back before closing the checkout entirely
Mock mode is automatically enabled based on your publicKey:
- If
publicKeystarts withtest_ormock_(case-insensitive), mock mode is enabled - Otherwise, live mode is used
In mock mode:
- Connection heuristics allow mock traffic
- You can simulate transactions without real money movement
// Mock mode
GlomoPayConfig(
publicKey: 'test_pk_12345',
orderId: 'order_abc123',
)
// Live mode
GlomoPayConfig(
publicKey: 'live_pk_xyz789',
orderId: 'order_abc123',
)Ensure orderId starts with "order_" and meets the minimum length requirement.
Verify config.publicKey is set correctly and starts with the expected prefix (live_ for production or test_ for mock mode).
Run flutter clean and ensure Camera and Storage permissions are granted in AndroidManifest.xml and Info.plist.
Rooted or jailbroken devices trigger onSdkError with a deviceForbidden error. Use an emulator or a non-rooted/jailbroken device for testing.
The SDK enforces several security measures:
- Device integrity checks - Root/jailbreak detection runs before loading the checkout. Compromised devices receive a
deviceForbiddenerror viaonSdkError. - Secure WebView - JavaScript is sandboxed within the WebView. The SDK validates all bridge messages before processing.
The SDK exports all types from a single entry point:
import 'package:glomopay_sdk/glomopay_sdk.dart';This gives you access to:
GlomoPayCheckout- The checkout widgetGlomoPayConfig- Configuration classGlomoPayPayload- Payment result payloadSdkError/SdkErrorType- SDK error typesConnectionError/ConnectionErrorType- Connection error typesTerminationSource- Checkout termination source enumLrsCheckoutStatus- Checkout lifecycle status enum