|
||
---|---|---|
.. | ||
.sample.json | ||
LocalReceiptValidation.cs | ||
LocalReceiptValidation.cs.meta | ||
LocalReceiptValidation.unity | ||
LocalReceiptValidation.unity.meta | ||
MissingTangleClassesWarning.cs | ||
MissingTangleClassesWarning.cs.meta | ||
README.md | ||
README.md.meta | ||
UserWarning.cs | ||
UserWarning.cs.meta |
README.md
README - In-App Purchasing Sample Scenes - Local Validation
This sample showcases how to use the cross-platform validator to do local receipt validation. The cross-platform validator supports the Google Play Store and Apple App Store.
Local validation
Important: While Unity IAP provides a local validation method, local validation is more vulnerable to fraud. Validating sensitive transactions server-side where possible is considered best practice. For more information, please see Apple and Google Play’s documentation on fraud prevention.
If the content that the user is purchasing already exists on the device, the application simply needs to make a decision about whether to unlock it.
Unity IAP provides tools to help you hide content and to validate and parse receipts through Google Play and Apple stores.
For more information, see the documentation on the topic.
Instructions to test this sample:
- Have in-app purchasing correctly configured with
the Google Play Store
or Apple App Store.
- (Alternatively) For local-only Xcode testing, follow the Apple StoreKit Testing process to set up a local StoreKit Configuration.
- Set your own product's id in
the
InAppPurchasing game object > Local Receipt Validation script > Gold Product Id field
or change theGoldProductId
value in theLocalReceiptValidation.cs
script. - This sample uses the
GooglePlayTangle
,AppleTangle
, andAppleStoreKitTestTangle
classes. To generate these classes in your project, do the following:- Get your license key from the Google Play Developer Console. (Skip this
step if you do not plan on supporting the Google Play Store)
- Select your app from the list.
- Go to "Monetization setup" under "Monetize".
- Copy the key from the "Licensing" section.
- Open the obfuscation window from
Services > In-App Purchasing > Receipt Validation Obfuscator
. - Paste your Google Play key. (Skip this step if you do not plan on supporting the Google Play Store)
- Obfuscate the key. (Creates
GooglePlayTangle
,AppleTangle
, andAppleStoreKitTestTangle
classes in your project.) - (Optional) To ensure correct revenue data, enter your key in the Analytics dashboard.
- Get your license key from the Google Play Developer Console. (Skip this
step if you do not plan on supporting the Google Play Store)
- Add the sample scene to the build settings in the
Build Settings
window - Build your project for
Android
*,iOS
,macOS
, ortvOS
.- (Alternatively) For local-only Apple StoreKit Testing, follow the process to assign the StoreKit Configuration to the current Scheme.