initializeConfig static method
Initialize secure configuration
Implementation
static Future<void> initializeConfig({
required String backendUrl,
required String apiKey,
required Map<String, dynamic> merchantInfo,
}) async {
try {
// Encrypt sensitive data
final encryptedApiKey = _encryptData(apiKey);
final merchantInfoJson = jsonEncode(merchantInfo);
// Create configuration hash for integrity check
final configHash = _createConfigHash(backendUrl, apiKey, merchantInfoJson);
// Store securely
await _storage.write(key: _backendUrlKey, value: backendUrl);
await _storage.write(key: _apiKeyKey, value: encryptedApiKey);
await _storage.write(key: _merchantInfoKey, value: merchantInfoJson);
await _storage.write(key: _configHashKey, value: configHash);
} catch (e) {
throw Exception('Failed to initialize secure configuration: $e');
}
}