Skip to content

GlomoPay Flutter SDK v1 (Archived)

Archived - This documentation is for Flutter SDK v1.x, frozen at the final v1 release, v1.11.2. v1 is no longer the latest version. For the latest version, see Flutter SDK v2. To upgrade, see the Migration Guide.

Official Flutter SDK for integrating GlomoPay payment checkout flows into your mobile applications.

Full Changelog is also available.

Prerequisites

Before using this SDK, you need:

  • API credentials (Public Key) from your GlomoPay dashboard
  • An order ID created via the GlomoPay API (or a subscription ID for subscription payments)

System Requirements

RequirementVersion
Flutter>= 3.7.0
Dart SDK>= 3.0.0

Installation

Add the dependency to your pubspec.yaml:

dependencies:
  flutter:
    sdk: flutter
  glomopay_sdk: ^1.11.2

Or install via the CLI:

flutter pub add glomopay_sdk

Then import the package:

import 'package:glomopay_sdk/glomopay_sdk.dart';

Platform Setup

Android

Add the following permissions to android/app/src/main/AndroidManifest.xml:

<uses-permission android:name="android.permission.INTERNET"/>
<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" />

iOS

Add the following keys to ios/Runner/Info.plist:

<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>

Quick Start

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);
        },
      ),
    );
  }
}

Subscriptions Checkout

To process subscription payments, pass a subscriptionId instead of an orderId in GlomoPayConfig:

GlomoPayCheckout(
  config: const GlomoPayConfig(
    publicKey: 'live_pk_abc123',
    subscriptionId: 'sub_xyz789',
  ),
  onPaymentSuccess: (GlomoPayPayload payload) {
    print('Subscription payment success: ${payload.paymentId}');
  },
  onPaymentFailure: (GlomoPayPayload payload) {
    print('Subscription payment failed: ${payload.orderId}');
  },
  onSdkError: (List<SdkError> errors) {
    errors.forEach((e) => print('${e.type}: ${e.message}'));
  },
  onConnectionError: (ConnectionError error) {
    print('Connection error: ${error.message}');
  },
)

When subscriptionId is provided:

  • The SDK skips order detection API calls
  • The subscriptionId must start with sub_
  • LRS-specific UI elements and flow logic are not applied
  • Do not pass both orderId and subscriptionId - the SDK will fire onSdkError
  • Existing order-based integrations remain backward compatible

Features

  • Glomo Payment Stack Support - handles standard checkout flows and overlay redirects (3DS, bank pages)
  • Robust Security - built-in jailbreak and root detection
  • Error Monitoring - built-in error tracking and diagnostics
  • Comprehensive Error Handling - gracefully manages connection drops, DNS issues, HTTP errors, validation mistakes
  • Native Support - full Android/iOS native features (camera, file pickers)
  • Mock Mode - easy testing with test_ and mock_ prefixed keys

API Reference

GlomoPayCheckout Widget

The checkout widget. Place it in your widget tree to render the payment checkout.

GlomoPayCheckout(
  config: config,
  onPaymentSuccess: ...,
  onPaymentFailure: ...,
  onSdkError: ...,
  onConnectionError: ...,
)

Props

PropTypeRequiredDescription
configGlomoPayConfigYesConfiguration details for the checkout session
onPaymentSuccessFunction(GlomoPayPayload)YesCalled when payment completes successfully
onPaymentFailureFunction(GlomoPayPayload)YesCalled when transaction declines or fails
onSdkErrorFunction(List<SdkError>)YesCalled on SDK-level errors (validation, forbidden device)
onConnectionErrorFunction(ConnectionError)YesCalled on internet drop, DNS failure, HTTP error
onPaymentTerminateFunction(TerminationSource)?NoCalled if user dismisses modal or hits back
onUserRefusedDevicePermissionsFunction()?NoCalled when user denies camera/storage permissions during file/document uploads or selfie verification requests
autoCloseOnConnectionErrorboolNoAuto-call onPaymentTerminate on critical connection error. Default: true

GlomoPayConfig

