Deprecated - This documentation is for Flutter SDK v0.0.3, 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 |
|---|---|
| Flutter | >= 3.7.0 |
| Dart SDK | >= 3.0.0 |
| Android | API 21+ |
| iOS | 13.0+ |
Add to your pubspec.yaml:
dependencies:
flutter:
sdk: flutter
glomopay_sdk: ^0.0.3Or 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, 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}');
},
onPaymentFailure: (GlomoPayPayload payload) {
print('Payment failed with Order ID: ${payload.orderId}');
},
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.
- Security Compliance - Built-in jailbreak and root detection to ensure transactions happen on secure devices.
- Error Monitoring - Built-in error tracking and diagnostics.
- Error Handling - Handles connection drops, DNS issues, HTTP errors, and validation errors.
- Native Support - Full support for Android and iOS native features like the camera and file pickers.
- 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. Starts with live_ (production) or test_/mock_ (mock mode) |
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
}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 occurredunknown- 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
Passed to onPaymentTerminate to indicate how the user exited:
userDismiss- User swiped down to dismiss (iOS)backButton- User pressed the hardware back button (Android)
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
- Checkout appears in full-screen mode
- Pressing the hardware back button triggers
onPaymentTerminatewithTerminationSource.backButton - The SDK intercepts back navigation and checks if the overlay WebView (e.g., 3DS bank page) can go back before closing
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 example
* Use test_ or mock_ prefix for non-production testing
*/
GlomoPayConfig(
publicKey: 'test_pk_12345',
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.
- Device Compliance - The SDK checks for jailbroken (iOS) or rooted (Android) devices and blocks checkout on non-compliant devices via
onSdkErrorwithdeviceForbidden. - Transport Security - All communication uses HTTPS. SSL errors are reported through
onConnectionError. - Signature Verification - The
signaturefield inGlomoPayPayloadshould be verified server-side to confirm payment authenticity.
The SDK exports the following from package:glomopay_sdk/glomopay_sdk.dart:
GlomoPayCheckout- The checkout widgetGlomoPayConfig- Configuration classGlomoPayPayload- Payment result payloadSdkError/SdkErrorType- Error model and enumConnectionError/ConnectionErrorType- Connection error model and enumTerminationSource- Enum for how the user exited checkoutLrsCheckoutStatus- Checkout lifecycle states