cafebazaar_market 0.9.5

  • Readme
  • Changelog
  • Example
  • Installing
  • new54

cafebazaar_market #

flutter plugin for Cafebazaar android market (only works on android)

Getting Started #

Communicate with Cafe Bazaar Application #

ارتباط با برنامه کافه بازار

  • Go to Application page #

  • رفتن به صفحه اپلیکیشن
//launches application page on bazaar app if bazaar is installed  
CafebazaarMarket.showProgramPage();  
  • Add Comment #

  • گذاشتن کامنت و امتیاز دادن به برنامه
//launches comment bazaar dialog  
CafebazaarMarket.setComment();  
  • Go to Developer page #

  • رفتن به صفحه برنامه نویس
//launches developer page on bazaar  
CafebazaarMarket.showDeveloperPage("your_id");  
  • Go to Cafe Bazaar login page #

  • رفتن به صفحه ورود کافه بازار
//launches bazaar login page  
CafebazaarMarket.showCafebazzarLogin();  

Check Application Update #

بررسی اپدیت بودن برنامه

  • Checking for update (if newer version is available) #

  • بررسی اپدیت بودن برنامه در صورت موجود بودن نسخه جدید
bool isUpdateAvailable = await CafebazaarMarket.isUpdateAvailable();  
 if(isUpdateAvailable) {  
 CafebazaarMarket.showProgramPage();  
 //or just show a dialog ask if user wants to update then call CafebazaarMarket.showProgramPage();  }  

Cafe Bazaar Payment #

بخش پرداخت کافه بازار

For use In-app purchases on your application use below code

  • جهت استفاده از پرداخت درون برنامه ای به صورت زیر عمل کنید.

1. Updating Your Application's Manifest #

  • این خط رو به فایل مانیفست برنامه اظافه کنید
  • Adding the com.farsitel.bazaar.permission.PAY_THROUGH_BAZAAR permission to your AndroidManifest.xml file
<uses-permission android:name="com.farsitel.bazaar.permission.PAY_THROUGH_BAZAAR" />

2. First of all initialize payment and rsa Key in initState #

  • این خط رو در قسمت initState اظافه کنید

use async and await

await CafebazaarMarket.initPay(rsaKey:"Your RSA Key From CafeBazaar");

3. And use this line in dispose #

  • این خط رو در قسمت dispose اظافه کنید
  • Important: Remember to unbind from the In-app Billing service when you are done with your Activity. If you don’t unbind, the open service connection could cause your device’s performance to degrade. This example shows how to perform the unbind operation on a service connection to In-app Billing called mServiceConn by overriding the activity’s onDestroy method.
await CafebazaarMarket.disposePayment();
  • To start a purchase request from your app, call the launchPurchaseFlow method on the In-app Billing plugin #

Map<String,dynamic> result = await CafebazaarMarket.launchPurchaseFlow(
                        sku: "wm2", consumption: false,payload:"bGoa+V7g/yqDXvKRqq+JTFn4uQZbPiQJo4pf9RzJ");
 // after pay you get some data from Cafebazaar, if you get response code -1005 the payment is canceled by the user and  if get code 0  the payment is Success

  1. sku : your product id on CafeBazaar

  2. consumption : if your product is not a subscriber type you must consume it, For product consumption, set the consumption to true

*consumption : زمانی که محصول شما از نوع اشتراکی نباشد و از نوع مصرفی باشد باید ان را مصرف کنید تا در خرید ها بعدی کاربر بتواند ان را دوباره خریداری کند برای مصرف یک محصول consumption را به صورت true .تنظیم کنید

4.payload : The developerPayload String is used to specify any additional arguments that you want Bazaar to send back along with the purchase information.

  • Result If pay is success
'{
    "isSuccess": "true",
    "response":"0",
    "message":"Success (response: 0:OK)",
    "purchase":{
       "orderId":"12999763169054705758.1371079406387615",
       "packageName":"com.example.app",
       "productId":"exampleSku",
       "purchaseTime":1345678900000,
       "purchaseState":0,
       "developerPayload":"bGoa+V7g/yqDXvKRqq+JTFn4uQZbPiQJo4pf9RzJ",
       "purchaseToken":"rojeslcdyyiapnqcynkjyyjh"
     }
}'
  • To get Purchase details use below code #

