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 /
avatar image
0
Question by MSOTech · Feb 26, 2019 at 09:22 AM · servicein app purchase

Unity IAP Error: Unable to buy item (response: 7: Item Already Owned ) DuplicateTransaction

Hi,

I use Unity 2018.3 and Unity In-App Purchase in my game. I encountered this error: products that I tried to buy before but failed in the middle of the process seem like bought and I can't buy those products now because it says they are already owned.

Here is how it happens: I try to buy a consumable product. While it is being bought I close the game before the process was completed. Then the product stays as consumed because consuming the product happens at the end of the purchasing process by Unity IAP. Which means, I initialize the buying process but I don't finalize it so, Google Play sees it as bought and not consumed. When I try to buy the same item again, this time it gives me an error that I can't buy it again because the item is already owned.

This is the log file:

 03-03 15:39:09.735: I/Unity(8475): Purchasing product asychronously: 'specialpack1'
 03-03 15:39:09.735: I/Unity(8475):  
 03-03 15:39:09.735: I/Unity(8475): (Filename: ./Runtime/Export/Debug.bindings.h Line: 45)
 03-03 15:39:09.736: I/UnityIAP(8475): isUnityVrEnabled = false
 03-03 15:39:09.737: I/UnityIAP(8475): onPurchaseProduct: specialpack1
 03-03 15:39:09.737: I/UnityIAP(8475): ITEM TYPE:inapp
 03-03 15:39:09.753: I/Unity(8475): purchase({0}): specialpack1
 03-03 15:39:09.753: I/Unity(8475):  
 03-03 15:39:09.753: I/Unity(8475): (Filename: ./Runtime/Export/Debug.bindings.h Line: 45)
 03-03 15:39:09.799: I/UnityIAP(8475): Creating purchase activity
 03-03 15:39:09.799: I/UnityIAP(8475): oldSkuMetadata is null
 03-03 15:39:09.800: I/UnityIAP(8475): invoking callback
 03-03 15:39:09.800: I/UnityIAP(8475): Constructing buy intent for specialpack1, item type: inapp
 03-03 15:39:09.854: I/UnityIAP(8475): Launching buy intent for specialpack1. Request code: 999
 
 -- Note: App was closed here before the buying process was completed
 
 03-03 15:40:29.066: I/Unity(8722): Purchasing product asychronously: 'specialpack1'
 03-03 15:40:29.066: I/Unity(8722):  
 03-03 15:40:29.066: I/Unity(8722): (Filename: ./Runtime/Export/Debug.bindings.h Line: 45)
 03-03 15:40:29.083: I/UnityIAP(8722): isUnityVrEnabled = false
 03-03 15:40:29.087: I/UnityIAP(8722): onPurchaseProduct: specialpack1
 03-03 15:40:29.089: I/UnityIAP(8722): ITEM TYPE:inapp
 03-03 15:40:29.113: I/Unity(8722): purchase({0}): specialpack1
 03-03 15:40:29.113: I/Unity(8722):  
 03-03 15:40:29.113: I/Unity(8722): (Filename: ./Runtime/Export/Debug.bindings.h Line: 45)
 03-03 15:40:29.162: I/UnityIAP(8722): Creating purchase activity
 03-03 15:40:29.162: I/UnityIAP(8722): oldSkuMetadata is null
 03-03 15:40:29.163: I/UnityIAP(8722): invoking callback
 03-03 15:40:29.163: I/UnityIAP(8722): Constructing buy intent for specialpack1, item type: inapp
 03-03 15:40:29.200: I/UnityIAP(8722): onIabPurchaseFinished: false
 03-03 15:40:29.200: I/UnityIAP(8722): Unable to buy item (response: 7:Item Already Owned)
 03-03 15:40:29.200: I/UnityIAP(8722): Purchase response code:7
 03-03 15:40:29.279: I/UnityIAP(8722): onActivityResult
 03-03 15:40:29.347: I/Unity(8722): onPurchaseFailedEvent({0}): specialpack1
 03-03 15:40:29.347: I/Unity(8722):  
 03-03 15:40:29.347: I/Unity(8722): (Filename: ./Runtime/Export/Debug.bindings.h Line: 45)
 03-03 15:40:29.363: I/Unity(8722): OnPurchaseFailed: FAIL. Product: 'specialpack1', PurchaseFailureReason: DuplicateTransaction
 03-03 15:40:29.363: I/Unity(8722):  
 03-03 15:40:29.363: I/Unity(8722): (Filename: ./Runtime/Export/Debug.bindings.h Line: 45)


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

