Search Unity

[Closed] Codeless API does nothing on build

Discussion in 'Unity IAP' started by sniffle63, Dec 3, 2017.

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

    sniffle63

    Joined:
    Aug 31, 2013
    Posts:
    365
    Im confused on how the codeless IAP works, in the editor it opens the Fake UI screen for purchasing, but what is it suppose to do in the build version? Am i supposed to create the purchasing part myself and put it into the codeless IAP to copy what the fake one does but with my graphics? Or how exactly is this expected to be used



    • Description of your issue
      • Import codeless IAP. Click run. See fake UI. Build game try to buy item see nothing
    • Your purchasing script
      • Codeless IAP, it's your code not mine.
    • Device logs
      • What logs do you want? its suppose to be codeless and no where anywhere does it say anything about me having to do anythign beyond device catalog and adding a button. So why does it do nothing on build?
    • Unity Version
      • 2017.1.1
    • Unity IAP version
      • 1.14.1
    • Platform you are building for
    • Android
    • Store you are targeting
      Play store
     
    Last edited: Dec 4, 2017
  2. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
  3. sniffle63

    sniffle63

    Joined:
    Aug 31, 2013
    Posts:
    365
    Yes of course they are set up in the store, iv rad threw that "manual" page 20 times now. The button just fires nothing, and no errors are logged.


    Im using a testing account set up on my Alpha page that is not the dev account downloaded the apk from the play store, clicked the buy button and nothing happens.


    What is the fake UI? No where anywhere seems to explain that and how its suppose to be replaced with your actual UI
     
  4. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    We offer IAP buttons that you would drop into your own UI. You would then link each button with the corresponding store product. Window->Unity IAP->Create IAP Button
     
  5. sniffle63

    sniffle63

    Joined:
    Aug 31, 2013
    Posts:
    365
    Yeah, i think i had already mentioned im using the codeless IAP?

    I really have no idea how i could of got the fake UI to open or know that the button works in editor but not in build, if i didnt already know how to add the codeless IAP button into the scene already.

    And my original question from the original post is still being ignored

    What is the fake UI that is launched when in the editor? Is it replaceable? Is it an editor version of the phoen purchasing pop up? Is it a confirmation page before the phone pop up.
     
    Last edited: Dec 4, 2017
  6. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Yes, I understand that you are using Codeless IAP. The fake UI is just that, an example UI. You are likely opening the "IAP Demo" scene that is included in the IAP Plugin. It's the one with two columns, Item and Purchased, with 100.gold.coins as the first product, and the Buy button at the bottom. If you are seeing something different, please post a screenshot. You instead would likely want to create your own scene, and drop a single IAP Button onto it to get started, and link that to one of your products. And to answer your original question, the answer is no, that is not the expectation. But instead, as I've described.
     
  7. sniffle63

    sniffle63

    Joined:
    Aug 31, 2013
    Posts:
    365
    Im not using the IAP demo, it's implemented in and works with the fake UI. Just nothing pops up on the build version.

    This is what i was looking for:
    The unity3d Fake UI that launches when the codeless IAP is being tested in the editor environment is a replication of the system UI of the device you will be building for.
     
    Last edited: Dec 4, 2017
  8. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Sorry for the confusion. I see now that you are referring to the UI that shows up AFTER you initiate a purchase. Your original description missed this part "Import codeless IAP. Click run. See fake UI. Build game try to buy item see nothing". I thought you were referring to your game scene UI with the buttons, etc. After re-reading however, I see what you mean, sorry about that.
     
  9. sniffle63

    sniffle63

    Joined:
    Aug 31, 2013
    Posts:
    365
    No problem, i apologize for the miss wording.
     
  10. sniffle63

    sniffle63

    Joined:
    Aug 31, 2013
    Posts:
    365
    So i've looked over everything and i still have no idea why its not firing on my device. :/

    its installed on a Samsung Galaxy Tab A 8.0
     

    Attached Files:

  11. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Please provide the full device logs, this should give us more information as to what is occurring on the device. I suspect your initialization is failing. Also, if you want, you could open a support ticket and send us the APK, and I could test directly here. You can open a support ticket here https://analytics.cloud.unity3d.com/support
     
  12. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Also, ensure that you are using a separate email for your testing. Google requires a separate email from your development account for testing.
     
  13. sniffle63

    sniffle63

    Joined:
    Aug 31, 2013
    Posts:
    365
    I placed a support ticket. And we tried it on a few different devices with different emails. My assumption is the initialization is failing also, but im unable to connect my android to my computer to receive the device logs because unity says something about my USB port being broken, when i build to device. Works fine on PTP from the editor play tho lol. (samsung galaxy tab A 8.0)

    Im instantiating a single IAP button when my shop opens and then when you click on different stuff in the shop it changes the values of that button. Im guessing that's probably not how the button is suppose to work (i just assumed it was fine, because it works to completion in the editor)
     
    Last edited: Dec 6, 2017
  14. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    You might want to implement the basic functionality of the Codeless IAP button, and allow it to purchase the single configured product instead of multiple products. Usually each product has it's own IAP button.
     
  15. sniffle63

    sniffle63

    Joined:
    Aug 31, 2013
    Posts:
    365
    Ok ill at least try setting up the oen button in the window to only buy one item, to see if it will fire. Should i should swap the buttons in and out as you click on new items in the shop then? (because the purchase button is always in one spot and the different items are in a list on our UI set up)
     
  16. sniffle63

    sniffle63

    Joined:
    Aug 31, 2013
    Posts:
    365
    i set the button to already be set to the settings of the skin_tank, so its not adjusting settings threw code. But still nothing fires. I have the version with literally just the codeless IAP button with the settings already set up on my shop menu uploaded to alpha on google play. I also gave you access to the bit bucket
     
  17. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    While you are getting familiar with Unity IAP and Android development, I might recommend using a separate project, with just a single IAP button associated with a single product. That is the approach that I took while learning. Get the basics working first before trying to script custom behavior.
     
  18. alexchandriyaa

    alexchandriyaa

    Joined:
    Jan 18, 2017
    Posts:
    140
    guys i have the same issue.. working very cool in editor but not in phone apk. i have created seaprate project and tried not working.. one week before i tried with separate project and that worls both in phone and editor after that i have implemented in my project also it worked but suddenly it stops working i didnt add or remove anything in the project. yesterday it works upto noon after that i added player prefs after that its not working and now i removed all my own code and done in new project even then it is not working. i tried with debug and checked yesterday i had an error purchasing initialisation is not correct but i didnt initialize anything i just copied from unity IAP tutorial tats it then i added my few codes after that debug mode also not workig

    my code:
    using System;
    using System.Collections.Generic;
    using UnityEngine;
    using UnityEngine.Purchasing;


    // Deriving the Purchaser class from IStoreListener enables it to receive messages from Unity Purchasing.
    using UnityEngine.UI;


    public class Purchaser : MonoBehaviour, IStoreListener
    {
    private static IStoreController m_StoreController; // The Unity Purchasing system.
    private static IExtensionProvider m_StoreExtensionProvider; // The store-specific Purchasing subsystems.


    public static string kProductIDConsumable = "100";
    public static string kProductIDNonConsumable = "200";
    public static string kProductIDSubscription = "subscription";

    // Apple App Store-specific product identifier for the subscription product.
    private static string kProductNameAppleSubscription = "com.unity3d.subscription.new";

    // Google Play Store-specific product identifier subscription product.
    private static string kProductNameGooglePlaySubscription = "com.unity3d.subscription.original";

    public int goldBar;
    public static int goldBarStore;
    public Text goldBarAmount;
    public Button goldBarButton;


    void Start()
    {

    // If we haven't set up the Unity Purchasing reference
    if (m_StoreController == null)
    {
    // Begin to configure our connection to Purchasing
    InitializePurchasing();
    }
    }

    public void Update()
    {

    CheckGoldBar ();
    CheckGoldBarLess ();
    goldBarAmount.text = PlayerPrefs.GetInt("GoldBar :",goldBarStore).ToString();


    }
    public void InitializePurchasing()
    {
    // If we have already connected to Purchasing ...
    if (IsInitialized())
    {
    // ... we are done here.
    return;
    }

    // Create a builder, first passing in a suite of Unity provided stores.
    var builder = ConfigurationBuilder.Instance(StandardPurchasingModule.Instance());

    // Add a product to sell / restore by way of its identifier, associating the general identifier
    // with its store-specific identifiers.
    builder.AddProduct(kProductIDConsumable, ProductType.Consumable);
    // Continue adding the non-consumable product.
    builder.AddProduct(kProductIDNonConsumable, ProductType.NonConsumable);
    // And finish adding the subscription product. Notice this uses store-specific IDs, illustrating
    // if the Product ID was configured differently between Apple and Google stores. Also note that
    // one uses the general kProductIDSubscription handle inside the game - the store-specific IDs
    // must only be referenced here.
    builder.AddProduct(kProductIDSubscription, ProductType.Subscription, new IDs(){
    { kProductNameAppleSubscription, AppleAppStore.Name },
    { kProductNameGooglePlaySubscription, GooglePlay.Name },
    });

    // Kick off the remainder of the set-up with an asynchrounous call, passing the configuration
    // and this class' instance. Expect a response either in OnInitialized or OnInitializeFailed.
    UnityPurchasing.Initialize(this, builder);
    }


    private bool IsInitialized()
    {
    // Only say we are initialized if both the Purchasing references are set.
    return m_StoreController != null && m_StoreExtensionProvider != null;
    }


    public void BuyConsumable()
    {
    BuyProductID(kProductIDConsumable);
    }


    public void BuyNonConsumable()
    {

    BuyProductID(kProductIDNonConsumable);
    }


    public void BuySubscription()
    {

    BuyProductID(kProductIDSubscription);
    }


    void BuyProductID(string productId)
    {
    // If Purchasing has been initialized ...
    if (IsInitialized())
    {

    Product product = m_StoreController.products.WithID(productId);

    // If the look up found a product for this device's store and that product is ready to be sold ...
    if (product != null && product.availableToPurchase)
    {
    Debug.Log(string.Format("Purchasing product asychronously: '{0}'", product.definition.id));

    m_StoreController.InitiatePurchase(product);
    }
    // Otherwise ...
    else
    {
    // ... report the product look-up failure situation
    Debug.Log("BuyProductID: FAIL. Not purchasing product, either is not found or is not available for purchase");
    }
    }
    // Otherwise ...
    else
    {
    // ... report the fact Purchasing has not succeeded initializing yet. Consider waiting longer or
    // retrying initiailization.
    Debug.Log("BuyProductID FAIL. Not initialized.");
    }
    }


    public void RestorePurchases()
    {
    // If Purchasing has not yet been set up ...
    if (!IsInitialized())
    {
    // ... report the situation and stop restoring. Consider either waiting longer, or retrying initialization.
    Debug.Log("RestorePurchases FAIL. Not initialized.");
    return;
    }

    // If we are running on an Apple device ...
    if (Application.platform == RuntimePlatform.IPhonePlayer ||
    Application.platform == RuntimePlatform.OSXPlayer)
    {
    // ... begin restoring purchases
    Debug.Log("RestorePurchases started ...");

    // Fetch the Apple store-specific subsystem.
    var apple = m_StoreExtensionProvider.GetExtension<IAppleExtensions>();
    // Begin the asynchronous process of restoring purchases. Expect a confirmation response in
    // the Action<bool> below, and ProcessPurchase if there are previously purchased products to restore.
    apple.RestoreTransactions((result) => {
    // The first phase of restoration. If no more responses are received on ProcessPurchase then
    // no purchases are available to be restored.
    Debug.Log("RestorePurchases continuing: " + result + ". If no further messages, no purchases available to restore.");
    });
    }
    // Otherwise ...
    else
    {
    // We are not running on an Apple device. No work is necessary to restore purchases.
    Debug.Log("RestorePurchases FAIL. Not supported on this platform. Current = " + Application.platform);
    }
    }


    //
    // --- IStoreListener
    //

    public void OnInitialized(IStoreController controller, IExtensionProvider extensions)
    {
    // Purchasing has succeeded initializing. Collect our Purchasing references.
    Debug.Log("OnInitialized: PASS");

    // Overall Purchasing system, configured with products for this application.
    m_StoreController = controller;
    // Store specific subsystem, for accessing device-specific store features.
    m_StoreExtensionProvider = extensions;
    }


    public void OnInitializeFailed(InitializationFailureReason error)
    {
    // Purchasing set-up has not succeeded. Check error for reason. Consider sharing this reason with the user.
    Debug.Log("OnInitializeFailed InitializationFailureReason:" + error);
    }


    public PurchaseProcessingResult ProcessPurchase(PurchaseEventArgs args)
    {
    // A consumable product has been purchased by this user.
    if (String.Equals(args.purchasedProduct.definition.id, kProductIDConsumable, StringComparison.Ordinal))
    {
    Debug.Log(string.Format("ProcessPurchase: PASS. Product: '{0}'", args.purchasedProduct.definition.id));
    Debug.Log ("100");
    int.TryParse(goldBarAmount.text, out goldBar);
    goldBarAmount.text = goldBar.ToString();
    goldBarStore = goldBar + 5;
    PlayerPrefs.SetInt ("GoldBar :", goldBarStore);
    Debug.Log ("100BAck");
    // The consumable item has been successfully purchased, add 100 coins to the player's in-game score.

    }
    // Or ... a non-consumable product has been purchased by this user.
    else if (String.Equals(args.purchasedProduct.definition.id, kProductIDNonConsumable, StringComparison.Ordinal))
    {
    Debug.Log(string.Format("ProcessPurchase: PASS. Product: '{0}'", args.purchasedProduct.definition.id));
    Debug.Log ("200");
    int.TryParse(goldBarAmount.text, out goldBar);
    goldBarAmount.text = goldBar.ToString();
    goldBarStore = goldBar + 10;
    PlayerPrefs.SetInt ("GoldBar :", goldBarStore);
    Debug.Log ("200back");
    // TODO: The non-consumable item has been successfully purchased, grant this item to the player.
    }
    // Or ... a subscription product has been purchased by this user.
    else if (String.Equals(args.purchasedProduct.definition.id, kProductIDSubscription, StringComparison.Ordinal))
    {
    Debug.Log(string.Format("ProcessPurchase: PASS. Product: '{0}'", args.purchasedProduct.definition.id));
    // TODO: The subscription item has been successfully purchased, grant this to the player.
    }
    // Or ... an unknown product has been purchased by this user. Fill in additional products here....
    else
    {
    Debug.Log(string.Format("ProcessPurchase: FAIL. Unrecognized product: '{0}'", args.purchasedProduct.definition.id));
    }

    // Return a flag indicating whether this product has completely been received, or if the application needs
    // to be reminded of this purchase at next app launch. Use PurchaseProcessingResult.Pending when still
    // saving purchased products to the cloud, and when that save is delayed.
    return PurchaseProcessingResult.Complete;
    }


    public void OnPurchaseFailed(Product product, PurchaseFailureReason failureReason)
    {
    // A product purchase attempt did not succeed. Check failureReason for more detail. Consider sharing
    // this reason with the user to guide their troubleshooting actions.
    Debug.Log(string.Format("OnPurchaseFailed: FAIL. Product: '{0}', PurchaseFailureReason: {1}", product.definition.storeSpecificId, failureReason));
    }
    public void GoldBarReduce()

    {
    int.TryParse(goldBarAmount.text, out goldBar);
    goldBarAmount.text = goldBar.ToString();
    goldBarStore = goldBar - 1;
    PlayerPrefs.SetInt ("GoldBar :", goldBarStore);
    }

    public void CheckGoldBar()
    {
    if (PlayerPrefs.GetInt ("GoldBar :") >= 1) {

    goldBarButton.interactable = true;

    }
    }
    public void CheckGoldBarLess()
    {
    if (PlayerPrefs.GetInt ("GoldBar :") == 0)
    {
    goldBarButton.interactable = false;
    }
    }
    }
     
  19. sniffle63

    sniffle63

    Joined:
    Aug 31, 2013
    Posts:
    365
    i actually switched over to script similar to yours after giving up on the codless IAP and it still does the same thing, works in editor. Nothing in build..... really starting to become frustrating.... been like a week now.

    I logged every debug in the Unity IAP purchasing script to a LOG UI text canvas i made and no debugs at all launched from my button and absolutely nothing happened in build. Worked 5000% fine in the editor. Im so tired of trying to fix a problem that i dont believe is mine.... iv read threw every post and topic on the first 20 pages of google. I dont know what to do from this point........
     
  20. sniffle63

    sniffle63

    Joined:
    Aug 31, 2013
    Posts:
    365
  21. sniffle63

    sniffle63

    Joined:
    Aug 31, 2013
    Posts:
    365
    Iv determined that "m_StoreController && m_StoreExtensionProvider" are both returning null. Not sure why tho... i followed the google play console setup in the unity manual to the tee on 3 different projects now. All with the same result. Tried it with 2 cloud build published game, and tried it with 1 local built published game. Same thing happens on all three, works fine in editor. Rturns null for 'm_StoreController && m_StoreExtensionProvider' on build
     
  22. sniffle63

    sniffle63

    Joined:
    Aug 31, 2013
    Posts:
    365
    Heres my errors from android studios


    12-09 15:03:12.487 10255-10786/com.GhostTReasureGames.FinalJumper I/UnityAds: com.unity3d.ads.api.Sdk.logInfo() (line:70) :: Received configuration with 2 placements for gamer 50507b163822f20000000001 (A/B group 1)
    12-09 15:03:12.577 10255-10401/com.GhostTReasureGames.FinalJumper I/UnityIAP: IAB helper created.
    12-09 15:03:12.767 10255-10401/com.GhostTReasureGames.FinalJumper I/UnityIAP: Starting in-app billing setup.
    12-09 15:03:12.767 10255-10255/com.GhostTReasureGames.FinalJumper I/UnityIAP: Billing service connected.
    12-09 15:03:12.777 10255-10827/com.GhostTReasureGames.FinalJumper I/UnityIAP: invoking callback
    12-09 15:03:12.777 10255-10827/com.GhostTReasureGames.FinalJumper I/UnityIAP: Checking for in-app billing 3 support.
    12-09 15:03:12.787 10255-10827/com.GhostTReasureGames.FinalJumper I/UnityIAP: In-app billing version 3 supported for com.GhostTReasureGames.FinalJumper
    12-09 15:03:12.787 10255-10827/com.GhostTReasureGames.FinalJumper I/UnityIAP: Subscriptions AVAILABLE.
    12-09 15:03:12.797 10255-10786/com.GhostTReasureGames.FinalJumper I/UnityAds: com.unity3d.ads.api.Sdk.logInfo() (line:70) :: Requesting ad plan from https://auction.unityads.unity3d.co...etworkType=0&gamerId=50507b163822f20000000001
    12-09 15:03:12.797 10255-10827/com.GhostTReasureGames.FinalJumper I/UnityIAP: VR purchases NOT AVAILABLE. Response: 3
    12-09 15:03:12.797 10255-10823/com.GhostTReasureGames.FinalJumper I/System.out: (HTTPLog)-Static: isSBSettingEnabled false
    12-09 15:03:12.797 10255-10823/com.GhostTReasureGames.FinalJumper I/System.out: (HTTPLog)-Static: isSBSettingEnabled false
    12-09 15:03:12.797 10255-10827/com.GhostTReasureGames.FinalJumper I/UnityIAP: onIabSetupFinished: 0
    12-09 15:03:12.797 10255-10827/com.GhostTReasureGames.FinalJumper I/UnityIAP: Requesting 1 products
    12-09 15:03:12.797 10255-10827/com.GhostTReasureGames.FinalJumper I/UnityIAP: QueryInventory: 1
    12-09 15:03:12.797 10255-10827/com.GhostTReasureGames.FinalJumper I/UnityIAP: invoking callback
    12-09 15:03:12.797 10255-10827/com.GhostTReasureGames.FinalJumper I/UnityIAP: Querying owned items, item type: inapp
    12-09 15:03:12.797 10255-10827/com.GhostTReasureGames.FinalJumper I/UnityIAP: Package name: com.GhostTReasureGames.FinalJumper
    12-09 15:03:12.797 10255-10827/com.GhostTReasureGames.FinalJumper I/UnityIAP: Calling getPurchases with continuation token: null
    12-09 15:03:12.807 10255-10827/com.GhostTReasureGames.FinalJumper I/UnityIAP: Owned items response: 0
    12-09 15:03:12.807 10255-10827/com.GhostTReasureGames.FinalJumper I/UnityIAP: Continuation token: null
    12-09 15:03:12.807 10255-10827/com.GhostTReasureGames.FinalJumper I/UnityIAP: Querying SKU details.
    12-09 15:03:12.887 10255-10827/com.GhostTReasureGames.FinalJumper I/UnityIAP: getSkuDetails() failed: 6:Error
    12-09 15:03:12.887 10255-10827/com.GhostTReasureGames.FinalJumper I/UnityIAP: onQueryInventoryFinished: false
    12-09 15:03:12.887 10255-10827/com.GhostTReasureGames.FinalJumper I/UnityIAP: Error refreshing inventory (querying prices of items). (response: 6:Error)
    12-09 15:03:12.887 10255-10827/com.GhostTReasureGames.FinalJumper I/UnityIAP: Failed to Query inventory. UnityIAP will automatically retry in 5000ms
    12-09 15:03:12.887 10255-10827/com.GhostTReasureGames.FinalJumper I/UnityIAP: QueryInventory: 1
    12-09 15:03:12.887 10255-10827/com.GhostTReasureGames.FinalJumper I/UnityIAP: invoking callback
    12-09 15:03:12.957 10255-10401/com.GhostTReasureGames.FinalJumper I/UnityIAP: Requesting 1 products
    12-09 15:03:12.957 10255-10401/com.GhostTReasureGames.FinalJumper I/UnityIAP: QueryInventory: 1
     
  23. alexchandriyaa

    alexchandriyaa

    Joined:
    Jan 18, 2017
    Posts:
    140
    for me
    i got an error like this purchase failed because purchase was not initialized correctly

    what i have to do now?? i have checked initialization of both inapp products (developer console) and in code
     
  24. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    @alexchandriyaa What email are you using to log into your device? It should be the email that was sent to you from the Google Play console when you configured testers in your Alpha test, and not your developer email.
     
  25. alexchandriyaa

    alexchandriyaa

    Joined:
    Jan 18, 2017
    Posts:
    140
    1.unity version 2017.2.0
    2.developing for android
    3.am using testers mail id which i gave in console am sure that am not using developer account
    4.one error in device log "purchase is not initialized correctly"
    5.i created new project and new product id in developer console even then its not working, it is working fine in editor but not in build
    6. i have followed the same steps in this link https://docs.unity3d.com/Manual/UnityIAPGoogleConfiguration.html
     

    Attached Files:

  26. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Be sure you download the APK from the testing link on the Google console or from the tester email that was received. If you installed directly from Unity using Build/Run, you will need to remove that version. If possible, please provide device log output using logcat which provides additional logging detail. And please be sure to reply on only a single thread.
     
    Last edited: Dec 12, 2017
  27. svwillia

    svwillia

    Joined:
    Aug 28, 2014
    Posts:
    48
    I am also having the same issues. I cannot find a solution anywhere.

    Codeless IAP is broken, the button keep resetting on build and scene swap. It also works in editor but does nothing in the builds.

    I had the same issues with traditional scripts and tried with the IAP Manager. Is there any quicker way for us all to get support for this?
     
  28. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    @svwillia Please do not cross post. Please open a support ticket.
     
Thread Status:
Not open for further replies.