PropertyTypeDefaultDescription
publicKeyString-Your GlomoPay public key (must start with live_, mock_, or test_)
orderIdString-Unique tracking ID generated for transaction on server
subscriptionIdString-Subscription checkout ID; use instead of orderId for subscriptions
serverString?nullCustom LRS checkout URL; leave unset to use the official environment URL

Exactly one of orderId or subscriptionId must be provided. If both or neither are set, onSdkError fires.

GlomoPayPayload

class GlomoPayPayload {
  final String orderId;       // System ID of the order
  final String? paymentId;    // Transaction reference, if generated
  final String? signature;    // Validation signature hash for backend verification
  final Map<String, dynamic>? rawResponse; // Page message exactly as it arrived
}

SdkError

class SdkError {
  final SdkErrorType type;   // Error category
  final String message;       // Human-readable description
  final String? field;        // Field name (e.g. "orderId") causing validationError
}

SdkErrorType

ValueDescription
validationErrorInput validation failed
deviceForbiddenRooted or jailbroken device detected
networkErrorNetwork-level error
unknownUncategorized error

ConnectionError

class ConnectionError {
  final ConnectionErrorType type;  // Error category
  final String message;            // Extracted 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;        // Suggests if safe to offer a "Retry" button
}

ConnectionErrorType

ValueDescription
noInternetDevice is offline
timeoutRequest timed out
dnsFailureDNS resolution failed
sslErrorSSL/TLS handshake error
httpClientErrorHTTP 4xx response
httpServerErrorHTTP 5xx response
webResourceErrorWebView resource loading error
unknownUncategorized connection error

Use isRecoverable to decide whether to show a "Retry" button to the user.

TerminationSource

ValueDescription
userDismissUser swiped down to dismiss the payment sheet
backButtonUser pressed the hardware/software back button
programmaticThe checkout was closed programmatically
connectionErrorA connection error closed the checkout

Checkout Status

CheckoutStatus represents the current state of the checkout flow.

StatusDescription
validatingInput keys and devices securely checked
readyVerified; loading UI
paymentInProgressUser typing card details or authorizing
paymentSuccessfulPayment clear
paymentFailedProcessing declined
paymentCancelledUser bounced

Platform-Specific Behavior

  • iOS: SDK intercepts downward swipes to dismiss the payment sheet and triggers onPaymentTerminate with TerminationSource.userDismiss.
  • Android: Overrides standard pop; checks if the Flow WebView overlay can go back. Returns TerminationSource.backButton until the modal is closed.

Mock Mode

The SDK infers mock mode from the publicKey prefix:

PrefixModeEnvironment
live_LiveProduction
test_MockTest/sandbox
mock_MockTest/sandbox

Mock mode keys route to the sandbox backend. No real transactions are created.

  • Connection heuristics allow mock traffic
  • Simulate fake transactions without real money movement

Troubleshooting

Invalid Order ID format

Ensure orderId starts with order_ and has appropriate length.

Invalid Subscription ID format

Ensure subscriptionId starts with sub_ and has appropriate length.

Mutually exclusive identifiers

Provide either orderId or subscriptionId, not both. The SDK fires onSdkError if both are set.

SDK crashes immediately on open

Ensure config.publicKey is correctly set with an expected prefix (live_, mock_, or test_).

File upload buttons do nothing

Run flutter clean and rebuild. Ensure Camera and Storage permissions are explicitly granted in the platform config.

Device Forbidden Error

Rooted or jailbroken devices trigger onSdkError with SdkErrorType.deviceForbidden unless testing in an emulator.

Security

The SDK loads checkout pages in an isolated WebView. No PAN, CVV, or sensitive payment data passes through the Flutter bridge - all sensitive input is handled within the WebView's sandboxed context.

Built-in jailbreak and root detection prevents checkout on compromised devices.

To report a security vulnerability, email security@glomopay.com. Do not open a public GitHub issue for security reports.

Exports

/**
 * All public exports from package:glomopay_sdk/glomopay_sdk.dart
 */

// Widget
GlomoPayCheckout

// Controller
GlomoPayController

// Configuration
GlomoPayConfig

// Payload
GlomoPayPayload

// Errors
SdkError
SdkErrorType
ConnectionError
ConnectionErrorType

// Enums
TerminationSource
CheckoutStatus