{"id":18750731,"url":"https://github.com/cafebazaar/cafebazaarunity","last_synced_at":"2025-04-12T23:32:29.696Z","repository":{"id":47259810,"uuid":"123108633","full_name":"cafebazaar/CafebazaarUnity","owner":"cafebazaar","description":"Cafebazaar In-app purchase Unity plugin","archived":false,"fork":false,"pushed_at":"2023-08-21T15:02:08.000Z","size":372,"stargazers_count":23,"open_issues_count":11,"forks_count":16,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-26T18:06:36.761Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cafebazaar.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-02-27T09:53:11.000Z","updated_at":"2024-03-23T15:04:43.000Z","dependencies_parsed_at":"2022-08-28T16:10:59.094Z","dependency_job_id":null,"html_url":"https://github.com/cafebazaar/CafebazaarUnity","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cafebazaar%2FCafebazaarUnity","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cafebazaar%2FCafebazaarUnity/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cafebazaar%2FCafebazaarUnity/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cafebazaar%2FCafebazaarUnity/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cafebazaar","download_url":"https://codeload.github.com/cafebazaar/CafebazaarUnity/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248647258,"owners_count":21139081,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-07T17:12:56.102Z","updated_at":"2025-04-12T23:32:26.466Z","avatar_url":"https://github.com/cafebazaar.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"\r\n# CafebazaarUnity\r\nCafebazaar In-app purchase Unity plugin\r\n\r\n\r\n## BUILD INSTRUCTION\r\nTo build `BazaarIAB.jar` from the java source code:\r\n1. Open a command prompt\r\n2. Navigate to JavaPlugin folder\r\n3. Type `gradlew createJar`\r\n4. After the build is succeeded you can find `BazaarIAB.jar` in the build folder\r\n\r\n\r\n## INSIDE UNITY PROJECT\r\nThis plugin has not any prefab to use, it will manage the required objects.\r\n\r\nThe `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.\r\n\r\nThis 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.\r\n\r\nThere is `IABEventManager` class that you can subscribe to all plugin events.\r\n\r\nAfter 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.\r\n\r\nAdd the plugin activity in the Application section of the `AndroidManifest.xml`:\r\n\r\n\t\u003cmeta-data android:name=\"billing.service\" android:value=\"bazaar.BazaarIabService\" /\u003e\r\n\t\u003cactivity android:name=\"com.bazaar.BazaarIABProxyActivity\" android:theme=\"@android:style/Theme.Translucent.NoTitleBar.Fullscreen\" /\u003e\r\n\t\r\nAlso add the required permissions to your manifest:\r\n\r\n\t\u003cuses-permission android:name=\"android.permission.INTERNET\" /\u003e\r\n\t\u003cuses-permission android:name=\"com.farsitel.bazaar.permission.PAY_THROUGH_BAZAAR\" /\u003e\r\n\r\n# Methods\t\r\nMethods are inside `BazaarIAB` class.\r\n```\tcsharp\r\n// Initializes the billing system\r\npublic static void init(string publicKey)\r\n\r\n// Get current version of plugin\r\npublic static string GetVersion()\r\n\r\n// Toggles high detail logging on/off\r\npublic static void enableLogging(bool shouldEnable)\r\n\r\n// Unbinds and shuts down the billing service\r\npublic static void unbindService()\r\n\r\n// Returns whether subscriptions are supported on the current device\r\npublic static bool areSubscriptionsSupported()\r\n\r\n// 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)\r\npublic static void queryInventory(string[] skus)\r\n\r\n// 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)\r\npublic static void querySkuDetails(string[] skus)\r\n\r\n// Sends a request to get all completed purchases (requires user to be logged in otherwise you will get error)\r\npublic static void queryPurchases()\r\n\r\n// Sends out a request to purchase the product\r\npublic static void purchaseProduct(string sku)\r\npublic static void purchaseProduct(string sku, string developerPayload)\r\n\r\n// Sends out a request to consume the product\r\npublic static void consumeProduct(string sku)\r\n// Sends out a request to consume all of the provided products\r\npublic static void consumeProducts(string[] skus)\r\n```\r\n\r\n# Events\r\nYou can access events from `IABEventManager` class.\r\n```csharp\r\n\r\n// Fired after init is called when billing is supported on the device\r\npublic static event Action billingSupportedEvent;\r\n// Fired after init is called when billing is not supported on the device\r\npublic static event Action\u003cstring\u003e billingNotSupportedEvent;\r\n\r\n// Fired when the inventory and purchase history query has returned\r\npublic static event Action\u003cList\u003cBazaarPurchase\u003e,List\u003cBazaarSkuInfo\u003e\u003e queryInventorySucceededEvent;\r\n// Fired when the inventory and purchase history query fails\r\npublic static event Action\u003cstring\u003e queryInventoryFailedEvent;\r\n\r\n// Fired when the SkuDetails query has returned\r\npublic static event Action\u003cList\u003cBazaarSkuInfo\u003e\u003e querySkuDetailsSucceededEvent;\r\n// Fired when the SkuDetails query fails\r\npublic static event Action\u003cstring\u003e querySkuDetailsFailedEvent;\r\n\r\n// Fired when the purchase history query has returned\r\npublic static event Action\u003cList\u003cBazaarPurchase\u003e\u003e queryPurchasesSucceededEvent;\r\n// Fired when the purchase history query fails\r\npublic static event Action\u003cstring\u003e queryPurchasesFailedEvent;\r\n\r\n// Fired when a purchase succeeds\r\npublic static event Action\u003cBazaarPurchase\u003e purchaseSucceededEvent;\r\n// Fired when a purchase fails\r\npublic static event Action\u003cstring\u003e purchaseFailedEvent;\r\n\r\n// Fired when a call to consume a product succeeds\r\npublic static event Action\u003cBazaarPurchase\u003e consumePurchaseSucceededEvent;\r\n// Fired when a call to consume a product fails\r\npublic static event Action\u003cstring\u003e consumePurchaseFailedEvent;\r\n\r\n```\r\n\r\n# Thanks\r\n- [mohsen-srn](https://github.com/mohsen-srn) for pointing out the AndroidManifest.xml issue in newer Unity versions.\r\n- [Hossynkoala](https://github.com/Hossynkoala) for fixing white keyboard issue in AndroidManifest.\r\n- [Mahdad-Baghani](https://github.com/Mahdad-Baghani) help with finding nullReference exception in Unity 2019.3.0f3.\r\n- [AhM0D](https://github.com/AhM0D) fixed a crash when there is no Cafebazaar app installed on older devices.\r\n\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcafebazaar%2Fcafebazaarunity","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcafebazaar%2Fcafebazaarunity","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcafebazaar%2Fcafebazaarunity/lists"}