Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

IAP initialization without adding products to builder

Discussion in 'Unity IAP' started by michaeltepl, Nov 10, 2020.

  1. michaeltepl

    michaeltepl

    Joined:
    Dec 26, 2013
    Posts:
    22
    Hi! I have a question regarding iap initialization.

    Currently to properly init IAP i have to add products to builder like this:

    Code (CSharp):
    1.         var builder = ConfigurationBuilder.Instance(StandardPurchasingModule.Instance());
    2.         builder.AddProduct("coins_099", ProductType.Consumable);
    3.  
    4.         UnityPurchasing.Initialize(this, builder);
    How can I initialize IAP without adding products? Is there a possibility to get all products defined in Play Console or in AppStore?
     
    Last edited: Nov 10, 2020
  2. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    No, unfortunately that's not possible. You need to specify the products in your code as you are.
     
  3. michaeltepl

    michaeltepl

    Joined:
    Dec 26, 2013
    Posts:
    22
    Do you have any plans to implement this? It would be very useful
     
  4. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    No not at the current time. We actually tried it about 2 years ago, but it was not possible to reliably keep the products in sync with the Apple and Google dashboards
     
  5. michaeltepl

    michaeltepl

    Joined:
    Dec 26, 2013
    Posts:
    22
    Actually I don't think that it is necessary to permanently sync products with dashboards.
    In my app I have no need to show localized price or description before purchasing process started. So ideal scenario for me would be the next:
    1) I receive some package id from my backend at any time, not before calling UnityPurchasing.Initialize(this, builder);
    2) call controller.InitiatePurchase(package id)
    3) If the product is available for purchase then purchase succceeds
    4) If the product is unavailable or not defined in Google Dashboard - receive error ProductUnavailable or smth like this
     
  6. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    I doubt the stores would allow you to fake their product list as you describe, for security. I'm not entirely sure what you mean by "package id". Regardless. the only way to initialize products in Unity IAP is by using the IAP Product Catalog built into the Editor, or by using AddProduct in script

    Code (CSharp):
    1. ProductCatalog catalog = ProductCatalog.LoadDefaultCatalog();
    2.         foreach (ProductCatalogItem product in catalog.allProducts)
    3.         {
    4.             MyDebug("Product = " + product.id);
    5.         }