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. SpaceRay

    SpaceRay

    Joined:
    Feb 26, 2014
    Posts:
    455
    I have bought this some time ago when it was version 3, but did not use it because was not needed, but now I need to use it but the problem is that I am using Unity 5.5.2 and the download on asset store is for Unity 5.6

    My boss does NOT want to upgrade the project to 5.6 because we did it before and gave many errors (before importing Simple IAP) and so I want to ask if there could be any possible way to get a previous version that could work with Unity 5.52

    So, please, want to ask if I could get a Simple IAP version compatible with Unity 5.5.2

    Thanks for any help
     
  2. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,268
    @SpaceRay please send an email with your Asset Store invoice no.
     
  3. SpaceRay

    SpaceRay

    Joined:
    Feb 26, 2014
    Posts:
    455
    Oh, just now I was going to send it by PM to you
     
  4. SpaceRay

    SpaceRay

    Joined:
    Feb 26, 2014
    Posts:
    455
    I

    I have seen that Simple IAP has support for using PlayFab and I want to ask if using this PlayFab service is good for avoiding the hack of in-app purchase as described in this article

    https://gameanalytics.com/blog/how-to-detect-and-prevent-in-app-purchase-hacks.html

    So I want to ask if using Simple IAP with PlayFab can help to avoid fake communications with a fake Apple store or Google play

    Thanks for any help

    If needed I can explain it more in detail
     
  5. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,268
    Simple IAP System offers client-side, server-side (your own server) and service-side (PlayFab servers) receipt validation. When checking for subscription products, at least server-side validation is needed. But it makes sense for consumable and non-consumable products too, if you are afraid of hackers. None of these methods are offered in the old version you have requested though - they are implemented in the latest version of SIS only (4.0+), as it basically required a complete rewrite of the previous version.
     
    SpaceRay likes this.
  6. SpaceRay

    SpaceRay

    Joined:
    Feb 26, 2014
    Posts:
    455
    Hi, I have been able to make a copy of the project and upgraded to 5.6 as a test and be able to use version 4, as previous version is not possible as I want to use Playfab, thanks anyway for sending it.

    Now I am learning how to use this asset

    Thanks
     
  7. SpaceRay

    SpaceRay

    Joined:
    Feb 26, 2014
    Posts:
    455
    IF I use Playfab on a single player game can it be possible to play the game on iOS without internet connection, and only need internet connection to buy anything? (Either with real money or virtual currency)

    I will only use Playfab for in-app purchases and not for saving other player data as high score

    Thanks
     
  8. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,268
    Hi @SpaceRay, please see this guide for current PlayFab limitations in chapter 1, as well as using only receipt verification in chapter 5: https://www.rebound-games.com/forum/index.php?topic=596.0

    If you are using the receipt verification only mode, the documentation describes that Simple IAP System does not require an internet connection at all times, but will try to login your player and validate the receipt at the time the purchase happens, if the login did not happen before already.
     
    SpaceRay likes this.
  9. SpaceRay

    SpaceRay

    Joined:
    Feb 26, 2014
    Posts:
    455
    Thanks, for your answer.

    In all the examples shown all the objects are individual things and each is separated, and you have to buy one each time.

    MULTIPLE NON-CONSUMABLE THINGS BOUGHT AT ONCE

    I have another question if I want to have a bundle group buy of In-app purchases, I mean for example, If there is available 5 cars to be bought individually and separate, each one with their own button, and then I want to put an additional button to buy all 5 cars at once, how is configured the IAP settings for this?

    Because as I see it you can just only assign and add one thing to one identifier inside a group , or maybe there is some way to activate all the objects contained in a group at once?

    IN-APP PURCHASE REAL MONEY + REMOVE ADS

    I have 5 packs of virtual coins to buy with real money and also I want to put in each of these 5 ones that at the same time you remove ads with this purchase. So in the same way as above there are multiple things, in this case 2 things at once

    Thanks very much for your help
     
    Last edited: Jan 9, 2018
  10. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,268
    You would set up the individual cars as usual, as separate products. Then create your bundle product as a separate product in the IAP Settings as well. In the IAPListener script, when your bundle gets purchased (add it's ID there), call DBManager.SetToPurchased on all product identifiers you would like to unlock for this bundle.

    Same as above, basically. Let your coins package call DBManager.SetToPurchased with the ads product identifier in the IAPListener. Note that users cannot restore virtual products, so if your users uninstall and reinstalls your app, they will lose the coins and also the no ads product - since it only existed in your app, not on the App Store. If you sell the no ads product on its own (as a non consumable), users will be able to restore it later.
     
  11. Astrobyte_

    Astrobyte_

    Joined:
    Jun 30, 2015
    Posts:
    6
  12. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,268
  13. julianr

    julianr

    Joined:
    Jun 5, 2014
    Posts:
    1,212
    Hi! I am trying to change the image sprite that is a child of the Icon, how can I do this as its not exposed in the IAPItem prefab. As you can see I have changed the cell size, but the image sprite does not fill the size of the cell.

    edit: resolved is by adding in the following under set icon to matching sprite in IAPItem

    icon.rectTransform.sizeDelta = new Vector2(150, 150);
     

    Attached Files:

    Last edited: Apr 2, 2018
  14. julianr

    julianr

    Joined:
    Jun 5, 2014
    Posts:
    1,212
    Hi..

    I'm getting the following error; before when I clicked on a product that requires coins when I have zero, it would throw up a window with insufficient coins, now it just produces this error in the log.

    Code (csharp):
    1.  
    2. NullReferenceException: Object reference not set to an instance of an object
    3. SIS.IAPManager.OnPurchaseFailed (System.String error) (at Assets/SimpleIAPSystem/Scripts/IAPManager.cs:620)
    4. SIS.IAPManager.PurchaseProduct (SIS.IAPObject obj) (at Assets/SimpleIAPSystem/Scripts/IAPManager.cs:409)
    5. SIS.IAPManager.PurchaseProduct (System.String productId) (at Assets/SimpleIAPSystem/Scripts/IAPManager.cs:359)
    6. SIS.IAPItem.Purchase () (at Assets/SimpleIAPSystem/Scripts/IAPItem.cs:254)
    7. UnityEngine.Events.InvokableCall.Invoke () (at C:/buildslave/unity/build/Runtime/Export/UnityEvent.cs:165)
    8. UnityEngine.Events.UnityEvent.Invoke () (at C:/buildslave/unity/build/Runtime/Export/UnityEvent_0.cs:58)
    9. UnityEngine.UI.Button.Press () (at C:/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/UI/Core/Button.cs:36)
    10. UnityEngine.UI.Button.OnPointerClick (UnityEngine.EventSystems.PointerEventData eventData) (at C:/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/UI/Core/Button.cs:45)
    11. UnityEngine.EventSystems.ExecuteEvents.Execute (IPointerClickHandler handler, UnityEngine.EventSystems.BaseEventData eventData) (at C:/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/EventSystem/ExecuteEvents.cs:50)
    12. UnityEngine.EventSystems.ExecuteEvents.Execute[IPointerClickHandler] (UnityEngine.GameObject target, UnityEngine.EventSystems.BaseEventData eventData, UnityEngine.EventSystems.EventFunction`1 functor) (at C:/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/EventSystem/ExecuteEvents.cs:261)
    13. UnityEngine.EventSystems.EventSystem:Update()
    14.  
    I'm not 100% sure, but I get this if I have the IAP Settings open at the time of running it in the editor, after that it doesn't work. Using 2017.2.1f1 of Unity.
     
    Last edited: Apr 2, 2018
  15. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,268
    Hi @julianr,

    looking at your trace, line 620 at IAPManager.cs refers directly to the purchaseFailedEvent invokation. This can be null if there is no listener subscribed to the event. Did you remove the IAPListener script from the IAPManager prefab by any chance?

    I'm not sure about the relation between the error and keeping the IAP Settings editor open, but this haven't caused issues in previous Unity versions. Is this something that can be reproduced reliably? I'll recheck that in the latest Unity version then.
     
  16. julianr

    julianr

    Joined:
    Jun 5, 2014
    Posts:
    1,212
    Thanks for that, this helped me to resolve it. For some reason when I dragged the IAPManager to the hierarchy it didn't have the IAP Listener script enabled. - Problem solved

    I also made an improvement to the IAP Settings to enable multiple text lines (using TextArea) in the description when the column is greater than 1 line.

    In all, its a great asset - thanks for making it.
     
    Last edited: Apr 2, 2018
  17. travispettry

    travispettry

    Joined:
    Jul 21, 2017
    Posts:
    25
    I would like to ask a clarify question. Does this asset allow for server sync on items bought through the Windows or other unimplemented stores from playfab? As in I can use the receipt from Unity IAP to have a server sync with playfab?
     
  18. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,268
    @travispettry Depends on the item type - virtual items like coins are bound to the player only and can be synchronized on all platforms that can do web requests to PlayFab.
    Products for real money need a valid receipt to be stored on PlayFab. So if PlayFab does not support validating receipts for a specific platform, it won't automatically grant the item to the player on that platform. You can see the supported platforms in our billing matrix on the first page.
     
    JBR-games likes this.
  19. julianr

    julianr

    Joined:
    Jun 5, 2014
    Posts:
    1,212
    Hi! Any plans on supporting PayPal direct instead of through PlayFab? I'd like to enable a membership purchase through paypal, which then validates it through paypals IPN, and updates my webserver with the correct membership so when they login to the game their account is upgrade and provide them with credits to use in the store which are stored server side.
     
    Last edited: May 5, 2018
  20. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,268
    Hi @julianr,

    there are no plans for doing that, as this would not only require writing and supporting a PayPal billing plugin ourself, it would also be necessary to write a player login and content management platform for custom servers. This is not what we want to do with our limited time and way out of scope for this asset.

    By not reinventing the wheel and making use of existing billing plugins and services is how we are able to support all the different platforms with this asset.
     
    JBR-games likes this.
  21. julianr

    julianr

    Joined:
    Jun 5, 2014
    Posts:
    1,212
    No problem. Just checking to see if anything like this was planned - like you say - we didn't want to re-invent the wheel unless we had to :)
     
  22. ismaelnascimentoash

    ismaelnascimentoash

    Joined:
    Apr 2, 2017
    Posts:
    30
    Hello,
    I want know, if is possible, get user canceled subscription of consumable of appstore and playstore ? If yes, how ?
     
  23. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,268
    Hello @ismaelnascimento01, I'm not sure I understand your question.
    That's impossible. A subscription is of type subscription, not consumable - there are no consumable subscriptions.

    If you would like to get the current state of a subscription product, Simple IAP System provides server-side receipt validation, where product receipts can be re-validated on app launch. If the subscription is not active anymore, the product gets deactivated in Simple IAP System's database, so you can prevent users accessing it in your app. Please read our documentation, included in the package, on how to set up server-side receipt validation (you will need your own server for this).
     
  24. olonge

    olonge

    Joined:
    Sep 22, 2014
    Posts:
    16
    Is there an issue with your site or is it just that your certificate has expired ?. We're not able to log into the forum
    upload_2018-8-2_12-17-10.png
     
  25. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,268
    Hey @olonge, damn, you're right - our https certificate expired. My colleague is on vacation so this may take a while to fix. What are you looking for?
     
  26. JuJuCoder

    JuJuCoder

    Joined:
    Dec 10, 2013
    Posts:
    30
    We are now thinking of upgrading from 3.3 to 4.1. My question is that our game is already live, so what will happen to our existing player base purchases if we upgrade from 3.3. to 4.1?
     
  27. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,268
    @JuJuCoder
    Please see our release notes for an upgrade notice. The database format hasn't changed, so users keep their purchases, but you would need to test that scenario for your app as well.
     
  28. JuJuCoder

    JuJuCoder

    Joined:
    Dec 10, 2013
    Posts:
    30
    Thanks, we have modded the UI a bit and We have been using ProductCache to fetch the localized realtime currency price of a product from the appstore server (eg. Same Price in dollars vs Euros vs pounds etc) to display to the user.

    Where I could obtain this information now since the cache has been removed?
     
  29. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,268
    @JuJuCoder Not sure what you mean by ProductCache? Do you mean the remote config file that was removed and replaced with PlayFab catalogs in 4.x?
    You already get the localized currency if you've enabled "Fetch" for your products in the IAP Settings editor. If you would like to access this data manually, you can get it from the Unity IAP StoreController directly as well.
     
  30. JuJuCoder

    JuJuCoder

    Joined:
    Dec 10, 2013
    Posts:
    30
    I have used like this (I have changed productCache to public from IAPManager in order to access it)

    List<IAPArticle> list = IAPManager.GetInstance().productCache;

    //Looking for the right product from the list and returning a string with localized price
    for (int i = 0; i < list.Count; i++)
    {
    if (list .id == productId)
    return "BUY " + list .price;
    }
     
  31. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,268
    @JuJuCoder
    Thanks for the clarification, but as I said, Unity IAP provides this already which means you do not have to modify any code in Simple IAP System. SIS fetches the localized information from Unity IAP too. You could just do

    IAPManager.controller.products.WithID("your product id").metadata.localizedPriceString

    References:
    https://docs.unity3d.com/ScriptReference/Purchasing.ProductCollection.html
    https://docs.unity3d.com/ScriptReference/Purchasing.Product.html
    https://docs.unity3d.com/ScriptReference/Purchasing.ProductMetadata.html
     
  32. JuJuCoder

    JuJuCoder

    Joined:
    Dec 10, 2013
    Posts:
    30
    Am i referencing the right class? :`SIS.IAPManager' does not contain a definition for `controller'
     
  33. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,268
  34. Rujash

    Rujash

    Joined:
    Jan 3, 2014
    Posts:
    37
    Hi,
    So I am going to have three types of Unity processes running at once: Master Server Framework server, Server for "rooms", and Clients (the players).

    Master Server Framework (MSF) will be managing player inventory in a database. When a player makes a purchase, the billing service has to send to the MSF for confirmation. The player has to only interact on their side with menus and such.

    Should I install this on the MSF and the client to sync the values (items, currency, etc.)? Specifically using with Unity's IAP, if it is possible.

    MSF: https://www.assetstore.unity3d.com/en/#!/content/71391
     
  35. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,268
    Hi @Rujash,

    Billing services do not work like that - the client can initiate and confirm the purchase by default. Once the purchase is successful and a receipt is received, it can then send the receipt to a server for confirmation. This can be set up so that items are only granted to the player after the server confirmed that the receipt is valid.

    What you do within the receipt processing step on your server, such as writing items to databases, is your decision. The items can still be granted locally on the client directly, instead of requesting another database update. Player inventory would need to be synched on each re-authentication either way.

    Simple IAP System provides server side receipt validation as a php file which you have to upload on your web server. This file passes receipts from clients, over the server, to App Store validation endpoints as https calls. It is not designed for being run in an Unity instance or do database connections for managing player inventories, since that's what we're optionally offering PlayFab integration for. You would need to rewrite parts of the server side validation to fit into your scenario.
     
  36. hottabych

    hottabych

    Joined:
    Apr 18, 2015
    Posts:
    107
    Hi. I've just watched your Youtube tutorial. For me it seems not too convenient to edit IAPListener.cs manually. Proposing to improve the workflow by creating switch-case structure automatically based on IAP Settings Editor setup, using reflection. And add a button for a quick opening of this file.
     
    Last edited: Dec 4, 2018
  37. derkoi

    derkoi

    Joined:
    Jul 3, 2012
    Posts:
    2,260
    I'm currently beta testing an update to my app on Google Play & I've notice the IAPs are not downloading the data from Google Play even though it's set to do so in Simple IAP. The live version of my app updates fine. Is this because my app is in beta or have I perhaps screwed something up?

    Thanks
     
  38. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,268
    @derkoi Testing IAPs requires setting an app to alpha or beta, so it cannot be the cause. Unless your beta app uses a broken version of Unity IAP, or a different bundle version/identifier that cannot connect to your Google Play dashboard, the localized product prices etc. should be fetched just fine.
     
  39. derkoi

    derkoi

    Joined:
    Jul 3, 2012
    Posts:
    2,260
    OK thanks, I'll investigate this further.
     
  40. Sholms

    Sholms

    Joined:
    Nov 15, 2014
    Posts:
    85
    Its asset work with steam microtrasactions? if so do you have a link to the documentation?
     
  41. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,268
    @Sholms Yes. The general instructions are included in the package, with the Steam store specific setup explained on our website. We'll also have an update coming out soon which makes use of Steam's native inventory service, which does not require a PlayFab integration then.
     
    JBR-games likes this.
  42. derkoi

    derkoi

    Joined:
    Jul 3, 2012
    Posts:
    2,260
    Hi, I have an odd issue. I have 3 categories of IAP, some virtual, some real. In editor it's fine, on Android it's fine but on iOS 2 of the categories are empty.

    Any ideas why that could be? Thanks
     
  43. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,268
    Hey @derkoi,

    I just re-checked, but there is no iOS specific code when it comes to instantiating IAPItems via the ShopManager. Could you pinpoint this - which category does work and which don't? Do they contain mixed products or upgrades? Does UnityIAP initialize all products without errors (Xcode log)?

    In case you've highly customized your shop, I would suggest running one of the SIS example scenes to get an idea of whether the issue is actually related to Simple IAP System, or something that interferes with your scripts.
     
    JBR-games likes this.
  44. Colin_MacLeod

    Colin_MacLeod

    Joined:
    Feb 11, 2014
    Posts:
    334
    Herzlichen guten Tag @Baroni!

    I've been using SIS for a client project recently. We're using PlayFab and the app is on Google Play for Android and Apple store for iOS.

    On Android specifically, it seems we have one last hurdle to overcome. Purchases work fine, but we're seeing some inconsistent behavior when purchases are restored.

    We have a script on a purchase button for No-Ads non-consumable. In the Unity Start() method, I look for DBManager.GetPurchase(_productId) > 0. If there are purchases, button interactable is set false.

    Here's what's happening. I purchased something under test account 'a' (on android), then (with test account a logged in on another device) I install the app.

    When it first loads up, the button is not interactable and it adheres to the rules... but if I force quit the app and restart it, the button is active again (and I see in the logs DBManager.GetPurchase returned 0).

    The weird thing is, when we click on the button in the second machine, I see this in the logs:

    Code (CSharp):
    1. IAPManager reports: PurchaseFailed. Error: DuplicateTransaction
    So at the start, it thinks there were no purchases. But when the button is clicked the purchase fails because it finds out there were. Bearing in mind we're using PlayFab, how can I check if there were purchases from another machine on startup?

    Do we need to do something in our preloader scene to restore purchases?


    mfG,
    Colin
     
    Last edited: Nov 17, 2018
    JBR-games likes this.
  45. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,268
    Hey Colin!

    Just a quick note on this - if you are already initializing Unity IAP in the "preloader" scene, then that should be fine. However there could be cases where Unity IAP takes longer to initialize and fetch, due to bad internet connection etc. Also: a short version for "GetPurchase(...) > 0" is DBManager.IsPurchased(...).

    Mmmh.. on the first app launch, UnityIAP automatically tries to restore purchases. For convenience, Simple IAP System takes this callback as "granted" and sets the corresponding products to purchased. If you are using PlayFab as well, then the purchase receipt (restore receipt) is sent to PlayFab's servers for validation - PlayFab does not allow verifying the same receipt twice though, so this validation will fail.

    I guess this is what you are experiencing: the product is set to purchased on the first app launch directly, but subsequent launches (not using the restore) will not grant the item since PlayFab hasn't approved it.

    There have been some bugs in older versions of Unity IAP regarding this, are you using a more recent version 1.20 or 1.20.1?

    That's actually the culprit - if players would like to use the app on multiple different devices, they would need to login using a method that's available on each device, i.e. Facebook or Google. Just logging in on a new device creates a new account on PlayFab, which does not have the purchase associated to it (from device 1). By default, SIS uses device logins (or email for desktop standalone/PayPal), so you would need to add a login button for cross-platform logins.

    If you are already using email login on all devices, then this issue should not occur. You can login to the PlayFab dashboard and check your player accounts there as well as the purchases associated to them, so you could actually see that the other device's PlayFab account (signed in with Google account a to Play Store, but not in PlayFab) does not have any purchases.
     
    Colin_MacLeod and JBR-games like this.
  46. Colin_MacLeod

    Colin_MacLeod

    Joined:
    Feb 11, 2014
    Posts:
    334
    Hi @Baroni!

    Thanks for getting back on this.

    Yes, that makes sense. The strange thing is we are not seeing this on Apple devices. When we press the Restore button on a second Apple device, non-consumable purchases are restored and it behaves as expected.

    We are using PlayFab device id login in both cases.

    Can you think why this might be handled differently on Apple? Is there something in the Restore Purchases workflow we can copy over to Android?
     
  47. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,268
    That's because Apple actually returns a new transaction including the original transaction, on each restore:
    https://developer.apple.com/documen...entqueue/1506123-restorecompletedtransactions
    This way PlayFab can validate the restore transaction each time, because it thinks it is getting a new transaction. Unfortunately Google Play returns the same, already validated transaction/order number each time. There is nothing we could do in Simple IAP System to work around this, as we are just using the native Unity IAP and PlayFab packages, which provide these order details. I would still suggest implementing a cross-device login method on Android, or contacting the guys over at PlayFab directly for confirmation.
     
  48. Colin_MacLeod

    Colin_MacLeod

    Joined:
    Feb 11, 2014
    Posts:
    334
    But doesn't the Unity IAP Documentation suggest that restoring purchases is automated on Google Play?

    https://docs.unity3d.com/Manual/UnityIAPRestoringTransactions.html

    Can we implement IStoreListener to tell PlayFab about each previous purchase?
     
  49. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,268
    Correct, and SIS does this for you already. Didn't you say that the product is set to purchased on the first app launch - this is what UnityIAP does. But since the receipt cannot be re-validated by PlayFab, it is set to "not purchased" on the next and all subsequent app launches.

    As I said, PlayFab cannot validate the same purchase several times and will fail if you try to do so. You need to direct your users to the same PlayFab account, which has the validated purchase associated to it.
     
  50. Colin_MacLeod

    Colin_MacLeod

    Joined:
    Feb 11, 2014
    Posts:
    334