Git Product home page Git Product logo

cafebazaar_flutter's Introduction

cafebazaar_flutter

CafeBazaar In-App Billing package for flutter this package is just for android applications and not work on ios

This plugin is just for Android applications

Getting Started

Import this line in Flutter pubspec

cafebazaar_flutter: <Last Version>

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" />

To Use CafeBazzar plugin import below code to your class(your payment class)

import 'package:cafebazaar_flutter/cafebazaar_flutter.dart';
  • All method be static and don't need to initialize any class

To show application page in cafeBazaar use this code(نمایش صفحه نرم افزار در کافه بازار)

CafebazaarFlutter.showProgramPage("packageName")  // Replace "package Name" with Your application Package Name. you can find package name on gradle file

To show comment and privilege in cafeBazaar use this code(ثبت نظر و امتیاز به برنامه)

CafebazaarFlutter.setComment("packageName")  // Replace "package Name" with Your application Package Name. you can find package name on gradle file

To show Developer page in cafeBazaar use this code(نمایش صفحه برنامه نویس در کافه بازار)

CafebazaarFlutter.showDeveloperPage("developerId")  // Replace "developerId" with Your developerId in CafeBazaar

To show CafeBazaar Login Page page in cafeBazaar use this code(ارجا کاربر به صفحه لاگین کافه بازار)

CafebazaarFlutter.showCafebazzarLogin()

For use In-app purchases on your application use below code جهت استفاده از پرداخت درون برنامه ای به صورت زیر عملکنید.

First of all initialize payment and ras Key in initState

use async and await

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

To start a purchase request from your app, call the launchPurchaseFlow method on the In-app Billing plugin

Map<String,dynamic> result = await CafebazaarFlutter.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 = CafebazaarFlutter.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 CafebazaarFlutter.verifyDeveloperPayload("your developerPayload");
  • 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 CafebazaarFlutter.dispose();

cafebazaar_flutter's People

Contributors

javad-zobeidi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

cafebazaar_flutter's Issues

Support null safety.

As the title says, we need to migrate this plugin to support the Dart sound null safety.

use together with myket_flutter

When using with myket_flutter and try to build apk, an error thrown
R8: Type com.android.vending.billing.IInAppBillingService$Stub$Proxy is defined multiple times

isLoggedIn method does not work in Flutter 3.7

The isLoggedIn method does not work and does not return anything. It doesn't even return an error!
I try to use it like this:

  Future<bool> launchPurchaseFlow() async {

    bool success = false;

    try {
      bool? isLoggedIn = await _bazaar.isLoggedIn();
      if (isLoggedIn == null || isLoggedIn == false) {
        _showProperMessage(isLoggedIn);
        return success;
      } else {
        final PurchaseInfo? purchaseInfo = await inapp.purchase(AppConfig.productSKU, payLoad: "payLoad");
        if (purchaseInfo != null) {
          success = await _getPurchaseAtBazaar();
        }
      }
    } catch (e) {
      _showCafeBazaarErrorState();
    }

    return success;
  }

And this is my Flutter doctor -v results:

PS C:\Users\hossein\projects\flutter\haazerr> Flutter doctor -v   
[√] Flutter (Channel stable, 3.7.0, on Microsoft Windows [Version 10.0.19044.2604], locale en-US)
    • Flutter version 3.7.0 on channel stable at C:\src\flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision b06b8b2710 (5 weeks ago), 2023-01-23 16:55:55 -0800
    • Engine revision b24591ed32
    • Dart version 2.19.0
    • DevTools version 2.20.1

[√] Windows Version (Installed version of Windows is version 10 or higher)

[√] Android toolchain - develop for Android devices (Android SDK version 33.0.1)
    • Android SDK at C:\Users\hossein\AppData\Local\Android\sdk
    • Platform android-33-ext4, build-tools 33.0.1
    • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 11.0.15+0-b2043.56-9505619)
    • All Android licenses accepted.

[√] Chrome - develop for the web
    • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe

[X] Visual Studio - develop for Windows
    X Visual Studio not installed; this is necessary for Windows development.
      Download at https://visualstudio.microsoft.com/downloads/.
      Please install the "Desktop development with C++" workload, including all of its default components

[√] Android Studio (version 2022.1)
    • Android Studio at C:\Program Files\Android\Android Studio
    • Flutter plugin can be installed from:
       https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
       https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.15+0-b2043.56-9505619)

