initialize static method
Initializes the Khipu Pay plugin.
This method is used to initialize the Khipu Pay plugin. Call this method before using any other methods or properties of the plugin.
Example usage:
KhipuPay.initialize();
Note: This method should be called only once during the app's lifecycle.
Implementation
static void initialize({String? apiKey}) {
assert(
!_instance._initialized,
'This instance is already initialized',
);
if (apiKey != null && apiKey.isNotEmpty) {
_instance._init(apiKey);
} else {
const apiKey = String.fromEnvironment(Constants.khipuAPIKey, defaultValue: Constants.empty);
if (apiKey.isEmpty) {
throw ArgumentError('You must provide an API key in the environment variables or as a parameter to initialize() method.');
}
_instance._init(apiKey);
}
}