[Closed] Codeless API does nothing on build

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*

Have you configured your products on this store? Once this is done, you would want to choose the store target in Unity by going to the Window menu, and then the Unity IAP option. There is more information here Unity - Manual: Codeless IAP

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

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

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.

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.

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.

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.

No problem, i apologize for the miss wording.

So i’ve looked over everything and i still have no idea why its not firing on my device. :confused:

its installed on a Samsung Galaxy Tab A 8.0



3311223--257239--2017-12-04_23-59-24.png

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 Unity Cloud

Also, ensure that you are using a separate email for your testing. Google requires a separate email from your development account for testing.

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)

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.

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)

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

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.

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();
// Begin the asynchronous process of restoring purchases. Expect a confirmation response in
// the Action 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;
}
}
}

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…

i did everything on this page

i also went threw this whole page

The only thing im doign differently is my item names, im not putting com.unity3d.storedemo.ITEM_NAME

im just putting ITEM_NAME. but i realllllllyyyy dont think thats the problem.