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
How It Works
- Initialize the Geidea Flutter SDK in your application.
- The SDK retrieves and displays available payment methods.
- Customer payment details are securely collected.
- The SDK processes the payment via Geidea’s payment gateway.
- The payment result is returned to the Flutter application and displayed to the user.
Getting Started
Prerequisites
| Requirement | Minimum Version |
|---|---|
| Flutter SDK | 3.0.0+ |
| Dart | 2.17.0+ |
| iOS Deployment Target | iOS 15.0+ |
| Android Min SDK | API 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 getPlatform-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.lightorThemeStyle.darkprimaryColor: 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 IDregion:Region.egy,Region.uae,Region.ksaisSandbox: Enable sandbox testing (default:false)language:SDKLanguage.englishorSDKLanguage.arabictheme: 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 }Updated 1 day ago