Skip to main content
Version: v1.4.x Legacy

Flutter Integration

Flutter Integration using Dart Wrapper

Create a Dart class that uses MethodChannel to communicate with the native implementations.

import 'package:flutter/services.dart';

class PaymentSDK {
static const MethodChannel _channel = MethodChannel('payment_sdk');

/// Initialize the Payment SDK with the given configuration
static Future<void> initialize(Map<String, dynamic> config) async {
await _channel.invokeMethod('initialize', config);
}

/// Update the Payment SDK configuration dynamically
static Future<void> updateConfiguration(Map<String, dynamic> config) async {
await _channel.invokeMethod('updateConfiguration', config);
}

/// Process a payment with the given details
static Future<String> processPayment(Map<String, dynamic> paymentDetails) async {
return await _channel.invokeMethod('processPayment', paymentDetails);
}

/// Retrieve payment tokens associated with an account ID
static Future<List<dynamic>> getPaymentTokens(String accountId) async {
return await _channel.invokeMethod('getPaymentTokens', {'accountId': accountId});
}

/// Retrieve the latest token transactions for a specific payment token
static Future<List<dynamic>> getLatestTokenTransactions(String paymentToken) async {
return await _channel.invokeMethod(
'getLatestTokenTransactions',
{'paymentToken': paymentToken},
);
}

/// Block a specific payment token
static Future<void> blockPaymentToken(String paymentToken) async {
await _channel.invokeMethod('blockPaymentToken', {'paymentToken': paymentToken});
}

/// Transfer payment tokens to another device for the same account ID
static Future<void> transferPaymentTokens(String accountId, List<String> tokens) async {
await _channel.invokeMethod('transferPaymentTokens', {
'accountId': accountId,
'tokens': tokens,
});
}

/// Set connection settings for the payment gateway
static Future<void> setConnectionSettings(Map<String, dynamic> settings) async {
await _channel.invokeMethod('setConnectionSettings', settings);
}

/// Subscribe to the payment form closure event
static Future<void> onPaymentFormClosed() async {
await _channel.invokeMethod('onPaymentFormClosed');
}

/// Handle SDK exceptions such as SDKNotInitializedException
static Future<void> handleSDKExceptions() async {
await _channel.invokeMethod('handleSDKExceptions');
}
}

Usage Example

Usage of the Payment SDK in a Flutter application:

import 'package:your_app/payment_sdk.dart';

void main() async {
final config = {
'language': 'en',
'theme': 'light',
'baseUrl': 'https://api.qicardpaymentgateway.com',
};

await PaymentSDK.initialize(config);

final paymentDetails = {
'paymentId': '123456',
'amount': 101.90,
'currency': 'GBP',
'customerInfo': {
'accountId': 'user_001',
},
'paymentMethod': {
'paymentType': 'PAYMENT_TOKEN',
'paymentToken': 'abc123',
},
};

try {
final result = await PaymentSDK.processPayment(paymentDetails);
print('Payment Successful: $result');
} catch (error) {
print('Payment Failed: $error');
}
}