项目作者: DJafari

项目描述 :
CafeBazaar APIs (In-App Purchase, Intents, UpdateChecker, LoginChecker) in flutter, works only in Android platform
高级语言: Kotlin
项目地址: git://github.com/DJafari/flutter_bazaar.git
创建时间: 2020-08-19T22:10:04Z
项目社区:https://github.com/DJafari/flutter_bazaar

开源协议:BSD 3-Clause "New" or "Revised" License

下载


SHOW PERSIAN README

flutter_bazaar

CafeBazaar API (In-App Purchase, Intents, UpdateChecker, LoginChecker) in flutter, works only in Android platform

Getting Started

first, add flutter_bazaar to your pubspec dependencies.

  1. flutter_bazaar: <LAST VERSION>

To import flutter_bazaar:

  1. import 'package:flutter_bazaar/flutter_bazaar.dart';

Done!

API

In-App purchase

InAppPurchase of this library build by Poolakey, new cafebazaar IAP library

Initialization

first you must initialized iap :

  1. final _bazaar = FlutterBazaar.instance;
  2. final iap = _bazaar.inAppPurchase(PUBLIC_KEY);

PUBLIC_KEY is your public RSA key from cafebazaar control panel

Purchase a product

  1. final PurchaseInfo purchaseInfo = await iap.purchase("productId", payLoad: "Your payload");
  2. if(purchaseInfo != null) {
  3. print('success: $purchaseResult');
  4. }

if purchaseInfo != null purchase is successful

purchaseInfo is full detail of purchase :

  1. class PurchaseInfo {
  2. final String orderId;
  3. final String purchaseToken;
  4. final String payload;
  5. final String packageName;
  6. final String purchaseState;
  7. final int purchaseTime;
  8. final String productId;
  9. final String dataSignature;
  10. }

Subscribe to product

  1. final PurchaseInfo purchaseInfo = await iap.subscribe("productId", payLoad: "Your payload");
  2. if(purchaseInfo != null) {
  3. print('success: $subscribeResult');
  4. }

if purchaseInfo != null subscription is successful

Consume a purchase

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

User purchases

for getting all purchases of user :

  1. final List<PurchaseInfo> purchasedProducts = await iap.getPurchasedProducts();
  2. print(purchasedProducts);

User Subscriptions

for getting all subscriptions of user :

  1. final List<PurchaseInfo> subscribedProducts = await iap.getSubscribedProducts();
  2. print(subscribedProducts);

Disconnect

for disconnect connection of app and cafebazaar :

  1. await iap.disconnect();

Intents

Open application detail page

for open details page of your app ( or another application ) you can use this method :

  1. final _bazaar = FlutterBazaar.instance;
  2. await _bazaar.openDetail([String packageName]);
  3. 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

Open Developer applications List

for open list of all applications of developer, you can use this method :

  1. final _bazaar = FlutterBazaar.instance;
  2. await _bazaar.openDeveloperPage(String developerId);
  3. print('USER BACK TO YOUR APP');

note: this method is Future, and you can found when user back to app

Open comment form

for open comment form of this app ( or given packageName app ) use this method :

  1. final _bazaar = FlutterBazaar.instance;
  2. await _bazaar.openCommentForm([String packageName]);
  3. 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

Update Checker

for getting current version of your app in cafebazaar market :

  1. final _bazaar = FlutterBazaar.instance;
  2. final int versionCode = await _bazaar.getLatestVersion();

Login Checker

for getting current status of logged user in cafebazaar, you can use this method :

  1. final _bazaar = FlutterBazaar.instance;
  2. final bool isLoggedIn = await _bazaar.isLoggedIn();

for more info check Example