hyochan/flutter_inapp_purchase

Offer Token issue

Closed this issue · 2 comments

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.

// 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.

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.