dooboolab-community / flutter_inapp_purchase

(Sun Rised!) Flutter plugin for In App Purchase.
MIT License
549 stars 236 forks source link

Offer Token issue #458

Closed kinjalofficial closed 6 months ago

kinjalofficial commented 10 months ago

flutter_inapp_purchase: ^5.4.2

Android

image

offerToken is required for constructing ProductDetailsParams

Real device (Samsung,MI)

When i request for plan purchase it is showing offerToken is required for constructing ProductDetailsParams error.

BhagyeshAgiles commented 9 months ago

// Request a subscription with the specified planId and offerTokenIndex.

FlutterInappPurchase.instance
    .requestSubscription(planId, offerTokenIndex: priceSelectIndex.value)
    .onError((error, stackTrace) {
      // Dismiss a loader dialog if shown.
      ShowLoaderDialog.dismissLoaderDialog();

      // Show a SnackBar with an error message if the subscription request encounters an error.
      SnackBarUtil.showSnackBar(
        context: Get.context!,
        type: SnackType.error,
        message: error.toString(),
      );
    });

In this code:

You're using FlutterInappPurchase.instance to request a subscription with a specific planId.

The offerTokenIndex parameter is set based on the value of priceSelectIndex.value. This can be used to specify a particular subscription offer within the plan if you have multiple subscription offers available.

The onError callback handles what to do in case of an error:

It dismisses a loader dialog if one is displayed. It shows a SnackBar with an error message to provide feedback to the user when the subscription request encounters an error. @kinjalofficial Please make sure to customize the error handling and UI feedback according to your app's requirements.

github-actions[bot] commented 6 months ago

This issue is stale because it has been open 90 days with no activity. Leave a comment or this will be closed in 7 days.