Search Unity

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

    173 vote(s)
    86.5%
  2. Voxel Busters

    10 vote(s)
    5.0%
  3. Stans Assets

    13 vote(s)
    6.5%
  4. Prime31

    4 vote(s)
    2.0%
  1. uniphonic

    uniphonic

    Joined:
    Jun 24, 2012
    Posts:
    130
    A few questions:

    The examples don't seem to have DBManager script attached to any game objects. Is proper to attach the script to a game object, in order to set up the encryption field and Obfusc Key?

    My game mechanic involves decreasing currency when the player gets hit by certain projectiles. Is there anything wrong with passing DBManager.IncreaseFunds a negative value to accomplish this?

    Thanks!
    Jacob
     
  2. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,260
    They don't need one: the DBManager script is attached to your IAPManager prefab. If you place the IAPManager prefab in the first scene of your game, it will be persistent across scenes.

    That's totally fine, but you have to check against zero by yourself (will add this check in the next version).
     
  3. TWaanders

    TWaanders

    Joined:
    Mar 27, 2013
    Posts:
    46
    Hi Baroni,

    I am having some issues with updating to the latest version.

    As soon as I import the lastest version of SIS through the Asset Store, all the scripts in my existing project get corrupted. The error reads: " The associated script cannot be loaded" (This is displayed underneath all the scripts on all Game Objects). The reason I want to update to the latest version is that I want to switch from Prime31 to OpenIAB.

    Do you have any idea why that would be the case? Fortunately I made a back-up of the project, this also allowed me to test it a couple of times. Unfortunately it leads to the same problem everytime I try to update this plugin.

    Do you have any idea what could go wrong?
     
  4. uniphonic

    uniphonic

    Joined:
    Jun 24, 2012
    Posts:
    130
    Does this mean that every time I test my game in the editor, if I want the store to load properly, that I will have to enter from the first scene, rather than shortcutting directly to another scene?

    Would it hurt including the prefab in each scene?

    Also, is the database in a single file format that I could just save the whole database file to the cloud?

    Thanks,
    Jacob
     
    Last edited: May 11, 2014
  5. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,260
    Hi there,

    no, not really... I've just tried updating SIS from 2.0.1 to 2.0.2 (Asset Store version) and it went without problems. These are the things which "could" help:
    1. Open a new, empty scene
    2. Delete the SIS folder (but keep the IAPManager prefab in SIS/Prefabs/Resources)
    3. Delete your local download of SIS and re-download it from the Asset Store
    4. Import the new version
    5. When the plugin setup window pops up, select your package, but deselect the IAPManager prefab

    No, the Shop Manager prefab in your store scene will instantiate a new IAPManager prefab if it can't find one.

    In the final game, yes. IAP items could occur multiple times or some other weird things could happen. However you can do that for testing database values etc., but don't forget to remove it later.

    Yes, it is. It's a single PlayerPrefs file (page 18 in the documentation describes how to find it on your pc).
     
  6. uniphonic

    uniphonic

    Joined:
    Jun 24, 2012
    Posts:
    130
    Thanks for the answers!

    If it's problematic having the prefab in multiple scenes, then would it also be problematic if I allow the user to load the first scene again? My first scene is currently a menu screen, and I allow the user to return there multiple times.

    Thanks!
    Jacob
     
  7. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,260
    That won't be an issue, the IAPManager also destroys other instances if it detects them (in your case when entering the first scene). The issues I've listed above only occur when having multiple instances in one scene - specifically the shop scene - as both instances try to populate the shop script with items at the same time, before destroying each other.
     
  8. fmarkus

    fmarkus

    Joined:
    May 22, 2010
    Posts:
    181
    Sorry to bother you again... I get a spinning wheel, editor frozen when I try to open IAP settings.
    I have updated everything and everything works but this.
    Any idea?
     
  9. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,260
    Does this happen on a Mac or on Windows, which Unity version are you running and do you have a Shop Manager prefab in the scene?
     
  10. fmarkus

    fmarkus

    Joined:
    May 22, 2010
    Posts:
    181
    Missing Shop manager prefab was the problem. Thanks for your super fast answer! Awesome support.
     
  11. TWaanders

    TWaanders

    Joined:
    Mar 27, 2013
    Posts:
    46
    I think I run an older version, I somehow couldn't get it to work, my scripts keep getting corrupted. As long as I keep my Prime31 package up to date it shouldn't be in issue to run an older version of SIS right?

    I do have another question; how do I determine which currency is used for which items. I know I can set the different prices for my 2 currencies, but where do I control which currencies belong to which item?

    Thanks again for the excellent support!
     
  12. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,260
    That's weird.. 2.0.2 only contains a minor fix in the scenes for NGUI 3.5.8+. You should be fine when running 2.0.x.

    In the IAP Settings editor, under the "In Game Content" tab, you specify the currencies and the active currency for entering prices. Each item will require values for each currency. After you've specified those, you'll need an IAPItem prefab for displaying your IAP data.
    The IAPItem script has a "price" array, which is mapped to your currencies (slot 0 = currency 0, slot 1 = currency 1, etc.). Resize the array and assign UILabels to these slots for displaying prices. I hope this clarifies it a bit.
     
    Last edited: May 13, 2014
  13. TWaanders

    TWaanders

    Joined:
    Mar 27, 2013
    Posts:
    46
    Cheers, works like a charm!
     
  14. fmarkus

    fmarkus

    Joined:
    May 22, 2010
    Posts:
    181
    Just curious. Having some time looking at this, I just tried the examples provided, particularly Vertical List + Menu.
    When I buy in the items list, bullets or anything, nothing happens other than the 'Sold' sign appearing. No currency decremented and as a matter of fact, no call in the iAPListener. Put some debug logs there but nothing.
    Is this normal? Missing something?
    Thx.
     
  15. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,260
    Which version of SIS are you running? In one of the earlier versions (1.3, 2.0 or something like that I think), the IAPListener component on the IAPManager prefab was disabled. Please check that this script is enabled to correctly receive IAPManager events.
     
  16. fmarkus

    fmarkus

    Joined:
    May 22, 2010
    Posts:
    181
    Everything looks on. Checkmark next to script. I downloaded the latest yesterday. I'm trying this in editor by the way, in case it makes any difference.
     
  17. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,260
    Hmm.. it doesn't make a difference when buying virtual items, the result should be the same in the editor. I can't figure this one out, as everything seems to run correctly on my end. Feel free to debug it further, with the following method flow:

    IAPManager: PurchaseConsumableVirtualProduct() -> purchaseSucceededEvent
    IAPListener: purchaseSucceededEvent -> HandleSuccessfulPurchase()

    or send me a repro project. Now that I think of it, do you actually have these product ids (bullets, health, etc.) in your IAP Settings editor? You could have deleted or replaced them with your own.
     
  18. fmarkus

    fmarkus

    Joined:
    May 22, 2010
    Posts:
    181
    I just restarted a project from scratch. Downloaded everything updated, NGUI, your plugin, latest Open IAB 0.9.6. Added all the scenes to iOS build.
    Ran in editor. No compiling error at all.
    Virtual currency at 2000. Buy items, no decrease in total currency. Sold Checkmark on.
    Added Debug.Log("here") under Bullets in IAPListener. No message showing.
     
  19. fmarkus

    fmarkus

    Joined:
    May 22, 2010
    Posts:
    181
    Looks like this is not happening...
    UIEventListener.Get(buyButton).onClick += Purchase;
    That's in the IAPItem.cs file. BuyButton is set properly in the prefab.
     
  20. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,260
    @fmarkus
    Could you please zip up your project folder (not exported as a unitypackage), upload it somewhere and pm me a link to it.
     
  21. fmarkus

    fmarkus

    Joined:
    May 22, 2010
    Posts:
    181
    Well this is ridiculous :)
    I was expecting to see a result when I clicked on BUY. But you actually have to click on the checkmark to make this work... I thought the checkmark was to confirm the purchase, not something you had to click.
    So it works.
     
  22. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,260
    Actually that's the exact reason why the checkmark is there: to confirm the purchase of this item. Some users could accidentally buy items by pressing on "buy", because they are expecting some confirmation to show up first. You can skip this step by not assigning the additional buy button to the IAPItem, if you want to. If the item has been bought by the user, the gameobject "sold" will be activated to indicate a previously purchased item.
     
  23. fmarkus

    fmarkus

    Joined:
    May 22, 2010
    Posts:
    181
    Yes I understand :)
    It just didn't look like something I had to push to me so it didn't come to my mind until I looked at the code :) Sorry about that.
    Learned a lot about the code though.
     
  24. TWaanders

    TWaanders

    Joined:
    Mar 27, 2013
    Posts:
    46
    I found the solution to the problem where none of my scripts could be loaded after updating!

    It was super simple. After studying some of the new scripts, I noticed they use a new class reference --> using SIS;

    As soon as I added this reference to all of my scripts that interact with the DBManager and other SIS components, the errors dissapeared :). I am glad to be up and running again.

    I still run into one error that does not makes sense. As soon as I run the game in Unity, I get an error stating:

    Code (csharp):
    1.  Couldn't get funds, currency: '' not found.
    2. UnityEngine.Debug:LogError(Object)
    3. SIS.DBManager:GetFunds(String) (at assets/sis/Scripts/DBManager.cs:461)
    4. UpdateFunds:OnEnable() (at assets/scripts/UIScripts/UpdateFunds.cs:57)
    The Error refers to this piece in the UpdateFunds.cs script:


    Code (csharp):
    1.     void OnEnable()
    2.     {
    3.         //if we don't use the database component,
    4.         //thus we don't get an instance of it,
    5.         //disable this script and do nothing
    6.         if (!DBManager.GetInstance())
    7.         {
    8.             this.enabled = false;
    9.             return;
    10.         }
    11.  
    12.         //get current currency value
    13.         int funds = DBManager.GetFunds(currency);
    14.         //display value in the UILabel
    15.         label.text = funds.ToString();
    16.         //store value
    17.         curValue = funds;
    18.     }
    I set the currency in the IAP settings window to match the one I previously used. This should match other references that already existed in my project, although I do not think the name really matters.

    I did not touch the DBManager script at all (freshly imported), although I did modify the UpdateFunds.CS script a bit. Any idea as to what could be wrong here?
     
  25. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,260
    Have you set the currency name in the inspector for UpdateFunds? If so, deleting the PlayerPrefs entry in your registry could help, so that the DBManager does not find previous data and can initialize a new PlayerPrefs file with all IAPs and currencies.
     
  26. casperjeff

    casperjeff

    Joined:
    Apr 13, 2013
    Posts:
    333
    Game I am working on has a virtual currency that is earned through actions/activities.
    Can I use Simple IAP to allow user to purchase and track using this virtual currency without hitting a third party IAP system?
     
  27. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,260
    Yes, you could just import the free billing plugin OpenIAB and comment out its initialization call, or remove all corresponding code lines in our IAPManager script.
     
  28. uniphonic

    uniphonic

    Joined:
    Jun 24, 2012
    Posts:
    130
    Upon setting things up, and then deploying to a device, and then trying to test purchase, I'm getting an error:

    "Error
    The item you were attempting to purchase could not be found."

    Any idea what could cause this?

    Thanks!
    Jacob

    P.S. My products are all Active in the Google Play Developer Console.
     
    Last edited: May 31, 2014
  29. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,260
    Have you uploaded an alpha build to Google Play and checked that the bundle identifier in Unity matches the one displayed on your app in Google Play?
     
  30. uniphonic

    uniphonic

    Joined:
    Jun 24, 2012
    Posts:
    130
    Yep, I did, and it matches.

    Is there an easy way to debug further?

    Thanks!
    Jacob
     
    Last edited: May 31, 2014
  31. uniphonic

    uniphonic

    Joined:
    Jun 24, 2012
    Posts:
    130
    I don't need to have the app published, right? It's uploaded, but not published.
     
  32. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,260
    No, your app does not need to be published. I can't think of any other reason for that error to show up, besides entering an invalid google developer key or product id. But if you're logging the device, the billing plugin itself should report faulty setups.

    Edit: Google now requires apps to be published for IAPs to work properly.
     
    Last edited: Jun 12, 2014
  33. uniphonic

    uniphonic

    Joined:
    Jun 24, 2012
    Posts:
    130
    The only SIS error I see, from logcat, says:

    NullReferenceException: Object reference not set to an instance of an object.
    at SIS.IAPArticle..ctor (OnePF.SkuDetails prod) [0x00006] in IAPArticle.cs:44
    at SIS.IAPManager.ProductDataReceived (OnePF.Inventory inv) [0x00086] in IAPManager.cs:44

    Followed by a few other lines, which I'm guessing you may not need, so i'm not yet taking the time to retype (but I will if you need the other lines following).

    This message seems to happen on initialization.

    Other than that I'm not seeing any SIS related errors in logcat.

    The error I mentioned previously:
    "Error
    The item you were attempting to purchase could not be found."
    does not show up in logcat, and only shows up in the Google GUI shown directly to the user.

    Does this shed any light on what might be happening?

    I've double checked that the IDs match what is in Google Play, but the errors still persist, and I've tried multiple different products including consumable and non-consumable.

    Thanks for your help!
    Jacob
     
  34. uniphonic

    uniphonic

    Joined:
    Jun 24, 2012
    Posts:
    130
    Hmm... looks like we've got new forums here... maybe my last message didn't trigger a notification?
     
  35. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,260
    I replied to your email.
     
  36. games

    games

    Joined:
    Feb 18, 2012
    Posts:
    61
    I have the exact same issue with the item not being found.

    Having gone through the GooglePlay Developer Portal, verified test accounts for alpha and beta, and triple checking the product IDs match in the code and portal, I'm not sure where to go from here...

    The app is not published but I am thinking maybe I need to publish it to test it for sure? Cause, my code looks good.

    Also, I am using BlueStacks on a Mac OS X to test the app.

    Any fix by chance?
     
  37. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,260
  38. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,260
    Version 2.1 is live on the stores, adding support for remotely hosted configuration files for virtual products.

    Features
    - added remote config download option for virtual products, with "cached" and "overwrite" option. Useful for adjusting product details (titles, descriptions, prices) without updating the app.
    cached: saves downloaded config on the device, applies them on next startup (permanent changes)
    overwrite: only affects the current session and immediately applies changes (temporary changes)

    Fixes & Changes
    - IAPManager and virtual products now work on standalone builds
    - DBManager IncreaseFunds method checks against negative values
    - removed unnecessary DBManager references in IAPManager
    - restructured IAPManager receipt verification checkboxes as enums
    - restructured IAPManager serverUrl for verification and hosted configs
    - potential fix for IAPEditor hang/error on Close(), improved warning
    - unlockable prefabs falsely unlocked buy buttons too (inspector change)

    ---
    Still on my to-do list is csv import, a better approach for defining products on multiple platforms and uGUI support.
     
  39. uniphonic

    uniphonic

    Joined:
    Jun 24, 2012
    Posts:
    130
    I just updated, but then started getting some errors that I wasn't getting before, so then I reverted the update. What is the proper update procedure?

    Thanks!
    Jacob
     
  40. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,260
    What errors? There have been changes to the verification type and url, but no compatibility breaking changes.
     
  41. uniphonic

    uniphonic

    Joined:
    Jun 24, 2012
    Posts:
    130
    Well, first when I tapped the buy buttons, the Google Play IAP window never popped up. So then I went to look at the logcat, and saw:
    "You can't place widgets on a layer different than the UIPanel that manages them.
    If you want to move widgets to a different layer, parent them to a new panel instead."

    This error is repeated multiple times. I don't have it in debug mode right now.

    To update, I just imported the updated version, and after that the billing plugin selection popped up, so I selected OpenIAB. After that, the import window came up again, this time for the OpenIAB related files, but I deselected the prefab, since I didn't want it to overwrite my key I had previously entered, and I figured updating the scripts would be enough.
    Any ideas?

    I should probably also point out that I'm using a custom scene saved to a different name, so my scene that contained the shop files would not be overwritten.

    Thanks!
    Jacob
     
    Last edited: Jun 13, 2014
  42. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,260
    This is a warning sent by NGUI, which means that all UI elements parented to a UIPanel have to be on the same layer. Nothing serious, just make sure that all instantiated prefabs and UI scene objects are on the same layer.
     
  43. Subliminalman

    Subliminalman

    Joined:
    Sep 11, 2012
    Posts:
    47
    So I'm trying to get my shop/inventory setup and I'm having a ton of issues.


    I wanted to use the List Vertical template since it was the simplest option and set the Prefab to IGCItem_SS from the ListVerticalTabs scene since it had the behavior I wanted most. All of my items are non consumable and don't use a virtual currency.

    Whenever I test on my iPhone I am able to purchase successfully but the buy button never changes to the select button.



    Also when it is running on the device it will list the items twice in the scroll menu. It won't have them next to each other but instead have them like this:

    • Item 1
    • Item 2
    • Item 3
    • Item 1
    • Item 2
    • Item 3

    And finally theres a freeze that happens if I keep my device connected and have Xcode running. The app will freeze both my phone and Xcode when I open up the ListVertical scene. It works when I don't have it connected though.
     
  44. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,260
    I've just tested this successfully. In the ListVertical scene, I set the prefab to IGCItem_SS and changed the item type to non consumable. When running on my device, I clicked on the item price so that the confirmation (green tick) shows up. When clicking this button the store confirmation pops up in oder to be able to buy the product. After that the buy buttons are replaced with the select button.
    If this is not the result you are seeing, could you provide me with repro instructions?

    This happens if you have multiple IAPManager prefabs in the scene. Make sure to only place it in the first scene and to start your app there.

    That's weird. Any errors or similar inconsistencies in the debug log of Xcode related to Simple IAP System?
     
  45. Subliminalman

    Subliminalman

    Joined:
    Sep 11, 2012
    Posts:
    47
    Ok so I got it all working. I had to reinstall the plugin and I found out that I disabled the IAP Manager in the first scene. The Xcode seems to be happy as well! Thanks for the quick response! :)
     
  46. Subliminalman

    Subliminalman

    Joined:
    Sep 11, 2012
    Posts:
    47
    AH! Help! I just tried to set the database to encrypt but it was messing some things up so I tried going back to unencryption. In doing so I keep getting this Null Reference Exception on SIS.DBManager.InitDB() at line 171. I was trying to check it myself but nothing I do seems to help. I even tried redownloading the DB manager script and all the other scripts as well. I don't know what to do and I'm afraid to lose hours of work!
     
  47. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,260
    You have to delete the PlayerPrefs key set by DBManager between toggling encryption states. The documentation (search for DBManager) describes how to find it on a pc. If you deploy your app to a device, make sure to remove it beforehand.
     
  48. Subliminalman

    Subliminalman

    Joined:
    Sep 11, 2012
    Posts:
    47
    I did that and I'm still getting the null reference. I decided on unencrypted but it keeps writing encrypted data to the PlayerPref and giving me errors in the editor.

    Also it keeps deleting the items I put into my IAP Settings. I'm getting an error that says ExecutionEngineException: SIGILL on IAPEditor.OnGUI()
     
  49. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,260
    You've deactivated the encryption checkbox on the IAPManager prefab and it still writes encrypted data? How do you check that after getting the null reference? Never heard of the second error, but it could be related to the first. The DBManager component initializes itself in a new state if it does not find a PlayerPrefs key (as in a new project), so I can only suggest deleting it in your registry.
     
  50. Subliminalman

    Subliminalman

    Joined:
    Sep 11, 2012
    Posts:
    47
    So I'm using a Mac and I'm assuming that I delete the PlayerPrefs plist file for this correct?
    I delete the data line in my PlayerPrefs and it rewrites it in the file and it looks to be encrypted basing off the example in the docs.


    So I now have the data line completely blank. I've noticed that my issue seems to revolve around the gameData JSON object being null but I don't understand what's going on with it.


    EDIT WITH FIX

    I noticed that the error was coming from the gameData object being null. It was being assigned here
    Code (CSharp):
    1.  gameData = new JSONClass();
    2.             //look up existing playerpref
    3.             if (PlayerPrefs.HasKey(prefsKey))
    4.             {
    5.                 //read existing data string
    6.                 string data = PlayerPrefs.GetString(prefsKey);
    7.                 //read data into memory
    8.                 //if encryption is enabled, decrypt before reading
    9.                 if (encrypt)
    10.                 {
    11.                     gameData = JSON.Parse(Decrypt(data));
    12.                 }
    13.                 else{
    14.                     gameData = JSON.Parse(data);
    15.                 }
    16.                  
    17.             }
    if you comment out that if block and let it run it will fix itself.
     
    Last edited: Jun 24, 2014