Skip to content

GlomoPay Flutter SDK v0.0.15

Deprecated - This documentation is for Flutter SDK v0.0.15, which is past end of life and is no longer supported. Versions 1.0.3 and 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.

Prerequisites

Before using this SDK, you need:

  • API credentials (Public Key) from your GlomoPay dashboard
  • Flutter >= 3.7.0
  • Dart SDK >= 3.0.0

System Requirements

PlatformMinimum Version
AndroidAPI 21+
iOS13.0+
Flutter3.7.0+
Dart3.0.0+

Installation

1. Add Dependency

Add to your pubspec.yaml:

dependencies:
  flutter:
    sdk: flutter
  glomopay_sdk: ^0.0.15

Or run:

flutter pub add glomopay_sdk

2. Import

import 'package:glomopay_sdk/glomopay_sdk.dart';

Platform Setup

Android Permissions

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>

iOS Permissions

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>

Quick Start

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

Features

  • 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_...).

API Reference

GlomoPayCheckout Widget

Props

PropTypeRequiredDescription
configGlomoPayConfigYesConfiguration details for the checkout session
onPaymentSuccessFunction(GlomoPayPayload)YesCalled when payment completes successfully
onPaymentFailureFunction(GlomoPayPayload)YesCalled when the transaction declines or fails
onSdkErrorFunction(List<SdkError>)YesCalled on SDK-level validation or configuration errors
onConnectionErrorFunction(ConnectionError)YesCalled on internet drops, DNS failures, or HTTP errors
onPaymentTerminateFunction(TerminationSource)?NoCalled when the user dismisses the modal or presses back
autoCloseOnConnectionErrorboolNoAuto-close widget on connection error (default: true)

GlomoPayConfig

PropertyTypeDefaultDescription
publicKeyString-Your GlomoPay public key. If it starts with test_ or mock_, mock mode is enabled automatically
orderIdString-The order ID for this transaction. Must start with order_

GlomoPayPayload

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
}

SdkError

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 (invalid publicKey or orderId)
  • deviceForbidden - Device does not meet compliance requirements (rooted or jailbroken devices are not permitted)
  • networkError - A network-level error occurred before reaching the checkout
  • unknown - An unclassified error

ConnectionError

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 connectivity
  • timeout - Request timed out
  • dnsFailure - DNS resolution failed
  • sslError - SSL/TLS certificate error
  • httpClientError - HTTP 4xx error
  • httpServerError - HTTP 5xx error
  • webResourceError - WebView resource loading error
  • unknown - Unclassified connection error

TerminationSource

Indicates how the user exited the checkout:

  • userDismiss - User swiped down or tapped a close button
  • backButton - User pressed the Android back button

Checkout Status

The SDK tracks the checkout lifecycle through the following states:

StatusDescription
validatingInput keys and device compliance are being checked
readyValidation passed; loading the checkout UI
paymentInProgressUser is actively completing the payment
paymentSuccessfulPayment completed successfully
paymentFailedPayment was declined or failed
paymentCancelledUser dismissed or cancelled the checkout

Platform-Specific Behavior

iOS

  • Checkout appears inside a modal
  • Users can dismiss by swiping down, which triggers onPaymentTerminate with TerminationSource.userDismiss
  • The SDK intercepts iOS swipe gestures to ensure the termination callback fires correctly

Android

  • Checkout appears in full-screen mode
  • Pressing the hardware back button triggers onPaymentTerminate with TerminationSource.backButton
  • The SDK checks if the overlay WebView (e.g., 3DS bank page) can go back before closing the checkout entirely

Mock Mode

Mock mode is automatically enabled based on your publicKey:

  • If publicKey starts with test_ or mock_ (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',
)

Troubleshooting

Invalid Order ID format

Ensure orderId starts with "order_" and meets the minimum length requirement.

SDK errors on launch

Verify config.publicKey is set correctly and starts with the expected prefix (live_ for production or test_ for mock mode).

File upload buttons not working

Run flutter clean and ensure Camera and Storage permissions are granted in AndroidManifest.xml and Info.plist.

Device Forbidden error

Rooted or jailbroken devices trigger onSdkError with a deviceForbidden error. Use an emulator or a non-rooted/jailbroken device for testing.

Security

The SDK enforces several security measures:

  • Device integrity checks - Root/jailbreak detection runs before loading the checkout. Compromised devices receive a deviceForbidden error via onSdkError.
  • Secure WebView - JavaScript is sandboxed within the WebView. The SDK validates all bridge messages before processing.

Exports

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 widget
  • GlomoPayConfig - Configuration class
  • GlomoPayPayload - Payment result payload
  • SdkError / SdkErrorType - SDK error types
  • ConnectionError / ConnectionErrorType - Connection error types
  • TerminationSource - Checkout termination source enum
  • LrsCheckoutStatus - Checkout lifecycle status enum