Giter Club home page Giter Club logo

cafebazaarunity's Introduction

CafebazaarUnity

Cafebazaar In-app purchase Unity plugin

BUILD INSTRUCTION

To build BazaarIAB.jar from the java source code:

  1. Open a command prompt
  2. Navigate to JavaPlugin folder
  3. Type gradlew createJar
  4. After the build is succeeded you can find BazaarIAB.jar in the build folder

INSIDE UNITY PROJECT

This plugin has not any prefab to use, it will manage the required objects.

The BazaarIAB is the interface that let you call billing functions, all methods are static so is it not required to instantiate this class. Before calling any other function try to initialize the plugin by calling the init with the public key provided by Cafebazaar developer portal.

This call will check to see if billing is supported and fire the billingSupportedEvent if it is. If billing is not supported the billingNotSupportedEvent will fire and you should not call any other methods.

There is IABEventManager class that you can subscribe to all plugin events.

After you find out that the billing is supported, you can call queryInventory by providing all of your available skus. When the queryInventorySucceededEvent fires it will contain a list of all the current purchases, subscriptions and a list of all your project sku details. You can use this information to setup your store. The list is also handy when you want to consume a purchase. Any BazaarPurchases returned are available for consumption.

Add the plugin activity in the Application section of the AndroidManifest.xml:

<meta-data android:name="billing.service" android:value="bazaar.BazaarIabService" />
<activity android:name="com.bazaar.BazaarIABProxyActivity" android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen" />

Also add the required permissions to your manifest:

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="com.farsitel.bazaar.permission.PAY_THROUGH_BAZAAR" />

Methods

Methods are inside BazaarIAB class.

// Initializes the billing system
public static void init(string publicKey)

// Get current version of plugin
public static string GetVersion()

// Toggles high detail logging on/off
public static void enableLogging(bool shouldEnable)

// Unbinds and shuts down the billing service
public static void unbindService()

// Returns whether subscriptions are supported on the current device
public static bool areSubscriptionsSupported()

// Sends a request to get all completed purchases and product information as setup in the Bazaar dashboard about the provided skus (requires user to be logged in otherwise you will get error)
public static void queryInventory(string[] skus)

// Sends a request to get all product information as setup in the CafeBazaar portal about the provided skus (do not required user to be loggedin)
public static void querySkuDetails(string[] skus)

// Sends a request to get all completed purchases (requires user to be logged in otherwise you will get error)
public static void queryPurchases()

// Sends out a request to purchase the product
public static void purchaseProduct(string sku)
public static void purchaseProduct(string sku, string developerPayload)

// Sends out a request to consume the product
public static void consumeProduct(string sku)
// Sends out a request to consume all of the provided products
public static void consumeProducts(string[] skus)

Events

You can access events from IABEventManager class.

// Fired after init is called when billing is supported on the device
public static event Action billingSupportedEvent;
// Fired after init is called when billing is not supported on the device
public static event Action<string> billingNotSupportedEvent;

// Fired when the inventory and purchase history query has returned
public static event Action<List<BazaarPurchase>,List<BazaarSkuInfo>> queryInventorySucceededEvent;
// Fired when the inventory and purchase history query fails
public static event Action<string> queryInventoryFailedEvent;

// Fired when the SkuDetails query has returned
public static event Action<List<BazaarSkuInfo>> querySkuDetailsSucceededEvent;
// Fired when the SkuDetails query fails
public static event Action<string> querySkuDetailsFailedEvent;

// Fired when the purchase history query has returned
public static event Action<List<BazaarPurchase>> queryPurchasesSucceededEvent;
// Fired when the purchase history query fails
public static event Action<string> queryPurchasesFailedEvent;

// Fired when a purchase succeeds
public static event Action<BazaarPurchase> purchaseSucceededEvent;
// Fired when a purchase fails
public static event Action<string> purchaseFailedEvent;

