Flutter

Overview

The Geidea Flutter Payment SDK delivers a seamless and secure payment experience for cross-platform Flutter applications. Designed for flexibility and ease of integration, the SDK enables developers to add payment functionality with minimal code while supporting rich UI customization and multiple presentation styles.


Key Features

Dynamic Payment Methods
Flexible UI & Presentation Options
Native 3D Secure Authentication
Fast Card Scanning
Security & Compliance
Optimized Performance
Multi-language & Localization Support
Smart Error Handling

How It Works

  1. Initialize the Geidea Flutter SDK in your application.
  2. The SDK retrieves and displays available payment methods.
  3. Customer payment details are securely collected.
  4. The SDK processes the payment via Geidea’s payment gateway.
  5. The payment result is returned to the Flutter application and displayed to the user.

Getting Started

Prerequisites

RequirementMinimum Version
Flutter SDK3.0.0+
Dart2.17.0+
iOS Deployment TargetiOS 15.0+
Android Min SDKAPI 23 (Android 6.0)

Installation

Add the Geidea Payment SDK to your Flutter project by updating pubspec.yaml:

dependencies:
  gd_payment_sdk:
    path: ../

Then run:

flutter pub get

Platform-Specific Setup

iOS Setup

Ensure the minimum deployment target in ios/Podfile:

platform :ios, '15.0'

Android Setup

Ensure the minimum SDK version in android/app/build.gradle:

android {
    defaultConfig {
        minSdkVersion 23
    }
}

Integration Guide

Step 1: Create a Payment Session (Server-Side)

Before launching the SDK, create a payment session using Geidea APIs. The generated session.id will be required to initialize the SDK on the client side.

Refer to the Geidea API Documentation for full details.


Step 2: SDK Configuration (Client-Side)

Import the SDK

import 'package:gd_payment_sdk/gd_payment_sdk.dart';

Initialize and Start the SDK

class PaymentScreen extends StatefulWidget {
  @override
  _PaymentScreenState createState() => _PaymentScreenState();
}

class _PaymentScreenState extends State<PaymentScreen> {
  final GDPaymentSDK _sdk = GDPaymentSDK.sharedInstance();
  bool _isProcessing = false;

  Future<void> _startPayment() async {
    setState(() {
      _isProcessing = true;
    });

    final configuration = GDPaymentSDKConfiguration(
      sessionId: 'your_session_id',
      region: Region.egy,
      isSandbox: true,
      language: SDKLanguage.english,
      theme: SDKTheme(
        style: ThemeStyle.light,
        primaryColor: '#667eea',
        secondaryColor: '#764ba2',
      ),
    );

    try {
      final response = await _sdk.start(
        configuration: configuration,
        presentationStyle: const PushStyle(),
      );

      setState(() {
        _isProcessing = false;
      });

      if (!mounted) return;

      switch (response.status) {
        case PaymentStatus.success:
          _handlePaymentSuccess(response.result!);
          break;
        case PaymentStatus.failure:
          _handlePaymentFailure(response.error!);
          break;
        case PaymentStatus.canceled:
          _handlePaymentCanceled();
          break;
      }
    } catch (e) {
      setState(() {
        _isProcessing = false;
      });
    }
  }

  void _handlePaymentSuccess(GDPaymentResult result) {}
  void _handlePaymentFailure(GDPaymentError error) {}
  void _handlePaymentCanceled() {}

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text('Payment')),
      body: Center(
        child: _isProcessing
            ? const CircularProgressIndicator()
            : ElevatedButton(
                onPressed: _startPayment,
                child: const Text('Start Payment'),
              ),
      ),
    );
  }
}

Theme Customization

Customize the SDK appearance to match your brand identity:

final customTheme = SDKTheme(
  style: ThemeStyle.dark,
  primaryColor: '#FF6B35',
  secondaryColor: '#F7F7F7',
);

final configuration = GDPaymentSDKConfiguration(
  sessionId: 'your_session_id',
  theme: customTheme,
  language: SDKLanguage.english,
  region: Region.egy,
  isSandbox: true,
);

Theme Properties

  • style: ThemeStyle.light or ThemeStyle.dark
  • primaryColor: Hex color string (e.g. #667eea)
  • secondaryColor: Hex color string (e.g. #764ba2)
  • merchantLogoPath: Asset or file path for merchant logo

Payment Testing (Sandbox)

Use the following test card details in sandbox mode:

Successful Payment

  • Card Number: 4111 1111 1111 1111
  • CVV: 123
  • Expiry Date: Any future date (e.g. 12/27)
  • Cardholder Name: Any name

API Reference

GDPaymentSDK

class GDPaymentSDK {
  static GDPaymentSDK sharedInstance();

  Future<PaymentResponse> start({
    required GDPaymentSDKConfiguration configuration,
    SDKPresentationStyle presentationStyle = const PushStyle(),
  });
}

GDPaymentSDKConfiguration

class GDPaymentSDKConfiguration {
  final SDKTheme theme;
  final String sessionId;
  final SDKLanguage language;
  final bool isSandbox;
  final Region region;
}

Parameters

  • sessionId (required): Payment session ID
  • region: Region.egy, Region.uae, Region.ksa
  • isSandbox: Enable sandbox testing (default: false)
  • language: SDKLanguage.english or SDKLanguage.arabic
  • theme: Optional theme configuration

PaymentResponse

class PaymentResponse {
  final PaymentStatus status;
  final GDPaymentResult? result;
  final GDPaymentError? error;
}

GDPaymentResult

class GDPaymentResult {
  final String? orderId;
  final String? tokenId;
  final String? agreementId;
  final PaymentMethodResult? paymentMethod;
}

GDPaymentError

class GDPaymentError {
  final String code;
  final String message;
  final String? details;
}

Enums

enum Region { egy, uae, ksa }

enum SDKLanguage { english, arabic }

enum ThemeStyle { light, dark }

enum PaymentStatus { success, failure, canceled }