[√] VS Code (version 1.75.1)
    • VS Code at C:\Users\hossein\AppData\Local\Programs\Microsoft VS Code       
    • Flutter extension version 3.58.0

[√] Connected device (4 available)
    • sdk gphone64 x86 64 (mobile) • emulator-5554 • android-x64    • Android 12 (API 31) (emulator)
    • Windows (desktop)            • windows       • windows-x64    • Microsoft Windows [Version 10.0.19044.2604]
    • Chrome (web)                 • chrome        • web-javascript • Google Chrome 110.0.5481.177
    • Edge (web)                   • edge          • web-javascript • Microsoft Edge 110.0.1587.50

[√] HTTP Host Availability
    • All required HTTP hosts are available

! Doctor found issues in 1 category.

خطا بعد از قطع کردن ارتباط با بازار

سلام بعد از اینکه متد disconnect رو میزنم به این خطا میخورم

E/MethodChannel#cafebazaar_flutter/methods( 6165): Failed to handle method call
E/MethodChannel#cafebazaar_flutter/methods( 6165): java.lang.NullPointerException
E/MethodChannel#cafebazaar_flutter/methods( 6165): at ir.javadzobeidi.cafebazaar_flutter.CafebazaarFlutterPlugin$iapConnect$1$3.invoke(CafebazaarFlutterPlugin.kt:222)
E/MethodChannel#cafebazaar_flutter/methods( 6165): at ir.javadzobeidi.cafebazaar_flutter.CafebazaarFlutterPlugin$iapConnect$1$3.invoke(CafebazaarFlutterPlugin.kt:219)
E/MethodChannel#cafebazaar_flutter/methods( 6165): at com.phelat.poolakey.callback.ConnectionCallback$disconnected$2.invoke(ConnectionCallback.kt:33)
E/MethodChannel#cafebazaar_flutter/methods( 6165): at com.phelat.poolakey.callback.ConnectionCallback$disconnected$2.invoke(ConnectionCallback.kt:6)
E/MethodChannel#cafebazaar_flutter/methods( 6165): at com.phelat.poolakey.BillingConnection.disconnect(BillingConnection.kt:222)
E/MethodChannel#cafebazaar_flutter/methods( 6165): at com.phelat.poolakey.BillingConnection.stopConnection(BillingConnection.kt:212)
E/MethodChannel#cafebazaar_flutter/methods( 6165): at com.phelat.poolakey.BillingConnection.access$stopConnection(BillingConnection.kt:30)
E/MethodChannel#cafebazaar_flutter/methods( 6165): at com.phelat.poolakey.BillingConnection$startConnection$1.invoke(BillingConnection.kt:44)
E/MethodChannel#cafebazaar_flutter/methods( 6165): at com.phelat.poolakey.BillingConnection$startConnection$1.invoke(BillingConnection.kt:30)
E/MethodChannel#cafebazaar_flutter/methods( 6165): at com.phelat.poolakey.callback.ConnectionCallback.disconnect(ConnectionCallback.kt:42)
E/MethodChannel#cafebazaar_flutter/methods( 6165): at ir.javadzobeidi.cafebazaar_flutter.CafebazaarFlutterPlugin.iapDisconnect(CafebazaarFlutterPlugin.kt:232)
E/MethodChannel#cafebazaar_flutter/methods( 6165): at ir.javadzobeidi.cafebazaar_flutter.CafebazaarFlutterPlugin.onMethodCall(CafebazaarFlutterPlugin.kt:90)
E/MethodChannel#cafebazaar_flutter/methods( 6165): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:258)
E/MethodChannel#cafebazaar_flutter/methods( 6165): at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:295)
E/MethodChannel#cafebazaar_flutter/methods( 6165): at io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0$io-flutter-embedding-engine-dart-DartMessenger(DartMessenger.java:322)
E/MethodChannel#cafebazaar_flutter/methods( 6165): at io.flutter.embedding.engine.dart.DartMessenger$$ExternalSyntheticLambda0.run(D8$$SyntheticClass)
E/MethodChannel#cafebazaar_flutter/methods( 6165): at android.os.Handler.handleCallback(Handler.java:751)
E/MethodChannel#cafebazaar_flutter/methods( 6165): at android.os.Handler.dispatchMessage(Handler.java:95)
E/MethodChannel#cafebazaar_flutter/methods( 6165): at android.os.Looper.loop(Looper.java:154)
E/MethodChannel#cafebazaar_flutter/methods( 6165): at android.app.ActivityThread.main(ActivityThread.java:6121)
E/MethodChannel#cafebazaar_flutter/methods( 6165): at java.lang.reflect.Method.invoke(Native Method)
E/MethodChannel#cafebazaar_flutter/methods( 6165): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:889)
E/MethodChannel#cafebazaar_flutter/methods( 6165): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:779)
E/flutter ( 6165): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: PlatformException(error, null, null, java.lang.NullPointerException
E/flutter ( 6165): at ir.javadzobeidi.cafebazaar_flutter.CafebazaarFlutterPlugin$iapConnect$1$3.invoke(CafebazaarFlutterPlugin.kt:222)
E/flutter ( 6165): at ir.javadzobeidi.cafebazaar_flutter.CafebazaarFlutterPlugin$iapConnect$1$3.invoke(CafebazaarFlutterPlugin.kt:219)
E/flutter ( 6165): at com.phelat.poolakey.callback.ConnectionCallback$disconnected$2.invoke(ConnectionCallback.kt:33)
E/flutter ( 6165): at com.phelat.poolakey.callback.ConnectionCallback$disconnected$2.invoke(ConnectionCallback.kt:6)
E/flutter ( 6165): at com.phelat.poolakey.BillingConnection.disconnect(BillingConnection.kt:222)
E/flutter ( 6165): at com.phelat.poolakey.BillingConnection.stopConnection(BillingConnection.kt:212)
E/flutter ( 6165): at com.phelat.poolakey.BillingConnection.access$stopConnection(BillingConnection.kt:30)
E/flutter ( 6165): at com.phelat.poolakey.BillingConnection$startConnection$1.invoke(BillingConnection.kt:44)
E/flutter ( 6165): at com.phelat.poolakey.BillingConnection$startConnection$1.invoke(BillingConnection.kt:30)
E/flutter ( 6165): at com.phelat.poolakey.callback.ConnectionCallback.disconnect(ConnectionCallback.kt:42)
E/flutter ( 6165): at ir.javadzobeidi.cafebazaar_flutter.CafebazaarFlutterPlugin.iapDisconnect(CafebazaarFlutterPlugin.kt:232)
E/flutter ( 6165): at ir.javadzobeidi.cafebazaar_flutter.CafebazaarFlutterPlugin.onMethodCall(CafebazaarFlutterPlugin.kt:90)
E/flutter ( 6165): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:258)
E/flutter ( 6165): at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:295)
E/flutter ( 6165): at io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0$io-flutter-embedding-engine-dart-DartMessenger(DartMessenger.java:322)
E/flutter ( 6165): at io.flutter.embedding.engine.dart.DartMessenger$$ExternalSyntheticLambda0.run(D8$$SyntheticClass)
E/flutter ( 6165): at android.os.Handler.handleCallback(Handler.java:751)
E/flutter ( 6165): at android.os.Handler.dispatchMessage(Handler.java:95)
E/flutter ( 6165): at android.os.Looper.loop(Looper.java:154)
E/flutter ( 6165): at android.app.ActivityThread.main(ActivityThread.java:6121)
E/flutter ( 6165): at java.lang.reflect.Method.invoke(Native Method)
E/flutter ( 6165): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:889)
E/flutter ( 6165): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:779)
E/flutter ( 6165): )
E/flutter ( 6165): #0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:652:7)
E/flutter ( 6165): #1 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:310:18)
E/flutter ( 6165):