// Fired when a call to consume a product succeeds
public static event Action<BazaarPurchase> consumePurchaseSucceededEvent;
// Fired when a call to consume a product fails
public static event Action<string> consumePurchaseFailedEvent;

Thanks

  • mohsen-srn for pointing out the AndroidManifest.xml issue in newer Unity versions.
  • Hossynkoala for fixing white keyboard issue in AndroidManifest.
  • Mahdad-Baghani help with finding nullReference exception in Unity 2019.3.0f3.
  • AhM0D fixed a crash when there is no Cafebazaar app installed on older devices.

cafebazaarunity's People

Contributors

ahm0d avatar alia74 avatar enzx avatar hojjatjafary avatar hossynkoala 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

cafebazaarunity's Issues

Security

Hi, is this plugin secured from hack?
Application like lucky patcher can hack it or not?

خطا در دریافت خرید های قبلی کاربر

خطا در دریافت خرید های قبلی کاربر:

# Type of exception: java.lang.NullPointerException
# Exception message: Attempt to invoke interface method 'android.os.Bundle com.android.vending.billing.IInAppBillingService.getPurchases(int, java.lang.String, java.lang.String, java.lang.String)' on a null object reference
# Thread name: Thread-75
# Stacktrace: java.lang.NullPointerException: Attempt to invoke interface method 'android.os.Bundle com.android.vending.billing.IInAppBillingService.getPurchases(int, java.lang.String, java.lang.String, java.lang.String)' on a null object reference
	at com.bazaar.util.ServiceIAB.getPurchases(ServiceIAB.java:265)
	at com.bazaar.util.IabHelper.queryPurchases(IabHelper.java:753)
	at com.bazaar.util.IabHelper$5.run(IabHelper.java:585)
	at java.lang.Thread.run(Thread.java:784)

failure while building

There is an error while I'm trying to build BazaarIAB.jar file.

  • What went wrong:
    A problem was found with the configuration of task ':lint' (type 'LintGlobalTask').

No value has been specified for property 'lintClassPath'.

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.

I would be happy if you help me with this issue.

having androidManifest causes crash on app start

hi.
i just started using your plugin.
when i have androidManifest like you have in your example, app craashes on start and when i remove it i receive this error:
java.lang.SecurityException: Not allowed to bind to service Inten

List.isEmpty() in init function

hi im getting this error :

AndroidJavaException: java.lang.NullPointerException: Attempt to invoke interface method 'boolean java.util.List.isEmpty()' on a null object reference java.lang.NullPointerException: Attempt to invoke interface method 'boolean java.util.List.isEmpty()' on a null object reference com.bazaar.util.IabHelper.startSetup(IabHelper.java:267) com.bazaar.BazaarIABPlugin.init(BazaarIABPlugin.java:59) com.unity3d.player.UnityPlayer.nativeRender(Native Method) com.unity3d.player.UnityPlayer.c(Unknown Source) com.unity3d.player.UnityPlayer$d$2.queueIdle(Unknown Source) android.os.MessageQueue.next(MessageQueue.java:211) android.os.Looper.loop(Looper.java:122) com.unity3d.player.UnityPlayer$d.run(Unknown Source) UnityEngine.AndroidJNISafe.CheckException () UnityEngine.AndroidJNISafe.CallVoidMethod (IntPtr obj, IntPtr methodID, UnityEngine.jvalue[] args) UnityEngine.AndroidJavaObject._Call (System.String methodName, System.Object[] args) UnityEngine.AndroidJavaObject.Call (System.String methodName, System.Object[] args) BazaarPlugin.BazaarIAB.init (System.String publicKey) IAPManager.OnEnable ()

مشکل در اندروید 10

موقع فراخوانی تابع
init()
اونت هیچ نتیجه ای برنمیگردونه.مگر اینکه قبلش یکبار برنامه بازار باز شده باشه.

queryInventorySucceededEvent()

سلام من اولین بار دارم از این پلاگین استفاده می کنم.
مشکل من اینه محصولاتی که خریده شده چه مصرفی و چه غیر مصرفی اطلاعاتش رو میشه با تابع زیر
void queryInventorySucceededEvent(List<BazaarPurchase> purchases, List<BazaarSkuInfo> skus)
بدست آورد.
.هستش purchases.count = 0 ولی همیشه

queryInventory Return Empty List

Hi

queryInventory(string[] skus) Return Empty List[BazaarPurchase] .
I saw this malfunction in Unity plugin, but I saw it in React Native (Native android) too before.
I think the problem is on CafeBazaar App ( server ) Side.

*** other functions work just fine

please let me know your opinion.
thanks.

پیشنهاد

دوتا پیشنهاد دارم برای اضافه کردن به اس دی کی که میتونم در پاره وقت انجام بدم در صورت استقبال شما فورک میگیرم برای کار

اول ارسال ایمیل به توسعه دهنده در زمان خرید ها که به احتیاج می باشد و برای کسانی که بک اند ندارند کاربرد دارد

دوم ساخت بک اند ذخیره سازی که به دو بخش
اولی ساخت سرور ساید برای ذخیره
دوم ساخت اس دی کی برای ذخیره اطلاعات
به نظرم این دوتا بخش اضافه بشه خیلی کمک میکنه

None of the events triggers

I built an APK and unfortunately none of the events triggers, even for init(neither supported nor not supported). Even the Demo Scene in the package is not working. What should I do?
Thanks in advance

Purchase signature verification failed

سلام .
یه مشکل اساسی وجود داره و اون اینه که موقع خرید یه محصول با قیمت صفر ( محصول آزمایشی ) ، signature محصول invalid میشه و در نتیجه query inventory با خطای Purchase signature verification failed مواجه میشه . در واقع بعد از خرید یه محصول آزمایشی با قیمت صفر پلاگین دیگه به درستی کار نمیکنه و هر دفعه موقع فراخوانی متود query inventory با خطای فوق مواجه میشیم. بعد از این اتفاق محصول رو مجددا نمیشه خریداری کرد چون محصول قبلا خریداری شده . همچنین نمیشه مصرفش کرد چون queryInventory با خطا مواجه شده و signature خرید Invalid هست .

Null data in IAB result

سلام
پس از فراخوانی تابع purchase این خطا را می دهد

purchaseFailedEvent: Null data in IAB result (response: -1002:Bad response received)

این مشکل بر روی گوشی های شیائومی وجود دارد
ولی در مدل های هواوی به درستی اجرا می شود

کرش پروژه نمونه

با عرض سلام و خسته نباشید
پروژه نمونه ای که خودتون گذاشتین رو با یونیتی 2019.1.3 خروجی گرفتم به محض باز کردن برنامه تو گوشی کرش میکنه

NullPointerException on unity 2019.2.11f1

Hi,
first of all tnx for this great SDK, but since unity version 2019.2.11f1 it crashes, error log:

