Search Unity

  1. Unity 2018.3 is now released.
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. Want more efficiency in your development work? Sign up to receive weekly tech and creative know-how from Unity experts.
    Dismiss Notice
  4. Nominations have been announced for this years Unity Awards. Celebrate the wonderful projects made by your peers this year and get voting! Vote here!
    Dismiss Notice
  5. Want to provide direct feedback to the Unity team? Join the Unity Advisory Panel.
    Dismiss Notice
  6. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice

Easy IAP - Make money from your game

Discussion in 'Assets and Asset Store' started by GleyGames, Oct 16, 2018.

?

What other platforms we should create support for?

  1. Amazon Apps

  2. Amazon Underground

  3. CloudMoolah Store

  4. Mac App Store

  5. Samsung GALAXY Apps

  6. Tizen Store

  7. Windows Store

Multiple votes are allowed.
Results are only viewable after voting.
  1. GleyGames

    GleyGames

    Joined:
    Oct 16, 2015
    Posts:
    71
    Easy IAP (In App Purchase)
    Make money from your game
    large.jpg

    Get it now from Asset Store
    For detailed implementation instructions see the Documentation


    Key features:
    • Make in app purchases with minimal setup and very little programming knowledge.
    • Same code for all supported platforms.
    • Just import Easy IAP and add your product IDs and all is done.
    • Can be tested using Unity Editor.
    • Support for Consumable. Non-Consumable and Subscriptions.
    • Easy setup for in app products using a custom made Setttings Window.
    • Works with Unity 5.3 and above and with Free, Plus or Pro versions of Unity.
    Currently supported platforms:
    • Android - Google Play
    • iOS - App Store
    Easy setup from a custom Editor Window:

    addProducts.jpg
    Simple methods to make a purchase that work for all platforms:
    • Initialize plugin
    Code (CSharp):
    1. //call this method only once at the beginning of the game to initialize product information.
    2. IAPManager.Instance.InitializeIAPManager(InitializeResultCallback);
    3.  
    4. //this method will be called after initialization process is done
    5. private void InitializeResultCallback(Status status, string message, List<StoreProduct> shopProducts)
    6. {
    7.      if (status == Status.Success)
    8.      {
    9.           //IAP was successfully initialized
    10.           //loop through all products
    11.           for (int i = 0; i < shopProducts.Count; i++)
    12.           {
    13.                if (shopProducts[i].productName == "YourProductName")
    14.                {
    15.                     //if active variable is true, means that user had bought that product
    16.                     //so enable access
    17.                     if (shopProducts[i].active)
    18.                     {
    19.                          yourBoolVariable = true;
    20.                     }
    21.                }
    22.           }
    23.      }
    24.      else
    25.      {
    26.           Debug.Log(“Error occurred ”+ message);
    27.      }
    28. }
    • Buy product
    Code (CSharp):
    1. IAPManager.Instance.BuyProduct(ShopProductNames.YourProductName, ProductBoughtCallback);
    2.  
    3. // automatically called after one product is bought
    4. // this is an example of product bought callback
    5. private void ProductBoughtCallback(Status status, string message, StoreProduct product)
    6. {
    7.      if (status == Status.Success)
    8.      {
    9.           //each consumable gives coins in this example
    10.           if (product.productType == ProductType.Consumable)
    11.           {
    12.                coins += product.value;
    13.           }
    14.  
    15.           //non consumable Unlock Level 1 -> unlocks level 1 so we set the corresponding bool to true
    16.           if (product.productName == "UnlockLevel1")
    17.           {
    18.                unlockLevel1 = true;
    19.           }
    20.  
    21.           //subscription has been bought so we set our subscription variable to true
    22.           if (product.productName == "Subscription")
    23.           {
    24.                subscription = true;
    25.           }
    26.      }
    27.      else
    28.      {
    29.           //an error occurred in the buy process, log the message for more details
    30.           Debug.Log("Buy product failed: " + message);
    31.      }
    32. }
    • Restore Purchases
    Code (CSharp):
    1. //only required for iOS App Store
    2. //restores previously bought products
    3. //this is also done automatically every time at initialize
    4. IAPManager.Instance.RestorePurchases(ProductRestoredCallback);
    5.  
    6. // this is an example of product restored callback
    7. private void ProductRestoredCallback(Status status, string message, StoreProduct product)
    8. {
    9.      if (status == Status.Success)
    10.      {
    11.           //consumable products are not restored
    12.           //non consumable Unlock Level 1 -> unlocks level 1 so we set the corresponding bool to true
    13.           if (product.productName == "UnlockLevel1")
    14.           {
    15.                unlockLevel1 = true;
    16.           }
    17.  
    18.           //subscription has been bought so we set our subscription variable to true
    19.           if (product.productName == "Subscription")
    20.           {
    21.                subscription = true;
    22.           }
    23.      }
    24.      else
    25.      {
    26.           //an error occurred in the buy process, log the message for more details
    27.           Debug.Log("Buy product failed: " + message);
    28.      }
    29. }
    For a complete list of methods check the Documentation

    Any suggestions are always welcome, we will consider them for future updates.

    We also made some tutorials on how to test your products on Google Play:


    And also for iOS:


    We also made a detailed step by step tutorial on how to create IAP products, upload builds to alpha, test IAP products and create a basic shop in your game. Here is a complete playlist:
    https://www.youtube.com/playlist?list=PLKeb94eicHQumyCLcJbprEgOhyKc2Q7EQ



     
    Last edited: Nov 12, 2018
  2. GleyGames

    GleyGames

    Joined:
    Oct 16, 2015
    Posts:
    71
    Version 1.1.0 in now available on Asset Store

    Changes in this version:
    • Fixed compatibility issue with other external packages. Now the plugin is compatible with all other plugins used in your app.
    • Minor fixes in settings window.
     
  3. Adswars

    Adswars

    Joined:
    Jun 28, 2015
    Posts:
    8
    I not sure how RestorePurchase works.
    If user bought more both UnlockLevel1 and Subscription (from example above) then when this command call

    IAPManager.Instance.RestorePurchases(ProductRestoredCallback);

    Which product will restore the purchase?
     
  4. GleyGames

    GleyGames

    Joined:
    Oct 16, 2015
    Posts:
    71
    Hello,

    Thank you for your interest in our plugins.

    If you call this method it will be restored all product marked as Non Consumable and Subscription.
    The product marked as consumable are not restored.
     
    Adswars likes this.