• 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
Question by hungnt-kayac · Oct 14, 2016 at 01:58 AM · iosinapp purchase

Unity IAP: product.hasReceipt alway return false with non-consumable product after restarting app on iOS

Hi guys. I'm working with Unity IAP plugin. When app starting, i want to check a non-consumable product was bought or not. This is the code i used:

 public bool IsPurchased (string productID)
     {
         Product product = m_StoreController.products.WithID (productID);
         if (product != null && product.hasReceipt) {
             return true;
         }
         return false;
     }

Even i have already bought a non-consumable one but the product.hasReceipt alway return false on iOS platform (sandbox). I expected it should alway return true as i bought a non-consumable product. Somebody tell me why? Thank you in advance.

Comment
nubick
Nick62

People who like this

2 Show 0
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

2 Replies

· Add your reply
  • Sort: 
avatar image

Answer by hungnt-kayac · Oct 14, 2016 at 07:16 AM

I found a solution to work around this problem by using apple receipt. This is the snip code i use. Hope it can help you guys

 var builder = ConfigurationBuilder.Instance (StandardPurchasingModule.Instance ());
 var receiptData = Convert.FromBase64String (builder.Configure<IAppleConfiguration> ().appReceipt);
 var receipt = new AppleValidator (AppleTangle.Data ()).Validate (receiptData);
 foreach (AppleInAppPurchaseReceipt productReceipt in receipt.inAppPurchaseReceipts) {
                 if (productReceipt.productID.Equals (productID)) {
                     return true;
                 }
             }
             return false;

I still don't understand why product.hasReceipt return false :(

Comment
nubick

People who like this

1 Show 1 · 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 peter_kes · Apr 05, 2017 at 07:31 AM 0
Share

var receiptData = Convert.FromBase64String (builder.Configure ().appReceipt); return "This is a fake receipt. When running on an apple store, a base64 encoded App Receipt would be ... " and throw FormatException. I need to test IAP before the app is on Appstore. what should I do???

avatar image

Answer by Guillaumzed · Mar 25, 2017 at 07:59 PM

Thanks a lot.

Comment

People who like this

0 Show 0 · 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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

92 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 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

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

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

How to enable "Double Click to Pay" feature in Unity IAP on iOS devices? 0 Answers

Integrating apple IAP 0 Answers

Unable to restore transactions in iOS 9.2.1 using openIAB plugin. 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