Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

[Locked] Announcement: Codeless IAP for Unity IAP

Discussion in 'Unity IAP' started by nicholasr, Nov 28, 2016.

Thread Status:
Not open for further replies.
  1. nicholasr

    nicholasr

    Joined:
    Aug 15, 2015
    Posts:
    183
    Please see the Codeless IAP Manual, now live on the Unity Documentation site.

    Overview


    What is Codeless IAP?


    Codeless IAP is the easiest way to integrate in-app purchases in your Unity app. This allows you to use Unity's GUI and avoid directly using the Unity IAP API for a basic IAP integration.

    How do I use Codeless IAP?

    Add IAP Buttons to your app and define your products in the IAP Catalog. When players run your game, the Unity Purchasing system is configured based on the products you entered in the catalog. When a player taps or clicks on an IAP Button, it initiates a purchase of the associated product.

    Screenshots


    Inspector for a Button decorated with the Codeless IAP component



    IAP Catalog editor for defining and exporting Products​

    (edit: link to Unity Documentation site for additional details, truncate this post to 'overview' only)
     
    Last edited: Dec 8, 2016
  2. Robiwan

    Robiwan

    Joined:
    Dec 29, 2013
    Posts:
    92
    Thanks for this, and perfect timing for me as I'm about to integrate IAPs in my project and have limited code skills :)
     
    nathanf-unity, nicholasr and erika_d like this.
  3. Seraphim-Whiteless

    Seraphim-Whiteless

    Joined:
    Jun 23, 2014
    Posts:
    197
    how can i set up different ids for a few apk bundles?
     
  4. nathanf-unity

    nathanf-unity

    Unity Technologies

    Joined:
    Sep 30, 2016
    Posts:
    4
    We do not currently have any support for that, but we are always interested in collecting feedback about which features are important to put on our roadmap. Would you mind sharing a little about your workflow and why you want to set up different ids for different APKs?

    If you want to try to work around the lack of support right now, you could try working with multiple catalog files. The catalog is currently serialized as JSON and saved inside the plugin directory, in Assets/Plugins/UnityPurchasing/Resources/IAPProductCatalog.json. You could copy that file or create multiple product catalogs. You could then set up your build process to change which catalog file is included in your APK, or you could include all the catalogs and change IAPButton.cs to load from a different path at runtime.
     
  5. Seraphim-Whiteless

    Seraphim-Whiteless

    Joined:
    Jun 23, 2014
    Posts:
    197
    Hi! Thanks for support. My english is terrable .. so ..

    we have a few apk's in google play for different publishers.
    e.t.c amazon does not allow multiple using iap bundle in one account.
    that's why our iap bundles contains apk bundle name
    for example if apk bundle named
    com.company.game1 and com.company.game2
    iap bundles named com.company.game1.gold_100 and com.company.game2.gold_100

    for example 3 similar apps for different publishers
    https://play.google.com/store/apps/details?id=com.foranj.cartooncity
    https://play.google.com/store/apps/details?id=com.foranj.cartooncity_kor
    https://play.google.com/store/apps/details?id=com.foranj.citybuilder

    all bundles can be different, iap bundles can be different.
    now we are resolve it by our bundle manager that solving our problems

    but codeless iap plugin is not finalized and functionality too poor.

    Sory, but new version is not usable :(

    PS I love Unity.
    PPS Need smile "Love Unity"
     
    Last edited: Nov 30, 2016
  6. nathanf-unity

    nathanf-unity

    Unity Technologies

    Joined:
    Sep 30, 2016
    Posts:
    4
    Thank you for sharing your feedback. For your situation it sounds like Codeless IAP does not provide all the functionality you need, so you should continue to use the regular API. The existing API is not going away, and we expect many developers will choose not to use the Codeless IAP tools.
     
    GarthSmith and nicholasr like this.
  7. PedroGV

    PedroGV

    Joined:
    Nov 1, 2010
    Posts:
    415
    This is great! Are you planning to add a service to handle cross-platform UserIds so that purchases can be used in different platforms for the same gamer? (I'm referring about the logic even if we have to use our own backend) Example: say you have an iPhone, an Android-based tablet and a PC with steam installed, and the game is available for all those stores and platforms and we want to share your IAPs among those three platforms/devices.
     
  8. CH-M

    CH-M

    Joined:
    Feb 12, 2014
    Posts:
    6
    Thanks, This is great , can you add Fortumo
     
  9. Nyankoooo

    Nyankoooo

    Joined:
    May 21, 2016
    Posts:
    144
    Does this replace the current IAP Service, is it better than the current IAP Service or is it just an alternative for people who don't have much coding knowledge?
     
  10. breban1

    breban1

    Joined:
    Jun 7, 2016
    Posts:
    194
    Does this codeless API include receipt verification, or is that still a manual process?
     
  11. nathanf-unity

    nathanf-unity

    Unity Technologies

    Joined:
    Sep 30, 2016
    Posts:
    4
    Codeless IAP does not replace the existing service—it is built on top of the existing service and intended to help developers who have less coding experience get started with IAP integration.
     
    nicholasr likes this.
  12. Seraphim-Whiteless

    Seraphim-Whiteless

    Joined:
    Jun 23, 2014
    Posts:
    197
    Do not close API functionality please, and make it feature loadable, outside of inapp plugin.
     
  13. arkon

    arkon

    Joined:
    Jun 27, 2011
    Posts:
    1,122
    Hi, I don't use the unity GUI, I use NGUI instead. Is it still possible to use the code less IAP with NGUI?

    Also you say you don't implement non consumable restoration on apples App Store, Apple will reject any app that doesn't allow you to restore purchases. How do you solve this problem?
     
    Last edited: Dec 1, 2016
    Fronne likes this.
  14. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,256
    Just use the regular API...
     
    nicholasr and Fronne like this.
  15. Robiwan

    Robiwan

    Joined:
    Dec 29, 2013
    Posts:
    92
    Hi, just read the announcement of the release Unity 5.5, which also mentions Codeless IAP. Does this means that Codeless IAP is only included in unity and 5.5? Or is it available for previous versions as well?
     
  16. Seraphim-Whiteless

    Seraphim-Whiteless

    Joined:
    Jun 23, 2014
    Posts:
    197
    got it in unity 5.4.2 when update IAP plugin
     
    Robiwan likes this.
  17. Robiwan

    Robiwan

    Joined:
    Dec 29, 2013
    Posts:
    92
    Just got to do my first successful device on iOS from 5.4.3, super happy to finally make it work.

    However I have a huge request, that it think would be super helpful for others as well. I noticed that when I create the IAP button, it comes automatically with a text component. Could it be possible to post a script that fetches the name and price in local currency of the IAP and set that as the text component?

    Also a restore purchase script to drop on a button for restore purchase would also be very much appreciated.
     
  18. jhample

    jhample

    Joined:
    Jul 7, 2012
    Posts:
    47
    It does that already. There are Title, Description, and Price options on the object. Just attach them to the Text objects you want.
     
  19. Fronne

    Fronne

    Joined:
    Sep 25, 2014
    Posts:
    112
    I agree with Baroni, use the regular API to make sure Apple won't reject your App...

    Even better, use Baroni's Asset for IAP, this will save you countless hours of your time trying to reinvent the wheel...
    You can use it with Unity IAP wich is free and worked perfect for me. It also supports other Billing Plugins...
    I implemented this Asset in just a few hours, don't mess with IAP yourself just to save a few bucks if you don't know exactly what you are doing, using a professional Asset like Simple IAP System will guarantee satisfied costumers...
     
    Baroni and nicholasr like this.
  20. arkon

    arkon

    Joined:
    Jun 27, 2011
    Posts:
    1,122
    I know you can use the regular API, but my point is whats the point of touting a code less IAP implementation if it can't create an IAP solution that will pass basic Apple guidelines. Currently if you use this IAP method you will get rejected by apple because they insist on a restore purchases option. This Code less option is basically useless, so why are Unity suggesting it's a solution to the IAP problem?
     
    Fronne likes this.
  21. 009

    009

    Joined:
    Nov 7, 2013
    Posts:
    14
    I would like to know how do I get the price value that I'm already set on the Google Store ?
    It get nothing when I build on phone (But the button is working just the Price / Title /Description Text get nothing)
    What I set in the IAP catalog will shown up in editor play mode but not in the phone.
    Of-course the best way I want is directly get from the google play console

    Thank You
     
  22. 009

    009

    Joined:
    Nov 7, 2013
    Posts:
    14
    Okay............ is working but not on the first time ?? It works after I reactivate it....... Is a bug or?
     
    Last edited: Dec 16, 2016
  23. AVataRR616

    AVataRR616

    Joined:
    Feb 27, 2013
    Posts:
    21
    Hii,

    It seems the codless IAP framework doesn't automatically restore Android purchases. I got the impression from all my reading that it did. Is there a tickbox that I am missing? Or will I need to go back and re-implement some kind of store manager in code?
     
  24. AVataRR616

    AVataRR616

    Joined:
    Feb 27, 2013
    Posts:
    21
    Ah nevermind. It automatically went back up as soon as I loaded my store scene. Is this activated by the IAP purchase buttons?
     
  25. AVataRR616

    AVataRR616

    Joined:
    Feb 27, 2013
    Posts:
    21
    Yep it does!
     
  26. NelepovDS

    NelepovDS

    Joined:
    Nov 2, 2016
    Posts:
    5
  27. ap-unity

    ap-unity

    Unity Technologies

    Joined:
    Aug 3, 2016
    Posts:
    1,519
    @NelepovDS

    What version of Unity and the IAP plugin are you using?

    Did you make any modifications to the IAPButton.cs file?
     
  28. NelepovDS

    NelepovDS

    Joined:
    Nov 2, 2016
    Posts:
    5
    Unity 5.5 (not beta)
    IAP latest version
    upload_2016-12-22_11-34-21.png

    Button setup
    upload_2016-12-22_11-36-0.png

    p.s. try do reimport. No effect.
     
  29. NelepovDS

    NelepovDS

    Joined:
    Nov 2, 2016
    Posts:
    5
    For now i just make copy IAPButton script in my assets and now it work. Will wait fixes.
     
  30. efonsecab

    efonsecab

    Joined:
    Mar 1, 2011
    Posts:
    31
    Does it still need store initialization code when deploying to the stores such as Google Play?
    Like this one? https://docs.unity3d.com/Manual/UnityIAPInitialization.html

    When deploying to HockeyApp should it show something such as the FakeStore?

    I have a small test which works ok in the editor (it's showing the FakeStore), but when deploying to Google Play (in Alpha) or to Hockey App, when pressing the purchase button nothing happens, and the purchase handles for failure is not raised either, again, the store is working ok in the editor for both complete and failure.

    Is there a minimum version of Android supported?
     
    Last edited: Dec 23, 2016
  31. KrystofSuk

    KrystofSuk

    Joined:
    Mar 5, 2015
    Posts:
    1
    Hello guys, I have small problem. When I add non consumable item, ad buy it in play mode. Than reset play mode it is not bought anymore. Is it only in play mode, or I have something bad configured?
    Thanks
     
  32. jsaade

    jsaade

    Joined:
    Nov 29, 2013
    Posts:
    11
    I am having a weird issue when using IAP Button.
    When the player enters the Store page for the first time the prices never show, if he closes the page and re-opens it, then everything is working correctly.
    It seems the Price Text is not being being refreshed? Is there a way to force that behaviour?
     
  33. graemelaws

    graemelaws

    Joined:
    Jan 18, 2017
    Posts:
    3
    @NelepovDS @ap-unity

    I have the same problem, I follow the instructions to add a new IAP button to a scene, set it up with a product, everything works fine, however when I shut down unity and reload, the associated script error appears and I have to set it all up again, I've spent days trying to work out why IAP works sometimes and doesn't other times before I realised reloading Unity was breaking the button. I'll try the solution of copying the script to the assets folder, but it would be nice to see this fixed.

    I'm using Unity 5.5.0x1-CollabPreview.
     
  34. ap-unity

    ap-unity

    Unity Technologies

    Joined:
    Aug 3, 2016
    Posts:
    1,519
    @NelepovDS @graemelaws

    That leads me to think it is related to a bug in 5.5.

    If you go into your Unity Preferences, could you see what the value of "Load Previous Project on Startup"? Try marking that as unchecked. If you have that checked in 5.5, your project will become unlinked from the online service, so Analytics, Ads, IAP, etc won't work.
    LoadProject.png
     
  35. Robiwan

    Robiwan

    Joined:
    Dec 29, 2013
    Posts:
    92
    Is there any simple way to add an Restore purchase button? If possible I would be very grateful if someone can show the script that is need to attach to the Restore button, to make it compliant with Apple.

    Basically all my game is done and just trying to fix this before releasing it on appstore.
    Btw: The game is made with Playmaker, which currently doesn't support IAP, hence the question

    If anyone interested to earn a buck or two helping me out, here is the job invite:

    https://connect.unity.com/jobs/588e5784090915002a61e31f
     
    Last edited: Jan 29, 2017
  36. ap-unity

    ap-unity

    Unity Technologies

    Joined:
    Aug 3, 2016
    Posts:
    1,519
  37. andyasj

    andyasj

    Joined:
    Nov 23, 2016
    Posts:
    18
    I have been trying to test codeless IAP on Google Play but was having problems with restoration.
    Purchasing was working fine but after uninstall/reinstall there was no restore - until I realised that the IAPButton must be active at start of first scene. That means that for me I must place a second IAPButton (linked to the same product) hidden on the splash screen at start up as the proper IAPButton is not active immediately. This is the only way I could get restore to work.
    Is this documented? Is this the desired behaviour? Will there be any problems with 2 buttons linked to the same product?
    Or am I, as usual, missing some obvious point?
     
  38. andyasj

    andyasj

    Joined:
    Nov 23, 2016
    Posts:
    18
    Ammendment to above:
    OnPurchaseComplete is now called at every start up of the app.
    Investigating....
     
  39. andyasj

    andyasj

    Joined:
    Nov 23, 2016
    Posts:
    18
    To sum up:
    After Google purchase/uninstall/reinstall
    • If the IAPButton is placed active in opening scene OnPurchaseComplete() is called on every start up of app.
    • If the IAPButton is active a little later then OnPurchaseComplete is never called and when I click Purchase again there is no action. OnPurchaseComplete and OnPurchaseFailed are not called. There is no restore.
     
  40. andyasj

    andyasj

    Joined:
    Nov 23, 2016
    Posts:
    18
    Update:
    Seems to work OK now I have designed in the one IAPButton to be active (but hidden until later) in the opening scene.
    Please can anyone tell me if it is designed behaviour that the IAP button must be active in the first scene?
    If so, is this or rhould this be documented?
     
  41. andyasj

    andyasj

    Joined:
    Nov 23, 2016
    Posts:
    18
    Aaargh (is that how you spell it?)
    IAPButton active at start of scene does not initialise Title/Description/Price.
    2 IAPButtons are needed for each product (non-consummable).
    • First active but not clickable at first scene start to deal with Google restore.
    • Second set active later to initialise Title/Description/Price. This is the main clickable one.
    This is very clunky. Any comments anyone? Is the IAPButton just not really working yet or am I doing something wrong?
     
  42. andyasj

    andyasj

    Joined:
    Nov 23, 2016
    Posts:
    18
    Finally seems to work:
    Only 1 IAPButton but must be active at start of scene for Google restore.
    Set it inactive in Start().
    Set active again when needed and this initialises Title/Description/Price.
    Works for me with Google Play purchase and restore for non-consummable.
    [Next to try Apple]
     
    rdbdog likes this.
  43. moonabook

    moonabook

    Joined:
    Dec 4, 2014
    Posts:
    4
    Hello.

    The codeless IAP looks amazing, so simple just grab and go. Though I couldn't use it even for the simplest case. As Apple does require 'restore' button and codeless IAP doesn't support it, so I have to use regular API.
    It's ok for me, though it's pity that codeless IAP cannot be used for Apple builds as this approach looks very convenient.

    I posted it as matter of feedback.
    Looking forward for new releases.
     
  44. jsaade

    jsaade

    Joined:
    Nov 29, 2013
    Posts:
    11
    I have been using codeless IAP for a while on google play store.
    Unity analytics is behaving strangely and showing 3000$ sales per day (my app is not making that much).
    I am not sure if it is a receipt verification issue or not as I followed all the steps required.
     
  45. jsaade

    jsaade

    Joined:
    Nov 29, 2013
    Posts:
    11
    So basically no, I added receipt validation (which is a must) to codeless IAP button, so all you need to do is modiy ProcessPurchase in class IAPButton to:

    Code (CSharp):
    1. /**
    2.          *  Invoked to process a purchase of the product associated with this button
    3.          */
    4.         public PurchaseProcessingResult ProcessPurchase (PurchaseEventArgs e)
    5.         {
    6.             Debug.Log(string.Format("IAPButton.ProcessPurchase(PurchaseEventArgs {0} - {1})", e, e.purchasedProduct.definition.id));
    7.             bool validPurchase = true; // Presume valid for platforms with no R.V.
    8.  
    9. #if UNITY_ANDROID || UNITY_IOS || UNITY_STANDALONE_OSX
    10.             var validator = new CrossPlatformValidator(GooglePlayTangle.Data(),
    11.                             AppleTangle.Data(), Application.bundleIdentifier);
    12.  
    13.             try
    14.             {
    15.                 // On Google Play, result has a single product ID.
    16.                 // On Apple stores, receipts contain multiple products.
    17.                 var result = validator.Validate(e.purchasedProduct.receipt);
    18.                 // For informational purposes, we list the receipt(s)
    19.                 Debug.Log("Receipt is valid. Contents:");
    20.                 foreach (IPurchaseReceipt productReceipt in result)
    21.                 {
    22.                     Debug.Log(productReceipt.productID);
    23.                     Debug.Log(productReceipt.purchaseDate);
    24.                     Debug.Log(productReceipt.transactionID);
    25.                 }
    26.             }
    27.             catch (IAPSecurityException)
    28.             {
    29.                 Debug.Log("Invalid receipt, not unlocking content");
    30.                 validPurchase = false;
    31.             }
    32.  
    33. #endif
    34.             if (validPurchase)
    35.                 onPurchaseComplete.Invoke(e.purchasedProduct);
    36.             else
    37.                 onPurchaseFailed.Invoke(e.purchasedProduct, PurchaseFailureReason.SignatureInvalid);
    38.  
    39.             return (consumePurchase) ? PurchaseProcessingResult.Complete : PurchaseProcessingResult.Pending;
    40.         }
    Make sure that you have actually entered your Google Play base64 license key in Unity's menu:
    Window->IAP->Receipt validation ...
     
    toto2003 likes this.
  46. jsaade

    jsaade

    Joined:
    Nov 29, 2013
    Posts:
    11
    It works fine for consumables (like coins) as you do not need a restore button as far as I know.
     
  47. universityofgames

    universityofgames

    Joined:
    Nov 24, 2016
    Posts:
    34
    In one of our applications we came across the same problem. Something has to be on top of things :confused:
     
  48. MPM

    MPM

    Joined:
    Feb 21, 2014
    Posts:
    28
    Hello,
    is there a way to check if the actual Store (the one of the running platform) has been successfully reached by the game?

    My problem is that on my Android device, the IAP buttons appears correctly unless i'm disabling phone's data (incl. WiFi) before starting the game: then, the game will load the FakeStore, which i obviously don't want to happen (i would rather want to display an information message, but i didn't find a way in IapButton.cs to catch the actual store access "failure"). Also, once IapButton has been enabled once without internet, re-enabling it with an active internet will still load the Fake Store.

    @ap-unity
     
    universityofgames likes this.
  49. andyasj

    andyasj

    Joined:
    Nov 23, 2016
    Posts:
    18
    I have a strange problem trying to use codeless IAP on iOS.
    Purchase worked OK (sandbox environment) but after uninstall/reinstall then OnPurchaseComplete is called immediately and my purchase is restored. This can not be the AppStore surely? It must be some cached data not deleted by uninstall? After restore then my test account password is requested - too late - already restored!!
    I have set up a restore button but the code is never called.
    Can anyone shed any light on this?
     
  50. andyasj

    andyasj

    Joined:
    Nov 23, 2016
    Posts:
    18
    Continued...
    I have no iCloud/iTunes syncs and disabling internet stops restore.
    ProcessPurchase/OnPurchaseComplete are being called immediately the scene with my IAPButton starts and immediately before my test account password is requested.
    If I don't enter my password but 'cancel' then the password is requested every subsequent start up.
    This must be a bug surely? At least restore is working, but not as designed.

    Recent IAP update has fixed the issues with Google that I was experiencing a few weeks ago (see above). Brilliant - thanks very much somebody.
     
Thread Status:
Not open for further replies.