{"id":21051730,"url":"https://github.com/unity-package/in-app-purchasing-unity","last_synced_at":"2025-05-15T21:36:10.552Z","repository":{"id":246347984,"uuid":"820694725","full_name":"wolf-org/in-app-purchasing-unity","owner":"wolf-org","description":"Support Unity IAP ","archived":false,"fork":false,"pushed_at":"2024-08-27T09:17:55.000Z","size":87,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2024-08-28T09:43:20.586Z","etag":null,"topics":["iap","in-app-purchase","unity"],"latest_commit_sha":null,"homepage":"","language":"C#","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/wolf-org.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-06-27T02:04:26.000Z","updated_at":"2024-08-27T09:16:55.000Z","dependencies_parsed_at":"2024-06-27T15:16:52.205Z","dependency_job_id":"c213e812-0bfc-4f2c-8592-bf56c5db6984","html_url":"https://github.com/wolf-org/in-app-purchasing-unity","commit_stats":null,"previous_names":["wolf-package/in-app-purchasing","wolf-package/in-app-purchasing-unity","wolf-org/in-app-purchasing-unity"],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wolf-org%2Fin-app-purchasing-unity","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wolf-org%2Fin-app-purchasing-unity/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wolf-org%2Fin-app-purchasing-unity/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wolf-org%2Fin-app-purchasing-unity/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wolf-org","download_url":"https://codeload.github.com/wolf-org/in-app-purchasing-unity/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225384352,"owners_count":17465879,"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":["iap","in-app-purchase","unity"],"created_at":"2024-11-19T15:59:34.207Z","updated_at":"2025-05-15T21:36:10.541Z","avatar_url":"https://github.com/wolf-org.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"left\"\u003e\n  \u003ca\u003e\n    \u003cimg alt=\"Made With Unity\" src=\"https://img.shields.io/badge/made%20with-Unity-57b9d3.svg?logo=Unity\"\u003e\n  \u003c/a\u003e\n  \u003ca\u003e\n    \u003cimg alt=\"License\" src=\"https://img.shields.io/github/license/unity-package/in-app-purchasing-unity?logo=github\"\u003e\n  \u003c/a\u003e\n  \u003ca\u003e\n    \u003cimg alt=\"Last Commit\" src=\"https://img.shields.io/github/last-commit/unity-package/in-app-purchasing-unity?logo=Mapbox\u0026color=orange\"\u003e\n  \u003c/a\u003e\n  \u003ca\u003e\n    \u003cimg alt=\"Repo Size\" src=\"https://img.shields.io/github/repo-size/unity-package/in-app-purchasing-unity?logo=VirtualBox\"\u003e\n  \u003c/a\u003e\n  \u003ca\u003e\n    \u003cimg alt=\"Last Release\" src=\"https://img.shields.io/github/v/release/unity-package/in-app-purchasing-unity?include_prereleases\u0026logo=Dropbox\u0026color=yellow\"\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\n## What\n### In-app-purchase support tool for unity games (Unity 2022.3)\n\n## How To Install\n\n### Add the line below to `Packages/manifest.json`\n\nfor version `1.0.8`\n```json\n\"com.wolf-org.in-app-purchasing\":\"https://github.com/unity-package/in-app-purchasing-unity.git#1.0.8\",\n```\ndependency `extensions-unity-1.0.5`\n```json\n\"com.wolf-org.extensions\":\"https://github.com/unity-package/extensions-unity.git#1.0.5\",\n```\n\n## Use\n\n### Setup\n- Use via MenuItem `Unity-Common` \u003e `IapSettings` or shortcut `Ctrl + W / Command + W` to open `IapSettings`\n\n![Unity_BVkNMfm6fL](https://github.com/wolf-package/in-app-purchasing/assets/102142404/798a790c-c988-48c5-8b32-e88dab94a594)\n\n\n- If you select `Runtime Auto Init` in `IapSettings` then `IapManager` will be created automatically after loading the scene. Otherwise you will have to attach `IapManager` to the scene to ensure purchases can be made\n- Add data product to list (enter id and select product type), then click `Generate Product`\n- Select `Validate Product` and enter `Google Play Store Key`, then click `Obfuscator Key`\n- Don't forget add Define Symbol `VIRTUESKY_IAP`\n\n- After clicking `Generate Product`, an `IapProduct.cs` script is generated in the following format\n\n```csharp\n\n        public static class IapProduct\n\t{\n\t    public const string ID_REMOVEADS = \"com.test.removeads\";\n\t    public static IapDataProduct PurchaseRemoveads()\n\t    {\n\t\treturn IapManager.PurchaseProduct(IapSettings.Instance.IapDataProducts[0]);\n\t    }\n\n\t    public static bool IsPurchasedRemoveads()\n\t    {\n\t\treturn IapManager.IsPurchasedProduct(IapSettings.Instance.IapDataProducts[0]);\n\t    }\n\n\t    public const string ID_1000GEM = \"com.test.1000gem\";\n\t    public static IapDataProduct Purchase1000Gem()\n\t    {\n\t\t\treturn IapManager.PurchaseProduct(IapSettings.Instance.IapDataProducts[1]);\n\t    }\n\n\t    public static bool IsPurchased1000Gem()\n\t    {\n\t\treturn IapManager.IsPurchasedProduct(IapSettings.Instance.IapDataProducts[1]);\n\t    }\n\n\t}\n\n```\n\n### Handle purchase product\n- Example 1:\n```csharp\n        public Button buttonRemoveAds;\n        /// \u003csummary\u003e\n        /// refresh ui button remove ads\n        /// disable buttonRemoveAds if RemoveAds product has been purchased\n        /// \u003c/summary\u003e\n        void RefreshUI()\n        {\n            buttonRemoveAds.gameObject.SetActive(!IapProduct.IsPurchasedRemoveads());\n        }\n\n        /// \u003csummary\u003e\n        /// Buy remove ads iap\n        /// \u003c/summary\u003e\n        public void OnClickRemoveAds()\n        {\n            IapProduct.PurchaseRemoveads().OnCompleted(() =\u003e\n            {\n                // handle purchase success\n                RefreshUI();\n            }).OnFailed(() =\u003e\n            {\n                // handle purchase failed\n            });\n        }\n\n```\n- Example 2: You create a new script similar to the demo below. then attach it to LoadingScene\n\n```csharp\n\npublic class HandlePurchaseIap : MonoBehaviour\n{\n    private void Awake()\n    {\n        DontDestroyOnLoad(this.gameObject);\n        IapManager.OnPurchaseSucceedEvent += HandlePurchaseSuccess;\n        IapManager.OnPurchaseFailedEvent += HandlePurchaseFailed;\n    }\n\n    void HandlePurchaseSuccess(string id)\n    {\n        switch (id)\n        {\n            case IapProduct.ID_REMOVEADS:\n                // handle\n                break;\n            case IapProduct.ID_1000GEM:\n                // handle\n                break;\n        }\n    }\n\n    void HandlePurchaseFailed(string id)\n    {\n        switch (id)\n        {\n            case IapProduct.ID_REMOVEADS:\n                // handle\n                break;\n            case IapProduct.ID_1000GEM:\n                // handle\n                break;\n        }\n    }\n}\n\n```\n\n- Note: Example 1 is typically used to handle the user interface after a successful or failed purchase and cannot handle restore purchase. Therefore, you should use example 2 to handle logic for tasks such as removing ads, unlocking skins,...\n\n- Check to see if the product has been purchased (only applies to Non-Consumable items)\n```csharp\n\n    public Button buttonRemoveAds;\n\n    private void OnEnable()\n    {\n        if (IapProduct.IsPurchasedRemoveads())\n        {\n            buttonRemoveAds.gameObject.SetActive(false);\n        }\n    }\n\n```\n### Restore purchase\nRestore purchase only applies to Non-Consumable items\n\nRestore Purchase is a mandatory feature on iOS to be able to be released to the store.\n\nOn Android when you successfully purchased RemoveAds. Then you uninstall your game and reinstall it. If you click buy remove ads again, google play system will report that you already own this item and can't buy it again, now the user has removed ads but the game still displays ads (incorrect). We will need to handle restore purchase of the user's purchased items so that the user avoids this situation.\n\nOn Android restore purchase will be called automatically when you reinstall the game via method `ConfirmPendingPurchase` call in `OnInitialized`. On ios you will need to create a restore purchase button for the user to click\n\nWhen the restore is successful, it will automatically call the successful purchase callback of each item for further processing for the user\n\n```csharp\n\n    public void OnClickRestorePurchase()\n    {\n#if UNITY_IOS\n        IapManager.RestorePurchase();\n#endif\n    }\n\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Funity-package%2Fin-app-purchasing-unity","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Funity-package%2Fin-app-purchasing-unity","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Funity-package%2Fin-app-purchasing-unity/lists"}