Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
1
Question by Jonapulse · Jan 07, 2016 at 03:03 AM · androidiosinapp purchase

Unity Services In-App Purchases: How to check if a user has bought a non-consumable product

I've recently activated in-app purchases (for Android and iOS) through Unity Services and walked through their tutorial (http://unity3d.com/learn/tutorials/topics/analytics/integrating-unity-iap-your-game-beta?playlist=17123). Though it describes how consumable objects might be purchased, I'm not sure what to do with a non-consumable purchase.

I want to be able to communicate with the store when the user opens the game and find out which non-consumables they've purchased. Does Unity Services have a function for that? I could save the non-consumable purchase in PlayerPrefs right after user purchases clear, but PlayerPrefs doesn't seem secure.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

4 Replies

· Add your reply
  • Sort: 
avatar image
3

Answer by Banderous · Feb 08, 2016 at 01:02 PM

To counter local IAP fraud you should use local receipt validation; you can validate the receipts Google Play gives you for each product (as in @Jabbah76's code above) or on Apple platforms you can validate and parse the App receipt to determine all the non-Consumables the user is entitled to.

We are working on a receipt validation library to assist with this, initially for Google Play and Apple stores. This will be shipped in a forthcoming update to our IAP store implementations, installable from the Editor IAP cloud service window.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
2

Answer by Jabbah76 · Jan 15, 2016 at 11:27 AM

I just came across the same issue. I haven't tested it yet, but I think it can be done using the following code:

 Product product = storeController.products.WithID(productId);
 if (product != null && product.hasReceipt)
 {
     // Owned Non Consumables and Subscriptions should always have receipts.
     // So here the Non Consumable product has already been bought.
     itemBought = true;
 }
Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image AndrewRyan · Nov 22, 2017 at 03:25 PM 0
Share

In my experience—at least in the editor—the user retains a receipt after processing a restore or refund for an item. Is this true or is this only an editor thing?

avatar image PuzzleBuilder · May 28, 2018 at 02:34 AM 1
Share

This code appears to work when I run it in the Unity editor, but when I have one of my testers download the alpha, it doesn't always work. When they close and reopen the app, the above code is run to see if they still have the receipt, but for some reason it isn't working. The app works correctly when they first run it after an install, but stops working after closing it and re-opening. Is the storeController never initialized when they open it the second time, leading to a null pointer? Am I using this code for the right purpose? Has anyone else got it to work?

avatar image
1

Answer by hawkzey · May 15, 2017 at 01:13 AM

You feel like you need to do something extra to perform the enabling of already purchased items but you don't.

When the app is deleted and downloaded or downloaded on a new phone, the IAP's back end process will call the ProcessPurchase Function you have specified from the IStoreListener class on each item being restored(this is saved internally on each players google account). So what ever code was executed for when the player originally bought the item is executed again, there for re-enabling it.

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image hawkzey · May 15, 2017 at 01:22 AM 0
Share

I would also like to inform that Consumable products have to be managed them selves as the app store does not keep track of if the player has purchased such things.

avatar image PuzzleBuilder · May 26, 2018 at 12:53 AM 1
Share

$$anonymous$$y app recovers the correct state when it's re-installed, as you say, but when it's simply closed and re-opened, the game state resets, and the new "pro" features are gone. The pro features are enabled whenever the purchase is made, or the app is re-installed, but I need to make the game state persist after the game is closed. Is there a function I can call when the game starts that performs the same actions as when it's reinstalled? $$anonymous$$aybe I'll try what Jabbah76 suggests above.

avatar image
0

Answer by jacshon121 · Mar 01, 2018 at 09:47 AM

Here is how to View the Windows Store Purchase History

1- Launch Windows Store application directly by clicking on the Store icon or you can alternatively search for Store in the search box and launch it. 2- Wait while the store picks itself up and launches. 3- Now from the top portion of the Windows Store window, find your profile picture and click on it. If you haven’t set any profile picture, it will be the classic profile icon instead of your picture. A menu gets expanded out. Find Purchased option from the menu and click on. 4- Now you will be redirected to the Microsoft sign in page. You have to enter your Microsoft account credentials and click on the Sign in button when you are ready, to view your store purchase history. 5- Under the Payment & Billing tab, you can view your Windows Store purchase history. Look for a drop down menu that says View from. You can select the time period of the purchase history that you want to see, from this drop down menu. Once you are all set, click on search button. You can now view the purchased items along with their dates of purchases, the modes of payment and the amount that you have paid for every single item from the search results.

Source:- https://merabheja.com/view-windows-store-purchase-history/

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

52 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

IStoreListener Purchase vs Restore on Android and iOS 0 Answers

ios memory is much higher than android memory. 0 Answers

Namespace Gamecenter not found on Unity 2017.2 1 Answer

Read and save current git commit hash into script 1 Answer

[IAP] IOs Consumable pending when closing app during purchase 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges