initBuyNow method

void initBuyNow({
  1. required BuildContext context,
  2. required PlayState playState,
  3. required Datum content,
  4. required Function onLoadCallback,
  5. bool isContinueWatchingItemClicked = false,
})

Implementation

void initBuyNow(
    {required BuildContext context,
    required PlayState playState,
    required Datum content,
    required Function onLoadCallback,
    bool isContinueWatchingItemClicked = false}) async {
  onLoadCallback(PlayState(
    buttonState: playState.buttonState,
    isLoading: true,
  ));

  String url = "";

  if (kIsWeb) {
    url = await _generateCheckoutUrl(content, context);
  }
  SharedPreferences sharedPreferences = await DeviceStorage().getInstance();
  sharedPreferences.setString(DeviceStorage.purchaseListData, "");

  if (context.mounted) {
    if (kIsWeb) {
      _launchUrl(url, context);
      onLoadCallback(PlayState(
          buttonState: playState.buttonState,
          buttonText: PlayButtonState.buy,
          isLoading: false));
    } else {
      //Call to show bottom sheet dialog for purchase
      // await initInAppPayment(content, onLoadCallback, context);
    }
  }
}