/// <summary> /// Use to when the user wants to buy a IAP. /// </summary> /// <param name="inAppID">IAP Object</param> /// <param name="buyCallback">The callback that fires when done.</param> public void Buy(InAppPurchaseID inAppID, InAppPurchaseBuyCallbackMethod buyCallback) { Buy(inAppID.ID, buyCallback); }
void Start() { // bind button events BuyDurableButton.Select(); BuyDurableButton.onClick.AddListener(buyDurableClicked); BuyConsumableButton.onClick.AddListener(buyConsumableClicked); RestoreButton.onClick.AddListener(restoreClicked); GetPriceInfoButton.onClick.AddListener(getPriceInfoClicked); BackButton.onClick.AddListener(backClicked); // make sure we don't init the same IAP items twice if (created) return; created = true; // InApp-Purchases - NOTE: you can set different "In App IDs" for each platform. var inAppIDs = new InAppPurchaseID[3]; inAppIDs[0] = new InAppPurchaseID(item1, 1.99m, "$", InAppPurchaseTypes.NonConsumable); inAppIDs[1] = new InAppPurchaseID(item2, 0.99m, "$", InAppPurchaseTypes.NonConsumable); inAppIDs[2] = new InAppPurchaseID(item3, 2.49m, "$", InAppPurchaseTypes.Consumable); // create desc object var desc = new InAppPurchaseDesc(); // Global desc.Testing = true; desc.ClearNativeCache = false; // Editor desc.Editor_InAppIDs = inAppIDs; // WinRT desc.WinRT_InAppPurchaseAPI = InAppPurchaseAPIs.MicrosoftStore; desc.WinRT_MicrosoftStore_InAppIDs = inAppIDs; // WP8 desc.WP8_InAppPurchaseAPI = InAppPurchaseAPIs.MicrosoftStore; desc.WP8_MicrosoftStore_InAppIDs = inAppIDs; // BB10 desc.BB10_InAppPurchaseAPI = InAppPurchaseAPIs.BlackBerryWorld; desc.BB10_BlackBerryWorld_InAppIDs = inAppIDs; // iOS desc.iOS_InAppPurchaseAPI = InAppPurchaseAPIs.AppleStore; desc.iOS_AppleStore_InAppIDs = inAppIDs; desc.iOS_AppleStore_SharedSecretKey = "";// NOTE: Must set SharedSecretKey, even for Testing! // Android // Choose for either GooglePlay or Amazon. // NOTE: Use "player settings" to define compiler directives. #if AMAZON desc.Android_InAppPurchaseAPI = InAppPurchaseAPIs.Amazon; #elif SAMSUNG desc.Android_InAppPurchaseAPI = InAppPurchaseAPIs.Samsung; #else desc.Android_InAppPurchaseAPI = InAppPurchaseAPIs.GooglePlay; #endif desc.Android_GooglePlay_InAppIDs = inAppIDs; desc.Android_GooglePlay_Base64Key = "";// NOTE: Must set Base64Key for GooglePlay in Apps to work, even for Testing! desc.Android_Amazon_InAppIDs = inAppIDs; desc.Android_Samsung_InAppIDs = inAppIDs; desc.Android_Samsung_ItemGroupID = ""; // init InAppPurchaseManager.Init(desc, createdCallback); }