updateConfig static method

Future<void> updateConfig({
  1. String? backendUrl,
  2. String? apiKey,
  3. Map<String, dynamic>? merchantInfo,
})

Update configuration securely

Implementation

static Future<void> updateConfig({
  String? backendUrl,
  String? apiKey,
  Map<String, dynamic>? merchantInfo,
}) async {
  try {
    final currentBackendUrl = backendUrl ?? await getBackendUrl();
    final currentApiKey = apiKey ?? await getApiKey();
    final currentMerchantInfo = merchantInfo ?? await getMerchantInfo();

    if (currentBackendUrl == null || currentApiKey == null || currentMerchantInfo == null) {
      throw Exception('Cannot update incomplete configuration');
    }

    await initializeConfig(
      backendUrl: currentBackendUrl,
      apiKey: currentApiKey,
      merchantInfo: currentMerchantInfo,
    );
  } catch (e) {
    throw Exception('Failed to update configuration: $e');
  }
}