Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice
  3. Dismiss Notice

Simple In-App Purchase System (SIS) - Shop solution

Discussion in 'Assets and Asset Store' started by Baroni, Aug 8, 2013.

?

Which billing plugin are you using in combination with Simple IAP System?

  1. Unity IAP

    178 vote(s)
    86.8%
  2. Voxel Busters

    10 vote(s)
    4.9%
  3. Stans Assets

    13 vote(s)
    6.3%
  4. Prime31

    4 vote(s)
    2.0%
  1. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,290
    @JanJulinMekiwi thanks for sharing your experience! If Unity IAP does not initialize, one cause could be that there are indeed no products returned from the store, in this case, the Oculus Store. This is not in any way related to Google Play. It is the expected behavior built on Unity IAP callbacks, since with no products returned, nothing can be bought. Of course you can disregard any failures in your own implementation and treat it like the store is always available, however, that leaves room for other failures in billing processing.

    @benlap_ag I haven't received an invite yet, did you use the email address shown in the screenshot? Regarding the behavior you are mentioning, this is indeed the expected outcome. If the product is a non-consumable product that is owned by the user and contained in their inventory (you can verify this in Steam notifications, it should show a new product event), initializing the Steam store will pass all items to the user so nothing is lost. It's like an automatic restore.
     
  2. Andres41

    Andres41

    Joined:
    May 15, 2017
    Posts:
    9

    Sorry for my late response, this week was very hard and I barely had time. I tried your solution and it worked correctly. Thank you very much, I managed to do what I needed. Now what I am faced with is how to change the player's skin, being necessary to instantiate a new character but having the logic of this code I think I can do it.

    I thank you very much for your attention and prompt response. 5 Stars Asset and solution.
     
  3. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,290
    Happy to hear that the code helps in getting you started! I would appreciate that "5 Stars" feedback as a review on the Unity Asset Store, if you get the chance, since currently the last one is not that good :)
     
    Andres41 likes this.
  4. benlap_ag

    benlap_ag

    Joined:
    Apr 22, 2021
    Posts:
    5
    @Baroni Will send invite soon.

    Ah okay, so I see the (multiple) purchases in my steam inventory. How can I delete these so that I can test as a completely new user? This is making testing very difficult as I'm verifying the purchase flow.
     
  5. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,290
    You would need to set them to "Consumable" so they are being consumed every time you launch the app. Then set them back to "Non-Consumable" to test again.
     
  6. benlap_ag

    benlap_ag

    Joined:
    Apr 22, 2021
    Posts:
    5
    @Baroni Okay setting them to consumable let me 'reset' the purchase to test again.

    But now I'm running into another issue. I rely on the HandlePurchaseStarted, HandleSuccessfulPurchase, and the HandleFailedPurchase events to update my UI using some custom logic. I'm noticing that these events don't get fired when using Steam IAP.

    How can I make my game respond to a successful steam purchase without these events working?

    I see this in UIShopFeedback.cs:

    void Start()
    {
    #if SIS_IAP && !STEAM_IAP
    IAPManager.purchaseStartedEvent += HandlePurchaseStarted;
    IAPManager.purchaseSucceededEvent += HandleSuccessfulPurchase;
    IAPManager.purchaseFailedEvent += HandleFailedPurchase;
    #endif
    }
     
  7. majaus

    majaus

    Joined:
    Jan 15, 2016
    Posts:
    4
    Hello, I imported the asset into the project, but it seems like it's not detecting that it's installed for some reason. It lets me click on Install again, as if it hasn't been installed, and I don't see what the instructions say about:

    "A 'Link your Unity project' popup might appear. Follow its instructions in the Project Settings and link your project, as Unity IAP requires that for its UGS services."

    Also, it shows NOT OK.

    Im using unity 2023.3.25 lts.

    Regards.
     

    Attached Files:

  8. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,290
    @benlap_ag I just tested again with a consumable product (to allow re-testing) and the HandleSuccessfulPurchase event is fired correctly. Note that you are looking into the UIShopFeedback script, which handles a loading screen during purchase popups - this is used on mobile platforms but not on Steam. On Steam, like on all other platforms, the IAPListener script is subscribed to the HandleSuccessfulPurchase event and fires it.

    There must be something else going on with your project. Have you tried doing the purchase in one of the Simple IAP System samples?

    @majaus Thank you for your message and the screenshots. Please note that the "Package Imported - NOT OK" text is referring to Unity IAP (see screenshot). You did not import Unity IAP into your project, it seems. Please follow the installation instructions to do so.

    upload_2024-4-29_12-7-38.png
     
  9. justtime

    justtime

    Joined:
    Oct 6, 2013
    Posts:
    430
    Hi there! I don't know how this could be related to SIS, but decided to ask anyway: sometimes users complain about auto-refunds for non-consumable products. I thoughts it was the bank's fault, but may be there is something wrong with Unity IAP?
    I found only this, but i don't have any services like in that post
     
    Last edited: May 4, 2024
  10. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,290
    Hi @justtime! If you are not using receipt validation (client, or our server-side service) or external services (like PlayFab), the purchase is completed immediately by returning PurchaseProcessingResult.Complete. I can think of three issues causing this to fail:

    - a Null Reference Exception or any other exception in your code that is only thrown sometimes before the ProcessPurchase method returns
    - a rare bug in Unity IAP
    - Google payment failing to bill the user after trying multiple times
     
  11. justtime

    justtime

    Joined:
    Oct 6, 2013
    Posts:
    430
    Thanks for the reply. I use client receipt validation. It's strange because as i know i can't refund non-consumable product from code.
    Here is the typical user case with this bug:
    1)User buys the product, use the app for a while
    2)Opens the app after a few days/weeks and sees that he can't access the product he bought. He emails me with a GPA code and i confirm that product has been refunded refunded somehow
    3)He buys the product again and the cycle repeats
     
  12. zumpecorvin

    zumpecorvin

    Joined:
    Mar 10, 2024
    Posts:
    6
    Hello, this might be a dump question but I can't figure it out by my own... All of my virtual products (coins, ...) are marked as NOT virtual... However they are, which causes problems with my redeem system... Is there any setting I just didn't see to change that?
     
  13. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,290
    If that happens with the same users, and not with others, it really seems to be a payment issue with Google Play. You could try suggesting them to update or change their payment details.

    Hi! Not sure I understand your question: your coins products can be purchased with real money, but you do not want that? If so, you would verify that there is no "Real Money" price assigned to them in their product settings.
     
  14. justtime

    justtime

    Joined:
    Oct 6, 2013
    Posts:
    430
    This happens with different users in a single scenario.
     
  15. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,290
    I thought you wrote "sometimes" in the beginning? Is it reproducible, or the scenario that causes this?
     
  16. zumpecorvin

    zumpecorvin

    Joined:
    Mar 10, 2024
    Posts:
    6

    Hey, I do want the user to purchase the coins with real money. But since they don't get any physical goods for it, the coins should be a virtual product. I need the products to be marked as virtual so I hoped there would be any kind of option to toggle that. I don't really want to change much at the code at all
     
  17. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,290
    Hi @zumpecorvin, all products are virtual by default. They can either be purchased with real money, or virtual currency. This is defined by assigning the corresponding price value (a real money price, or a virtual currency value that should be deducted).

    -> There is no toggle to tell Simple IAP System "this is a virtual product" - it is handled internally. The way this works is that you would create a virtual currency (coins), a product (buy coins). Then in the product assign a real money price (e.g. $2) and a reward (virtual currency, e.g. 200 coins).

    If this does not answer your question, could you clarify what you exactly mean by "marked as virtual"? Marked where?
     
    zumpecorvin likes this.
  18. zumpecorvin

    zumpecorvin

    Joined:
    Mar 10, 2024
    Posts:
    6

    Thank you very much, I didn't know that. I will assign a reward then, this should fix it then. Stay safe!
     
    Baroni likes this.
  19. makaka-org

    makaka-org

    Joined:
    Dec 1, 2013
    Posts:
    1,077
    I use your RECEIPT VALIDATION cloud service and the only subscription product to validate.

    Are these statements correct?

    1. Simple IAP System (asset) and Receipt Validator (asset) are independent.
    2. I don't need to import the Receipt Validator (asset) when I use the Simple IAP System, because ReceiptValidatorServer.cs inside Simple IAP System (asset) contains all the needed code.
     
  20. justtime

    justtime

    Joined:
    Oct 6, 2013
    Posts:
    430
    Yes, i did. I meant that it happens from time to time with different users in single scenario. And i think many users don't emails be, just uninstall the app after refund(i see it in the dashboard) and i don't know if they really did refund or it was a bug.
     
  21. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,290
    @makaka-org That's correct. The Receipt Validator asset is free, and for developers who do not want or use Simple IAP System.

    @justtime ok! We will need more information to solve this, so I can think of two things you could try:

    1. Contact Google and send them some order tokens so they could clarify whether there was a billing issue with these orders and if Google declined them in the end.
    2. If you use any kind of analytics SDK, add an event funnel for how many purchases were started, pending (in client receipt validation) and finished. With the pending transactions, log their tokens so you are able to check some of them on the Google orders page and see whether they were refunded (and ask Google support why). A bonus would be to log the client receipt validation result too (maybe that fails to begin with?).
     
    justtime likes this.
  22. Vicetexin12

    Vicetexin12

    Joined:
    Sep 28, 2020
    Posts:
    2
    Hi Brother, I'm having some issues with integrating steam, I currently have everything set up according to the instructions and in the build and editor they fetch the price in the steam product just fine but when you click on the button nothing happens, no steam overlay or anything.


    onPurchaseFailedEvent(productId:TEST1 message:k_EResultBusy)
    UnityEngine.Purchasing.PurchasingManager:OnPurchaseFailed (UnityEngine.Purchasing.Extension.PurchaseFailureDescription)
    SIS.SteamStore:OnPurchaseFailed (string,int) (at Assets/SimpleIAPSystem/Scripts/Extensions/Steam/SteamStore.cs:367)
    SIS.SteamStore:OnPurchaseStarted (Steamworks.SteamInventoryStartPurchaseResult_t,bool) (at Assets/SimpleIAPSystem/Scripts/Extensions/Steam/SteamStore.cs:261)
    Steamworks.CallResult`1<Steamworks.SteamInventoryStartPurchaseResult_t>:OnRunCallResult (intptr,bool,ulong) (at Assets/com.rlabrecque.steamworks.net/Runtime/CallbackDispatcher.cs:386)
    Steamworks.CallbackDispatcher:RunFrame (bool) (at Assets/com.rlabrecque.steamworks.net/Runtime/CallbackDispatcher.cs:176)
    Steamworks.SteamAPI:RunCallbacks () (at Assets/com.rlabrecque.steamworks.net/Runtime/Steam.cs:112)
    SteamManager:Update () (at Assets/Scripts/Steamworks.NET/SteamManager.cs:173)

    This I get on the editor but on the build which has the dev console enabled I get no error or message when trying to purchase.

    thank you!
     
  23. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,290
    Hi @Vicetexin12! Unfortunately it is impossible for me to tell you the exact cause for this, since I do not have access to your Steam account and cannot look into your settings. Note that testing in the editor is unreliable, you absolutely do have to start the game from within your Steam client, with your developer account logged into Steam, for testing purposes.

    Did you read the last section in the Steam guide and went over all points mentioned there?
     
  24. Vicetexin12

    Vicetexin12

    Joined:
    Sep 28, 2020
    Posts:
    2
    Thank you for the swift response, I did fill out the points in the guide and double checked, I've been testing on a build uploaded to steam and was hoping that this was a particular error known to you, it's clear to me that the steam connection is at least partially working since it can fetch the price with ease and I have no issue pulling up the overlay with the shortcut it's just the purchase that does not pop up the overlay.

    I will keep looking for solutions in the Steam part of your code and go do a triple check on the Steam guide final points to make sure everything is in order.

    Cheers.
     
  25. Adrian_realgames

    Adrian_realgames

    Joined:
    Jun 14, 2016
    Posts:
    2
    Hey! I hope you doing well! I have a question, how can I get the productID from a restore at IOS?
    You did it lovely in the Android restore where I can just send each product that gets restored to an otherscript.
    Tho in your IF UnityIOS, it its just doing a Restore without giving out invidual products that I can send over to another script. Thank you for your help in advance!
     
  26. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,290
    Hi @Adrian_realgames, thanks for using SIS!

    The restore method for Android is self-written, so it allows doing whatever you want - for Android, actually there is no restore since it is not necessary, nor required. When your app gets newly installed, Unity IAP calls the ProcessPurchase method automatically for each owned product. See here.

    On iOS, this "automatic restore" does not happen, as it would require the user to enter their password. There, Unity IAP provides access to the native RestoreTransactions method, which again, invokes the ProcessPurchase method for each product owned. Its OnTransactionsRestored callback only tells you that the restore was successfully initiated, not providing any products, their state or information about the restore at all.

    What you could do is implementing a "restoreInProgress" boolean and set that to true when RestoreTransactions is called. While that boolean is true and ProcessPurchase is called, it is a product restore. After a few seconds, set the boolean back to false (OnTransactionsRestored cannot be used since it can be called at any time). This would be a hack and maybe you could think about your requirement so this would not be necessary to begin with?
     
  27. masulicz

    masulicz

    Joined:
    Apr 30, 2023
    Posts:
    2
    Hello! I've recently encountered a problem while using Simple IAP System. I have a scene set up for single-selection, with two test products. When I start from a fresh database file, everything works (I buy one, I can select it. I buy the other, and I can toggle between the two). However, when I close the Unity Editor, and replay the scene, both items are selected! Would you have an idea about how to fix this?
     
  28. masulicz

    masulicz

    Joined:
    Apr 30, 2023
    Posts:
    2
    Never mind, turns out that because I had named one of the products "test" and the other "test2", when I had "test2" selected, the String.Contains in the DBManager.IsSelected returned true for "test" (because, that's kinda how it works). I hope I didn't cause too much inconvenience. I just wanted to say thank you for making such a wonderful asset, it's helping a tremendous amount.
     
  29. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,290
    Hi @masulicz, thank you for the kind words! Do not forget to write a review on the Asset Store, at some point :)

    Oh, that's right! This method gets a full selection string and does a .Contains on it, I can see why that would fail. I'll think about making this more clear in a future update. If you would like to get a list of all products in that group and do your own check, you could use DBManager.GetSelectedGroup instead.
     
  30. Andres41

    Andres41

    Joined:
    May 15, 2017
    Posts:
    9
    Ok sure!, ill do it right now
     
    Baroni likes this.
  31. MicheleBunetto

    MicheleBunetto

    Joined:
    Jul 2, 2012
    Posts:
    9
  32. Andres41

    Andres41

    Joined:
    May 15, 2017
    Posts:
    9
    Hello again! I was developing my game but I ran into a new condition. It seems that the player cannot choose whether to use Crystals OR Coins in this case. When I added the price to the item I put it, for example: 500 crystals and 2000 coins, I thought that the player could choose whether to pay 500 crystals or 2000 coins but it seems that it is placed as the price is 500 crystals and 2000 coins, that is It adds them to the requirements, I tried to place 3 buttons, one for each price, but it doesn't work correctly and I have to edit a lot of the code. Is there any way to make this possible?
     
  33. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,290
    Thanks for the suggestion. Epic Game Store support is currently not planned. Maybe I'll do it when FAB (the new Epic Game Store) comes out.

    Hi Andres! Yes, there is no OR condition on the pricing. If you assign multiple prices, it is always an AND. If you want to sell one product for multiple separate prices, you will have to create separate products for it, with the same reward - one for crystals, the other for coins. Then you can display each one in their own category (crystal or coins category) in your shop. This is actually a design that most games use, which does not require editing any code in the asset.
     
    Andres41 likes this.
  34. Andres41

    Andres41

    Joined:
    May 15, 2017
    Posts:
    9

    Ok thank you so much, i think i would manage that way. Thanks for your help always!
     
  35. Rachan

    Rachan

    Joined:
    Dec 3, 2012
    Posts:
    806
    do you have a tutorial how to make it work with Steam microtransaction?
     
  36. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,290
  37. newlife

    newlife

    Joined:
    Jan 20, 2010
    Posts:
    1,082
    Hello, is there a way to retrieve the actual cost of a IAP? I know that there is IAPExchangeObject.realPrice, but this value is a string cause it contains also the currency character. IAPExchangeObject.amount for some reason returns 0
     
  38. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,290
    newlife likes this.
  39. justtime

    justtime

    Joined:
    Oct 6, 2013
    Posts:
    430
    Hi! Is the latest SIS compatible with Unity IAP 4.12.0?
     
  40. Dovekie

    Dovekie

    Joined:
    Jul 14, 2017
    Posts:
    7
    Under the HandleSuccessfulPurchase method in the IAPListener script, I have it update the value of a playerpref variable in my game.

    This is a non consumable purchase for iOS.

    I have 2 questions:
    1. When the restore purchases button is pressed, will it change the same playerpref variable to what I asked it to change it to in the IAPListener script? If not, where do I put this code?
    2. The restore button is in the same window as my Shop item. Will it instantly update the visual state of the IAP item to purchased? Just to reduce any confusion for the player—and I know the guys that approve on the App store are picky.
     
  41. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,290
    Hi @justtime, I am not aware of any major changes in Unity IAP 4.12.0. However I would recommend to not upgrade, due to several deployment issues, debug messages and other warnings currently present in that version. You can follow these discussions in the Unity IAP section.

    @Dovekie Although it is not a question, I have to make a comment on your first sentence:

    Simple IAP System already stores purchase states. Duplicating this state to your own PlayerPref is not a good idea, because in several events, you have to always keep it in sync. Instead of using your own PlayerPref, please just access the SIS DBManager directly. SIS.DBManager.IsPurchased("your product ID")
    You should not do any modifications to the IAPListener to duplicate PlayerPrefs.

    Please see my comment above. If you are accessing the DBManager directly, you do not have to manage anything yourself. Also in some cases and especially if you are using some type of receipt validation, Simple IAP System might remove a purchase from the device - this would also not be synced to your own PlayerPref.

    The DBManager has a local cache of purchase states. In addition, it updates the purchase state after Unity IAP has been initialized, which could take up to 10 seconds measured from launching the app (because the App Stores are slow to respond). So in both cases, with the device offline or online at launch, or going online later, the IAP Item will always display the latest purchase state it retrieved.
     
  42. justtime

    justtime

    Joined:
    Oct 6, 2013
    Posts:
    430
    Google sent me a letter:
    The previous version of Unity IAP uses Billing Library version 5. So it's important to update to the latest one(they prepared 4.12.1-pre.1 with fixes.). How long do you plan on releasing the SIS update?
     
  43. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,290
    @justtime maybe I didn't express myself clear enough: you can update to Unity IAP 4.12. However, there are multiple bugs in Unity IAP currently, so use it at your own risk. I would suggest waiting for Unity to fix some more bugs.
     
    justtime likes this.
  44. Dovekie

    Dovekie

    Joined:
    Jul 14, 2017
    Posts:
    7
    Cool thanks for the help. I don't understand all of it so I am learning. I replaced that playpref value in my game with

    Code (CSharp):
    1. my var = DBManager.IsPurchased("the unlock");
    and it works fine throughout my game.


    Sorry this isn't super clear to me. So it won't retrieve a new state immediately after the restore button is pressed (assuming they had previously purchased the item)? Assuming these are both in the same window of the same scene?
     
  45. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,290
    @Dovekie No worries. On re-reading your question, I now understand that you were asking about if there are are any restore delays, rather than the functionality itself.

    On Android, the restore is visible instantly because the purchase data is available on the device. On iOS, the device has to ask the App Store for purchase data. So, a restore can take between 3 and 10 seconds to process (web request and response) - the App Store team reviewing your app should know that. It does not matter if the restore button is in the same scene as the shop or not.