getLatestVersion method doesn't work

This method always returns nothing and doesn't seem to work. Furthermore, according to CafeBaazar documents, "getVersionCode" must get PackageName as parameters but "getLatestVersion" doesn't have any input parameter, and PackageName not specified before calling.

From cafebazaar check for update document:
long vCode = service.getVersionCode("packagename");

Invalid key specification

با سلام .
من اپی دارم که از پرداخت درون برنامه ای از نوع غیر مصرفی استفاده میکنه . وقت که اقدام به خرید میکنم و بعد از موفقیت آمیز بودن خرید و ظاهر شدن پیام پرداخت موفقیت آمیز بودن پرداخت روی صفحه گوشی در بکند و در کدم با خطای عدم دریافت اطلاعات پرداخت از سوی سرور بازار مواجه میشم .

با اینکه پرداخت انجام شده و بازار هم تایید کرده اما در کد برنامه انگار پرداختی انجام نشده ونمیشه بخش پولی برنامم رو برای کاربر باز کنم و وقتی خرید مجدد هم میزنم پیام قبلا خریداری شده برام ظاهر میشه .

متن خطا به صورت زیر هست :
Invalid key specification. D/AndroidRuntime(15330): Shutting down VM E/AndroidRuntime(15330): FATAL EXCEPTION: main E/AndroidRuntime(15330): Process: jico.behyad.workar, PID: 15330 E/AndroidRuntime(15330): java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=10001, result=-1, data=Intent { (has extras) }} to activity {jico.behyad.workar/jico.behyad.workar.MainActivity}: java.lang.IllegalArgumentException: java.security.spec.InvalidKeySpecException: com.android.org.conscrypt.OpenSSLX509CertificateFactory$ParsingException: Error parsing public key