11-09 17:11:20.139 522 569 E ANDR-PERF-MPCTL: Invalid profile no. 0, total profiles 0 only
11-09 17:11:20.248 5301 5362 E Unity : AndroidJavaException: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.lang.Class.getName()' on a null object reference
11-09 17:11:20.248 5301 5362 E Unity : java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.lang.Class.getName()' on a null object reference
11-09 17:11:20.248 5301 5362 E Unity : at com.unity3d.player.ReflectionHelper.getMethodID(Unknown Source:168)
11-09 17:11:20.248 5301 5362 E Unity : at com.unity3d.player.UnityPlayer.nativeRender(Native Method)
11-09 17:11:20.248 5301 5362 E Unity : at com.unity3d.player.UnityPlayer.c(Unknown Source:0)
11-09 17:11:20.248 5301 5362 E Unity : at com.unity3d.player.UnityPlayer$e$1.handleMessage(Unknown Source:95)
11-09 17:11:20.248 5301 5362 E Unity : at android.os.Handler.dispatchMessage(Handler.java:103)
11-09 17:11:20.248 5301 5362 E Unity : at android.os.Looper.loop(Looper.java:214)
11-09 17:11:20.248 5301 5362 E Unity : at com.unity3d.player.UnityPlayer$e.run(Unknown Source:20)
11-09 17:11:20.248 5301 5362 E Unity : at UnityEngine._AndroidJNIHelper.GetMethodID (System.IntPtr jclass, System.String methodName, System.String signature, System.Boolean isStatic) [0x00041] in <157db3d40e194fc2b8370dbe68a88be2>:0
11-09 17:11:20.248 5301 5362 E Unity : at UnityEngine.AndroidJNIHelper.GetMethodID (System.IntPtr javaClass, System.String methodName, System.St

Issue With MIUI

Hi guys
im a game developer and for my last project i use this plugin, unfortunately this version has bug with miui on xiaomi devices such as my mi9 and other models...
if in app settings of cafe bazar i enable display pop_up windows while running in the background then IAP perfectly work.
but with default settings of pop_up windows while running in the background of cafe bazar app, some other games such as pesar khande work prefectly!

i cafe bazar dosumention i read :
" نکته: این سند در تاریخ ۱۳۹۹/۱۲/۳ به روز شده و نسخه جدید برای حل مشکلات بر روی دستگاه‌های شیائومی جایگزین شده است. "

but in my test this not work!
hope you help me.

List.isEmpty() in init function

hi im getting this error in our game crash reporting tool :

AndroidJavaException: java.lang.NullPointerException: Attempt to invoke interface method 'boolean java.util.List.isEmpty()' on a null object reference java.lang.NullPointerException: Attempt to invoke interface method 'boolean java.util.List.isEmpty()' on a null object reference com.bazaar.util.IabHelper.startSetup(IabHelper.java:267) com.bazaar.BazaarIABPlugin.init(BazaarIABPlugin.java:59) com.unity3d.player.UnityPlayer.nativeRender(Native Method) com.unity3d.player.UnityPlayer.c(Unknown Source) com.unity3d.player.UnityPlayer$d$2.queueIdle(Unknown Source) android.os.MessageQueue.next(MessageQueue.java:211) android.os.Looper.loop(Looper.java:122) com.unity3d.player.UnityPlayer$d.run(Unknown Source) UnityEngine.AndroidJNISafe.CheckException () UnityEngine.AndroidJNISafe.CallVoidMethod (IntPtr obj, IntPtr methodID, UnityEngine.jvalue[] args) UnityEngine.AndroidJavaObject._Call (System.String methodName, System.Object[] args) UnityEngine.AndroidJavaObject.Call (System.String methodName, System.Object[] args) BazaarPlugin.BazaarIAB.init (System.String publicKey) IAPManager.OnEnable ()

do you have any idea what might cause this?
and how to prevent it?

thanks in advance

Invoke function in ActionExtensions cause error for non unity classes

At this line developers are forced to use non-static functions from classes that inherit from UnityEngine.Object, I have worked with several teams that experienced an issue with this policy.
I guess these constraints are implemented for making sure resources are released at the end of the application life cycle. This decision can be handed to the developer.
I've removed this line for some projects and they still work properly.
Is there any other concern behind this constraint?

Init problem

I build an apk using this repo sample with unity version 2019.2.10f1. Even your sample doesn't start up IabHelper. And problem is here that any of billing event either supported or not supported doesn't trigger.
Can some one help me??

کرش کردن گهگاه بازی در هنگام اینیت شدن پرداخت کافه بازار

سلام

Error AndroidRuntime java.lang.NullPointerException: Attempt to invoke virtual method 'void com.bazaar.util.IAB.isBillingSupported(int, java.lang.String, com.bazaar.util.communication.BillingSupportCommunication)' on a null object reference

at com.bazaar.util.IabHelper.checkBillingSupported(IabHelper.java:209)
at com.bazaar.util.IabHelper.access$000(IabHelper.java:63)
at com.bazaar.util.IabHelper$1.connected(IabHelper.java:184)
at com.bazaar.util.ServiceIAB$1.onServiceConnected(ServiceIAB.java:70)

سلام
من گهگاهی با این خطا در یکی از بازی ها مواجه میشم

این خط خطا میدهد.
NullPointerException
checkBillingSupported(IabHelper.java:209)
دلیلش چه چیزی هستش؟؟

دلیلش رو متوجه نمیشم با اینکه از خود کتابخونه کافه بازار استفاده میکنم و هنگام خروج

هم انجام میدم unbindService()

بنظر بیشتر در اندروید 7 و 8 پیش اومده

IL2CPP problem?

سلام و عرض ادب ...
بنظر میرسه این پلاگین تحت
IL2CPP
روی یونیتی 2019.3 اصلا کار نمیده!

پیشنهاد چی هست؟
ممنون.

Fatal Error and Crash

سلام با تشکر از شما بابت گردآوری این پلاگین.

ریپورت‌های کرشی را دریافت می‌کنیم از سمت پلاگین ، شما ایده ای دارید چرا این اتفاق می افته؟

java.lang.Error: FATAL EXCEPTION [Thread-214] Unity version : 2019.2.19f1 Device model : HUAWEI DRA-LX5 Device fingerprint: HUAWEI/DRA-LX5/HWDRA-MG:8.1.0/HUAWEIDRA-LX5/1.0.0.136(C185):user/release-keys Caused by at com.bazaar.util.IabHelper.queryPurchases (IabHelper.java:986) at com.bazaar.util.IabHelper$4.run (IabHelper.java:752) at java.lang.Thread.run (Thread.java:780)

بیشتر روی اندروید های 8.1 و 9 اتفاق می افته.

not clear!!!!

salam chera hich tozihi baraye shoro'e kar ba in file ha nadadid?!
masalan inke che folder ya file ro bayad be proje unity khodemoon ezafe konim!!!
ba tavajoh be inke hich file ba pasvand .unitypackage ham dar folderha mojood nist.

java.lang.NullPointerException error

Hi,
The SDK works fine but we have this error on our analytics:

java.lang.NullPointerException
at com.bazaar.util.IabHelper.queryPurchases(IabHelper.java:986)
at com.bazaar.util.IabHelper.queryInventory(IabHelper.java:544)
at com.bazaar.util.IabHelper.queryInventory(IabHelper.java:522)
at com.bazaar.util.IabHelper$2.run(IabHelper.java:617)
at java.lang.Thread.run(Thread.java:841)

what can we do about it?

مشکل نصب کافه بازار بعد از اپ

سلام خسته نباشید. وقتی بعد از نصب اپی که پلاگین شما روشه کافه بازار نصب بشه پلاگین شما این ارور رو میده:
AndroidJavaException: java.lang.SecurityException: Not allowed to bind to service Intent { act=ir.cafebazaar.pardakht.InAppBillingService.BIND pkg=com.farsitel.bazaar launchParam=MultiScreenLaunchParams { mDisplayId=0 mBaseDisplayId=0 mFlags=0 } }
09-23 19:22:09.266 8927 9268 E Unity : java.lang.SecurityException: Not allowed to bind to service Intent { act=ir.cafebazaar.pardakht.InAppBillingService.BIND pkg=com.farsitel.bazaar launchParam=MultiScreenLaunchParams { mDisplayId=0 mBaseDisplayId=0 mFlags=0 } }

Null data in IAB result (response: -1002:Bad response received)

سلام.

موقع خرید از بازار این مشکل رو به صورت پراکنده روی درصد خیلی کمی از دیوایس های کاربران داره بهمون گزارش میشه.

کسی میدونه مشکل از چیه؟

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.