initializeOloPay method

Future<void> initializeOloPay({
  1. bool productionEnvironment = true,
  2. DigitalWalletConfiguration? digitalWalletConfig,
})

Initializes the Olo Pay SDK.

Important: The SDK only needs to be initialized once, even if multiple instances of OloPaySdk are created/used.

productionEnvironment determines if the SDK will be initialized for production or test environment usage.

In order to enable digital wallets, a non-null digitalWalletConfig must be provided. To enable Apple Pay, the config must contain a non-null DigitalWalletConfiguration.applePayConfig. Similarly a non-null DigitalWalletConfiguration.googlePayConfig is required to enable Google Pay.

Important: The Olo Pay SDK will be fully initialized when this method completes. However, digital wallets have an asynchronous callback to indicate when they are ready to be used. See onDigitalWalletReady for more information

If an error occurs while initializing the SDK a PlatformException will be thrown. The PlatformException.code property on the exception can be used to determine what went wrong and take appropriate action. The PlatformException.message property can be used to get more information about what went wrong.

When a PlatformException is thrown, the PlatformException.code property will be one of the following:

Implementation

Future<void> initializeOloPay({
  bool productionEnvironment = true,
  DigitalWalletConfiguration? digitalWalletConfig,
}) async {
  return await OloPaySdkPlatform.instance.initializeOloPay(
    productionEnvironment: productionEnvironment,
    digitalWalletConfig: digitalWalletConfig,
  );
}