مشکل از کجا میتونه باشه؟ ممنون

please support flutter 3.0.1

Running Gradle task 'assembleDebug'...
e: F:\DevelopmentKit\flutter_3.0.1.pub-cache\hosted\pub.dartlang.org\cafebazaar_flutter-1.0.1\android\src\main\kotlin\ir\javadzobeidi\cafebazaar_flutter\BgResult.kt: (6, 1): Class 'BgResult' is not abstract and does not implement abstract member public abstract fun error(p0: String, p1: String?, p2: Any?): Unit defined in io.flutter.plugin.common.MethodChannel.Result
e: F:\DevelopmentKit\flutter_3.0.1.pub-cache\hosted\pub.dartlang.org\cafebazaar_flutter-1.0.1\android\src\main\kotlin\ir\javadzobeidi\cafebazaar_flutter\BgResult.kt: (13, 3): 'error' overrides nothing
e: F:\DevelopmentKit\flutter_3.0.1.pub-cache\hosted\pub.dartlang.org\cafebazaar_flutter-1.0.1\android\src\main\kotlin\ir\javadzobeidi\cafebazaar_flutter\BgResult.kt: (14, 33): Type mismatch: inferred type is String? but String was expected

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':cafebazaar_flutter:compileDebugKotlin'.

Compilation error. See log for more details

  • Try:

Run with --stacktrace option to get the stack trace.
Run with --info or --debug option to get more log output.
Run with --scan to get full insights.

BUILD FAILED in 2m 51s
Exception: Gradle task assembleDebug failed with exit code 1

En : When adding a package to the project in Flutter 3.0.1
Fa : موقع اضافه کردن ، پکیج به پروژه در فلاتر 3.0.1

Failed to transform poolakey-1.0.0-alpha07.aar to match attributes

Hi
I add cafebazaar_flutter to my project and use it . When I want to build and run app in emulator this error is showing :

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':cafebazaar_flutter:compileDebugAidl'.

Could not resolve all files for configuration ':cafebazaar_flutter:debugCompileClasspath'.
Failed to transform poolakey-1.0.0-alpha07.aar (com.phelat:poolakey:1.0.0-alpha07) to match attributes {artifactType=android-aidl, org.gradle.category=library, org.gradle.libraryelements=jar, org.gradle.status=release, org.gradle.usage=java-api}.
> Could not find poolakey-1.0.0-alpha07.aar (com.phelat:poolakey:1.0.0-alpha07).
Searched in the following locations:
https://maven.aliyun.com/nexus/content/groups/public/com/phelat/poolakey/1.0.0-alpha07/poolakey-1.0.0-alpha07.aar
https://maven.aliyun.com/nexus/content/groups/public/com/phelat/poolakey/1.0.0-alpha07/poolakey-1.0.0-alpha07.jar

Please Help

Get error in getting result of purchaseDetail method.

for checking purchase of user I use purchaseDetail(...) as code below:

MainMethod:

Future<Map<String, dynamic>> result = BazaarUtils.purchaseDetail("sample2");
      result
          .then((result) {
            if (result == null) {
              print("Purchase is null");
            }
            else {
              print("Already Purched");
            }
          })
          .catchError((error) => print('Detail error: $error'))
          .whenComplete(() {
            widget.onPushLoadingWidget(false);
          });

BazaarUtils.purchaseDetail:

static Future<Map<String, dynamic>> purchaseDetail(String sku) async {
    Map<String, dynamic> result = await CafebazaarFlutter.getPurchase(sku: sku);
    return result;
}

But in logs I got these error:

Detail error: NoSuchMethodError: The getter 'length' was called on null.
    Receiver: null
    Tried calling: length

I already use initPay(...) for initializing payment.
How can I check that user purchased some product?
Thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.