CafeBazaar API (In-App Purchase, Intents, UpdateChecker, LoginChecker) in flutter, works only in Android platform
first, add flutter_bazaar
to your pubspec dependencies.
flutter_bazaar: <LAST VERSION>
To import flutter_bazaar
:
import 'package:flutter_bazaar/flutter_bazaar.dart';
Done!
InAppPurchase of this library build by Poolakey, new cafebazaar IAP library
first you must initialized iap :
final _bazaar = FlutterBazaar.instance;
final iap = _bazaar.inAppPurchase(PUBLIC_KEY);
PUBLIC_KEY is your public RSA key from cafebazaar control panel
final PurchaseInfo purchaseInfo = await iap.purchase("productId", payLoad: "Your payload");
if(purchaseInfo != null) {
print('success: $purchaseResult');
}
if purchaseInfo != null
purchase is successful
purchaseInfo
is full detail of purchase :
class PurchaseInfo {
final String orderId;
final String purchaseToken;
final String payload;
final String packageName;
final String purchaseState;
final int purchaseTime;
final String productId;
final String dataSignature;
}
final PurchaseInfo purchaseInfo = await iap.subscribe("productId", payLoad: "Your payload");
if(purchaseInfo != null) {
print('success: $subscribeResult');
}
if purchaseInfo != null
subscription is successful
final bool consumeResult = await iap.consume("PURCHASE TOKEN"); //IN PurchaseInfo.purchaseToken
note: if you need PurchaseToken
after purchase
you can getting it from purchaseInfo.purchaseToken
for getting all purchases of user :
final List<PurchaseInfo> purchasedProducts = await iap.getPurchasedProducts();
print(purchasedProducts);
for getting all subscriptions of user :
final List<PurchaseInfo> subscribedProducts = await iap.getSubscribedProducts();
print(subscribedProducts);
for disconnect connection of app and cafebazaar :
await iap.disconnect();
for open details page of your app ( or another application ) you can use this method :
final _bazaar = FlutterBazaar.instance;
await _bazaar.openDetail([String packageName]);
print('USER BACK TO YOUR APP');
if packageName == null
this library open details page of current packageName
note: this method is Future, and you can found when user back to app
for open list of all applications of developer, you can use this method :
final _bazaar = FlutterBazaar.instance;
await _bazaar.openDeveloperPage(String developerId);
print('USER BACK TO YOUR APP');
note: this method is Future, and you can found when user back to app
for open comment form of this app ( or given packageName app ) use this method :
final _bazaar = FlutterBazaar.instance;
await _bazaar.openCommentForm([String packageName]);
print('USER BACK TO YOUR APP');
if packageName == null
this library open comment form of current packageName
note: this method is Future, and you can found when user back to app
for getting current version of your app in cafebazaar market :
final _bazaar = FlutterBazaar.instance;
final int versionCode = await _bazaar.getLatestVersion();
for getting current status of logged user in cafebazaar, you can use this method :
final _bazaar = FlutterBazaar.instance;
final bool isLoggedIn = await _bazaar.isLoggedIn();
for more info check Example