Git repository: https://github.com/Omnilatent/OmniInAppPurchaseHelper
- Unity In App Purchasing 4.4.1.
- Unity Services Core 1.4.0.
Setup Unity IAP:
- Follow steps in: https://learn.unity.com/tutorial/unity-iap#:~:text=Adding%20the%20IAP%20Package until you complete the step "Adding the IAP Package". Do not write any script yet.
- Setup IAP Receipt Validation Obfuscator following this guide: https://docs.unity3d.com/Manual/UnityIAPValidatingReceipts.html.
- If you followed Google's guide and get a duplicate aar error, delete the billing 3.0.1 aar file
Prepare IAP Products:
- Google Play Store:
- Build an APK to upload to Google Play alpha build.
- Create IAP product in Google Play Console.
- Apple App Store: (Support Coming soon)
Setup in Unity project:
- Add a gameObject with component InAppPurchaseHelper in your first scene.
- Import Extra files: Go to Tools/Omnilatent/IAP Helper/Import Extra Package.
- Modify HandleIAPEvent (in Assets/Omnilatent/Extra/IAPHelperExtra/HandleIAPEvent.cs):
- In PayoutPurchase(), handle what will happens when user successfully purchase a product. You can check payout's type and subtype.
- In OnPurchaseComplete(), a placeholder message popup is shown when purchase is successful, modify this behaviour to your need.
- Create IAPProductData Scriptable Objects with correspond name to every products in folder "Resources/ProductData".
- Setup payout for each IAPProductData you created.
- Make sure an Assembly Definition Reference to "Omnilatent.InAppPurchaseHelper" exist in the same folder as the "Tangle" class generated by IAP Receipt Validation Obfuscator.
Buying product: InAppPurchaseHelper.Instance.BuyProduct(productId, onPurchaseComplete).
Adding remove ads:
- Make Product on Google Play Console
- Add all remove ads product to removeAdsProducts list in InAppPurchaseHelper. It'll check for remove ads on initiation.
- Use InAppPurchaseHelper.BuyProduct(string productId, PurchaseCompleteDelegate purchaseCompleteDelegate) to initiate purchasing process.
- Add HandleIAPEvent class to your project:
Get & display product's price with currency symbol: use component ProductPriceText.
Checking user's ownership of product: use InAppPurchaseHelper.CheckReceipt(productId).
InitializePurchasing:
- All IAPProductData in Resources/ProductData will be loaded and added by ConfigurationBuilder.
Example: [Updated] Extra script is now included in Extra package
- A message should be displayed in purchaseCompleteDelegate's code to announce purchase result.