cafebazaar_flutter 2.0.0 cafebazaar_flutter: ^2.0.0 copied to clipboard
CafeBazaar In-App Billing package for flutter upgrade to poolakey this package is just for android applications
import 'package:flutter/material.dart';
import 'package:cafebazaar_flutter/cafebazaar_flutter.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
late InAppPurchase inApp;
late CafebazaarFlutter _bazaar;
@override
void initState() {
super.initState();
_bazaar = CafebazaarFlutter.instance;
inApp = _bazaar.inAppPurchase("PUBLIC_KEY");
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Plugin example app'),
),
body: Center(
child: Column(
children: [
ElevatedButton(
onPressed: () async {
final PurchaseInfo? purchaseInfo = await inApp.purchase("m2");
await inApp.consume(purchaseInfo?.purchaseToken ?? "");
print(purchaseInfo?.orderId);
print(purchaseInfo?.purchaseToken);
print(purchaseInfo.toString());
},
child: Text("Pay")),
],
)),
),
);
}
}