rotateApiKey static method

Future<void> rotateApiKey(
  1. String newApiKey
)

Rotate API key securely

Implementation

static Future<void> rotateApiKey(String newApiKey) async {
  try {
    final backendUrl = await getBackendUrl();
    final merchantInfo = await getMerchantInfo();

    if (backendUrl == null || merchantInfo == null) {
      throw Exception('Cannot rotate API key without complete configuration');
    }

    await initializeConfig(
      backendUrl: backendUrl,
      apiKey: newApiKey,
      merchantInfo: merchantInfo,
    );
  } catch (e) {
    throw Exception('Failed to rotate API key: $e');
  }
}