Reputation: 6796
I am trying to implement a subscription feature for my app...Just created the Subscription and the 2 base plans, but I am stuck on onError('Ids not found');
I also included here a screenshot from my google play to support my help. I've no idea what is going on...
There is just one thing..it may or may not be the issue...My payments profile says:
Verify your identity Your identity verification is in progress. Please allow a few days for verification.
Any idea what is going on ? ty in advance
import 'package:in_app_purchase/in_app_purchase.dart';
import 'package:in_app_purchase_android/in_app_purchase_android.dart';
class SubscribeAndroid {
final InAppPurchase _inAppPurchase = InAppPurchase.instance;
SubscribeAndroid();
Future<void> subscribe({
required String productId,
required void Function(String message) onSuccess,
required void Function(String error) onError,
required void Function(List<String> productIds) onGotAvailableIds,
}) async {
final bool available = await InAppPurchase.instance.isAvailable();
if (!available) {
onError('Store is not available');
return;
}
const Set<String> _kIds = <String>{
'premium1-monthly',
'premium1-premium1-weekly',
'premium1'
};
final ProductDetailsResponse response =
await InAppPurchase.instance.queryProductDetails(_kIds);
if (response.notFoundIDs.isNotEmpty) {
onError('Ids not found');
return;
}
List<ProductDetails> products = response.productDetails;
print(products.first);
final productIds =
response.productDetails.map((product) => product.id).toList();
onGotAvailableIds(productIds);
final ProductDetails productDetails = response.productDetails.firstWhere(
(product) => product.id == productId,
orElse: () => response.productDetails.first,
);
final purchaseParam =
GooglePlayPurchaseParam(productDetails: productDetails);
_inAppPurchase
.buyNonConsumable(purchaseParam: purchaseParam)
.then((success) {
if (success) {
onSuccess('Purchase confirmed');
} else {
onError('Purchase failed');
}
}).catchError((error) {
onError('Purchase error: $error');
});
}
}
Upvotes: 0
Views: 68