Skip to content

GlomoPay Flutter SDK v0.0.13

Deprecated - This documentation is for Flutter SDK v0.0.13, 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

  • A GlomoPay account with API keys (public key starting with live_ or test_)
  • An order ID generated from your server via the GlomoPay API

System Requirements

  • Flutter 3.0 or higher
  • Dart 2.17 or higher
  • Android: minSdkVersion 21 or higher
  • iOS: iOS 13.0 or higher

Installation

Add the glomopay_sdk to your pubspec.yaml dependencies:

dependencies:
  flutter:
    sdk: flutter
  glomopay_sdk: ^0.0.13

Then run:

flutter pub get

Import it in your Dart code:

import 'package:glomopay_sdk/glomopay_sdk.dart';

Platform Setup

Android

Add the required permissions in your 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

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

<dict>
    <!-- Required for camera/file uploads during the checkout process -->
    <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

Import the library and display the GlomoPayCheckout widget:

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

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

/**

  • The main checkout widget. Embed it in your widget tree
  • to present the GlomoPay payment UI. */
PropTypeRequiredDescription
configGlomoPayConfigYesThe configuration details for the checkout session.
onPaymentSuccessFunction(GlomoPayPayload)YesCalled when the payment is completed successfully.
onPaymentFailureFunction(GlomoPayPayload)YesCalled when the transaction gets declined or fails.
onSdkErrorFunction(List<SdkError>)YesCalled when an SDK-level error occurs (e.g., validation, or forbidden device).
onConnectionErrorFunction(ConnectionError)YesCalled if there is an internet drop, DNS failure, or severe HTTP error.
onPaymentTerminateFunction(TerminationSource)?NoCalled if the user dismisses the modal or hits back.
autoCloseOnConnectionErrorboolNoWhether the widget should automatically call onPaymentTerminate upon encountering a critical connection error. Defaults to true.

GlomoPayConfig

/**

  • Configuration object passed to GlomoPayCheckout.
  • Contains keys, order info, and environment settings. */
PropertyTypeDefaultDescription
publicKeyString-Your GlomoPay public key (e.g., live_..., test_...).
orderIdString-The unique tracking ID generated for this transaction on your server.

GlomoPayPayload

/**

  • Returned via onPaymentSuccess and onPaymentFailure callbacks.
  • Contains the order reference and optional verification data. */
PropertyTypeDescription
orderIdStringThe system ID of the order.
paymentIdString?The transaction reference, if generated.
signatureString?The validation signature hash for backend verification.

SdkError

/**

  • Represents an SDK-level error such as validation failure
  • or a forbidden device condition. */
PropertyTypeDescription
typeSdkErrorTypeOne of: validationError, deviceForbidden, networkError, unknown.
messageStringA human-readable description of the constraint that failed.
fieldString?The field name (e.g., "orderId") that caused the validationError.

ConnectionError

/**

  • Represents a network or connectivity error encountered
  • during the checkout flow. */
PropertyTypeDescription
typeConnectionErrorTypeOne of: noInternet, timeout, dnsFailure, sslError, httpClientError, httpServerError, webResourceError, unknown.
messageStringExtracted error description or HTTP status phrase.
errorCodeint?The internal WebKit/Android error code.
statusCodeint?HTTP status code, if applicable.
isRecoverableboolSuggests if it is safe to offer a "Retry" button.

TerminationSource

/**

  • Indicates how the user exited the checkout flow
  • before completing payment. */
ValueDescription
userDismissThe user swiped down or tapped a close button to dismiss the checkout.
backButtonThe user pressed the Android back button to exit the checkout.

Checkout Status

/**

  • Internal lifecycle states of the checkout session.
  • Observable via the checkout lifecycle. */
StatusDescription
validatingInput keys and devices are securely checked.
readyVerified; loading the UI.
paymentInProgressThe user is currently entering card details or authorizing.
paymentSuccessfulPayment cleared.
paymentFailedProcessing declined.
paymentCancelledThe user exited before completing.

Platform-Specific Behavior

  • iOS Swiping - The SDK intercepts iOS downward swipe gestures to dismiss the payment sheet and triggers onPaymentTerminate with TerminationSource.userDismiss.
  • Android Back Button - Automatically overrides standard pop. First checks if the Flow WebView overlay (e.g., 3DS bank page) can go back. Does so accordingly until the modal is closed, returning TerminationSource.backButton.

Mock Mode

Using a public key that starts with test_ or mock_ shifts the SDK into mock mode.

In this mode:

  • Connection heuristics allow mock traffic.
  • You can simulate fake transactions without real money movement.

Troubleshooting

  • Invalid Order ID format - Ensure orderId starts with "order_" and has appropriate length.
  • SDK crashes immediately on open - Ensure config.publicKey is correctly set and starts with the expected prefix (test_ or live_).
  • File upload buttons do nothing - Run flutter clean and ensure Camera/Storage permissions were explicitly granted in the native AndroidManifest and Info.plist layers.
  • Device Forbidden (Error) - A root/jailbroken device will immediately trigger onSdkError. Test within your emulator.

Security

  • The SDK performs jailbreak/root detection at startup. Compromised devices trigger onSdkError with SdkErrorType.deviceForbidden.
  • All checkout traffic is served over HTTPS. SSL errors are surfaced via onConnectionError.
  • Public keys are validated before any network request is made.
  • Payment credentials never pass through your application code - they are handled entirely within the secure WebView.

Exports

The SDK exports the following from package:glomopay_sdk/glomopay_sdk.dart:

  • GlomoPayCheckout - The main checkout widget.
  • GlomoPayConfig - Configuration model.
  • GlomoPayPayload - Payment result payload.
  • SdkError / SdkErrorType - SDK error model and type enum.
  • ConnectionError / ConnectionErrorType - Connection error model and type enum.
  • TerminationSource - Enum for checkout exit source.