Domanda

I am currently setting up in-app billing for a Unity-based Android game I've made, and I'm using the OpenIAB plugin to do so. I'm only testing with the Google Play store for now.

I have published the in-app products already via the developer console; I am working with an APK that is published as a Beta; I am testing the game on a device on which the primary e-mail is one of the assigned testers, and I have the test response set to LICENSE, in case that matters.

When using OpenIAB, I basically just have to call the OpenIAB.purchaseProduct(string) function and pass "the SKU". I am not entirely sure what form of a string I have to pass, but so far I have been trying these combinations:

  • "sku_name"
  • "com.CompanyName.ProductName.sku_name"
  • "com.companyname.productname.sku_name"

All of these SKU identifiers produced a "The item you were attempting to purchase could not be found" error message. I am quite certain I am spelling "sku_name" correctly. The implementation of purchaseProduct() and its requisite variable _plugin is as follows (this is from the OpenIAB plugin source code, not me):

private static AndroidJavaObject _plugin;

        static OpenIAB_Android() {
            if (Application.platform != RuntimePlatform.Android) {
                STORE_GOOGLE = "STORE_GOOGLE";
                STORE_AMAZON = "STORE_AMAZON";
                STORE_TSTORE = "STORE_TSTORE";
                STORE_SAMSUNG = "STORE_SAMSUNG";
                STORE_YANDEX = "STORE_YANDEX";
                return;
            }

            AndroidJNI.AttachCurrentThread();

            // Find the plugin instance
            using (var pluginClass = new AndroidJavaClass("org.onepf.openiab.UnityPlugin")) {
                _plugin = pluginClass.CallStatic<AndroidJavaObject>("instance");
                STORE_GOOGLE = pluginClass.GetStatic<string>("STORE_GOOGLE");
                STORE_AMAZON = pluginClass.GetStatic<string>("STORE_AMAZON");
                STORE_TSTORE = pluginClass.GetStatic<string>("STORE_TSTORE");
                STORE_SAMSUNG = pluginClass.GetStatic<string>("STORE_SAMSUNG");
                STORE_YANDEX = pluginClass.GetStatic<string>("STORE_YANDEX");
            }
        }

        private bool IsDevice() {
            if (Application.platform != RuntimePlatform.Android) {
                //OpenIAB.EventManager.SendMessage("OnBillingNotSupported", "editor mode");
                return false;
            }
            return true;
        }

public void purchaseProduct(string sku, string developerPayload="") {
            if (!IsDevice()) {
                // Fake purchase in editor mode
                OpenIAB.EventManager.SendMessage("OnPurchaseSucceeded", Purchase.CreateFromSku(sku, developerPayload).Serialize());
                return;
            }
            _plugin.Call("purchaseProduct", sku, developerPayload);
        }

I don't really know what developerPayload is supposed to be. I'm not doing anything special other than calling OpenIAB.purchaseProduct() - perhaps I am forgetting something.

Can anyone offer any guidance or ideas as to how to make sure I am actually requesting the proper products?

È stato utile?

Soluzione

If you are unsure about your Google IAP sku. Look under the In-App Products tab, and see the id under "Name/ID". The sku is in the bracket. E.g. the sku is "def" if it is "abc (def)".

Therefore, you just have to call OpenIAB.purchaseProduct("def") to purchase your product.

I am not sure if this will affect the testing, please check at Google Dev, the main account "settings/Gmail accounts with testing access" and add your gmail account there.

Hope it helps.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top