2 Replies

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by MSOTech · Feb 26, 2019 at 02:16 PM

I have solved it. It turns out there was an error in the code that prevented Unity IAP from consuming all of the products at the beginning. Therefore PurchaseProcessingResult.Complete wasn't being returned.

 public PurchaseProcessingResult ProcessPurchase(PurchaseEventArgs args) 
 {
     // (code with error was here)
     return PurchaseProcessingResult.Complete;
 }
Comment
Add comment · 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 Stonegolemstudio · Mar 21 at 05:10 PM 0
Share

Not sure I understand what code was causing the error. here is my method. public PurchaseProcessingResult ProcessPurchase(PurchaseEventArgs args) { bool success = true; if (String.Equals(args.purchasedProduct.definition.id, product_gemsSmall, StringComparison.Ordinal)) { if (isInQuickMenu == true) { PurchaseQuickGemsSuccess(); } else { balloonMenu.PurchaseGemsSuccess(0); } } else if (String.Equals(args.purchasedProduct.definition.id, product_gemsMedium, StringComparison.Ordinal)) { balloonMenu.PurchaseGemsSuccess(1); } else if (String.Equals(args.purchasedProduct.definition.id, product_gemsLarge, StringComparison.Ordinal)) { balloonMenu.PurchaseGemsSuccess(2); } else if (String.Equals(args.purchasedProduct.definition.id, product_gemsExtraLarge, StringComparison.Ordinal)) { balloonMenu.PurchaseGemsSuccess(3); } else if (String.Equals(args.purchasedProduct.definition.id, product_gemsXXLarge, StringComparison.Ordinal)) { balloonMenu.PurchaseGemsSuccess(4); } else if (String.Equals(args.purchasedProduct.definition.id, product_heroOfTheDay, StringComparison.Ordinal)) { balloonMenu.OnConfirmPurchaseHeroOfTheDay(); } else if (String.Equals(args.purchasedProduct.definition.id, product_tokenOfTheDay, StringComparison.Ordinal)) { balloonMenu.OnConfirmPurchaseTokenOfTheDay(); } else { balloonMenu.ExitTimeOutScreen(); success = false; Debug.Log(string.Format("ProcessPurchase: FAIL. Unrecognized product: '{0}'", args.purchasedProduct.definition.id)); } if (success) { //Also checks if logged in in WEB script Web.web.SaveIapReciept(args.purchasedProduct.transactionID); } return PurchaseProcessingResult.Complete; }

avatar image
1

Answer by Priyanka-Rajwanshi · Dec 21, 2019 at 04:41 PM

For resolving the bug, all you need is to edit the OnInitialized function as follows:

     public void OnInitialized(IStoreController controller, IExtensionProvider extensions)
     {
         // Purchasing has succeeded initializing. Collect our Purchasing references.
         // Overall Purchasing system, configured with products for this application.
         m_StoreController = controller;
         // Store specific subsystem, for accessing device-specific store features.
         m_StoreExtensionProvider = extensions;

         foreach (var product in m_StoreController.products.all)
         {
             m_StoreController.ConfirmPendingPurchase(product);
         }
     }

You can get more details here: http://codesaying.com/unity-iap-stuck/

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 twice7713 · Aug 20, 2020 at 12:26 AM 0
Share

code where?

avatar image IMWinter twice7713 · Sep 19, 2020 at 10:42 PM 0
Share

Inside the OnInitialized function that Unity provides in their Purchase$$anonymous$$anager class when you use their Unity Purchasing plugin

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

102 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Unity services linking to different projects at build time (Automated) 0 Answers

Cant build because services tab wont load 1 Answer

In Unity Services, can Managers in an organisation integrate IAP or do they need to be Owners ? 0 Answers

Link Unity Dashboard with Play Store Game 0 Answers

Web Service not running problem 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