Map<String,dynamic> result = CafebazaarMarket.getPurchase(sku:"your product sku") // you can find sku(product id) in your application in-app section
// you get the payment details if you consumption the product result is null

Result

'{
   "orderId":"12999763169054705758.1371079406387615",
   "packageName":"com.example.app",
   "productId":"exampleSku",
   "purchaseTime":1345678900000,
   "purchaseState":0,
   "developerPayload":"bGoa+V7g/yqDXvKRqq+JTFn4uQZbPiQJo4pf9RzJ",
   "purchaseToken":"rojeslcdyyiapnqcynkjyyjh"
 }'
  • Security Recommendation: When you send a purchase request, create a String token that uniquely identifies this purchase request and include this token in the developerPayload.You can use a randomly generated string as the token. When you receive the purchase response from Bazaar, make sure to check the returned data signature, the orderId, and the developerPayload String. For added security, you should perform the checking on your own secure server. Make sure to verify that the orderId is a unique value that you have not previously processed, and the developerPayload String matches the token that you sent previously with the purchase request.
  • After Payment result check developerPayload result true or false #

bool result = await CafebazaarMarket.verifyDeveloperPayload("your developerPayload");

For more information about Cofe Bazaar payment go to Cafe Bazaar payment article .

0.9.5 #

  • fix readme content

0.9.4 #

  • add CafeBazaar payment

0.1.2 #

  • fix readme content

0.1.1 #

  • fix readme content

0.1.0 #

  • add check app version for update

0.0.1 #

  • this release has features : open app page on bazaar,comment,developer page,cafebazaar login page

example/lib/main.dart

import 'package:cafebazaar_market/cafebazaar_market.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  String _updateAvailable = 'Unknown';
  String _connectToBazaar = 'Unknown';

  @override
  void initState() {
    super.initState();
    //for payment
    initConnectToBazaar();
    initCheckUpdate();
  }

  // Platform messages are asynchronous, so we initialize in an async method.
  Future<void> initConnectToBazaar() async {
    String connectToBazaar;
    // Platform messages may fail, so we use a try/catch PlatformException.
    try {
      //check update available
      bool connect = await CafebazaarMarket.initPay(rsaKey: null);
      if (connect) {
        print("connect");
        connectToBazaar = "Yes";
      } else {
        print("disconnect");
        connectToBazaar = "No";
      }
    } on PlatformException {
      connectToBazaar = 'Failed to connect to Bazaar.';
    }

    // If the widget was removed from the tree while the asynchronous platform
    // message was in flight, we want to discard the reply rather than calling
    // setState to update our non-existent appearance.
    if (!mounted) return;

    setState(() {
      _connectToBazaar = connectToBazaar;
    });
  }

  // Platform messages are asynchronous, so we initialize in an async method.
  Future<void> initCheckUpdate() async {
    String pdateAvailable;
    // Platform messages may fail, so we use a try/catch PlatformException.
    try {
      //check update available
      bool hasUpdate = await CafebazaarMarket.isUpdateAvailable();
      if (hasUpdate) {
        print("has update");
        pdateAvailable = "Yes";
      } else {
        print("no update");
        pdateAvailable = "No";
      }
    } on PlatformException {
      pdateAvailable = 'Failed to get version for checking update';
    }

    // If the widget was removed from the tree while the asynchronous platform
    // message was in flight, we want to discard the reply rather than calling
    // setState to update our non-existent appearance.
    if (!mounted) return;

    setState(() {
      _updateAvailable = pdateAvailable;
    });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example Cafebazaar Market'),
        ),
        body: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              Text('Connect To Bazaar for payment: $_connectToBazaar\n'),
              Text('Update Available: $_updateAvailable\n'),
              SizedBox(
                height: 10,
              ),
              FlatButton(
                child: Text("page app"),
                color: Colors.black12,
                onPressed: () {
                  //show app page on cafe bazaar
                  CafebazaarMarket.showProgramPage();
                },
              ),
              SizedBox(
                height: 10,
              ),
              FlatButton(
                color: Colors.black12,
                child: Text("comment to app"),
                onPressed: () {
                  //add comment for app  on cafe bazaar
                  CafebazaarMarket.setComment();
                },
              ),
              SizedBox(
                height: 10,
              ),
              FlatButton(
                color: Colors.black12,
                child: Text("developer page"),
                onPressed: () {
                  //show developer apps on cafe bazaar
                  CafebazaarMarket.showDeveloperPage("1234");
                },
              ),
              SizedBox(
                height: 10,
              ),
              FlatButton(
                color: Colors.black12,
                child: Text("bazaar login page"),
                onPressed: () {
                  //show cafe bazaar login page
                  CafebazaarMarket.showCafebazzarLogin();
                },
              ),
              SizedBox(
                height: 10,
              ),
              RaisedButton(
                  child: Text("PayFirst"),
                  onPressed: () async {
                    Map<String, dynamic> result =
                        await CafebazaarMarket.launchPurchaseFlow(
                            sku: "PayFirst",
                            consumption: false,
                            payload:
                                "bGoa+V7g/yqDXvKRqq+JTFn4uQZbPiQJo4pf9RzJ");
                    print("resultresult $result");
                    CafebazaarMarket.verifyDeveloperPayload(
                            payload: "bGoa+V7g/yqDXvKRqq+JTFn4uQZbPiQJo4pf9RzJ")
                        .then((res) {
                      print(res);
                    });
                  }),
              SizedBox(
                height: 10,
              ),
              RaisedButton(
                  child: Text("PaySecond"),
                  onPressed: () async {
                    Map<String, dynamic> result =
                        await CafebazaarMarket.launchPurchaseFlow(
                            sku: "PaySecond",
                            consumption: true,
                            payload: "yqDXvKRqq+JTFn4uQZbPiQJo4pf9RzJ");
                    print("resultresult $result");
                    CafebazaarMarket.verifyDeveloperPayload(
                            payload: "yqDXvKRqq+JTFn4uQZbPiQJo4pf9RzJ")
                        .then((res) {
                      print(res);
                    });
                  }),
            ],
          ),
        ),
      ),
    );
  }

  @override
  void dispose() {
    //use dispose Payment if you use initPay
    CafebazaarMarket.disposePayment();
    super.dispose();
  }
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  cafebazaar_market: ^0.9.5

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:cafebazaar_market/cafebazaar_market.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
8
Health:
Code health derived from static analysis. [more]
99
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
54
Learn more about scoring.

We analyzed this package on Jul 3, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.4
  • pana: 0.13.13
  • Flutter: 1.17.5

Analysis suggestions

Package does not support Flutter platform linux

Because of import path [package:cafebazaar_market/cafebazaar_market.dart] that declares support for platforms: android, ios

Package does not support Flutter platform macos

Because of import path [package:cafebazaar_market/cafebazaar_market.dart] that declares support for platforms: android, ios

Package does not support Flutter platform web

Because of import path [package:cafebazaar_market/cafebazaar_market.dart] that declares support for platforms: android, ios

Package does not support Flutter platform windows

Because of import path [package:cafebazaar_market/cafebazaar_market.dart] that declares support for platforms: android, ios

Package not compatible with SDK dart

because of import path [cafebazaar_market] that is in a package requiring null.

Health issues and suggestions

Document public APIs. (-1 points)

14 out of 14 API elements have no dartdoc comment.Providing good documentation for libraries, classes, functions, and other API elements improves code readability and helps developers find and use your API.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.7.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.12 1.14.13
meta 1.1.8
sky_engine 0.0.99
typed_data 1.1.6 1.2.0
vector_math 2.0.8
Dev dependencies
flutter_test