To retrieve the base plan and subscription offers from the Google Play Store console in Flutter, you can use the Google Play Billing Library. Here are the steps:
dependencies:
in_app_purchase: ^0.3.4+1
import 'package:in_app_purchase/in_app_purchase.dart';
class MyHomePage extends StatefulWidget {
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
final InAppPurchaseConnection _connection = InAppPurchaseConnection.instance;
@override
void initState() {
super.initState();
_connection.onBillingSetupComplete.listen((billingResult) {
// Handle the result of the billing setup process
});
_connection.billingClient;
}
@override
Widget build(BuildContext context) {
// Build your Flutter UI
}
}
Future<void> _getProducts() async {
final ProductDetailsResponse response = await _connection.queryProductDetails(<String>[
'base_plan_id',
'subscription_1_month_id',
'subscription_6_month_id',
'subscription_1_year_id'
]);
if (response.error != null) {
// Handle the error
return;
}
final List<ProductDetails> products = response.productDetails;
// Do something with the product details, e.g. display them in a list
}
Asked: 2022-09-28 11:00:00 +0000
Seen: 10 times
Last updated: Feb 09 '22