static StoreKitManager() { AbstractManager.initialize(typeof(StoreKitManager)); // we ignore the results of this call because our only purpose is to trigger the creation of the required listener on the native side for transaction processing. StoreKitBinding.canMakePayments(); }
public void InitialiseStoreKit() { canMakePayments = StoreKitBinding.canMakePayments(); Debug.Log("StoreKit canMakePayments: " + canMakePayments); if (isFree) { var productIdentifiers = new string[] { "com.DMDEnterprise.kicktheballfree.100coins", "com.DMDEnterprise.kicktheballfree.250coins", "com.DMDEnterprise.kicktheballfree.500coins", "com.DMDEnterprise.kicktheballfree.1500coins", "com.DMDEnterprise.kicktheballfree.3000coins", "com.DMDEnterprise.kicktheballfree.5000coins" }; StoreKitBinding.requestProductData(productIdentifiers); } else { var productIdentifiers = new string[] { "com.immanitas.KickTheBall.100coins", "com.immanitas.KickTheBall.250coins", "com.immanitas.KickTheBall.500coins", "com.immanitas.KickTheBall.1500coins", "com.immanitas.KickTheBall.3000coins", "com.immanitas.KickTheBall.5000coins" }; StoreKitBinding.requestProductData(productIdentifiers); } }
void myMakePurchaseMethod(UpsightPurchase purchase) { if (purchase != null) { # if UNITY_IPHONE if (StoreKitBinding.canMakePayments()) { StoreKitBinding.purchaseProduct(purchase.productIdentifier, purchase.quantity); } # endif # if UNITY_ANDROID
public override void Start() { base.Start(); Debug.Log("iOS billing is starting."); _canMakePayments = StoreKitBinding.canMakePayments(); Debug.Log("IOBilling. Can make payments:" + _canMakePayments); if (_canMakePayments) { Debug.Log("iOSBilling. Request Product data:"); StoreKitBinding.requestProductData(MarketLot.AllLots.Select(l => l.ProductIOSIdentifier).ToArray()); } }
void Start() { LanguageManager thisLanguageManager = LanguageManager.Instance; welcome.text = thisLanguageManager.GetTextValue("UI.StoreTitle"); product1.text = thisLanguageManager.GetTextValue("UI.Product1"); product1desc.text = thisLanguageManager.GetTextValue("UI.Product1Desc"); product2.text = thisLanguageManager.GetTextValue("UI.Product2"); product2desc.text = thisLanguageManager.GetTextValue("UI.Product2Desc"); product3.text = thisLanguageManager.GetTextValue("UI.Product3"); product4.text = thisLanguageManager.GetTextValue("UI.Product4"); product5.text = thisLanguageManager.GetTextValue("UI.Product5"); product6.text = thisLanguageManager.GetTextValue("UI.Product6"); storeThanks.text = thisLanguageManager.GetTextValue("UI.StoreThanks"); StoreKitManager.productListReceivedEvent += allProducts => { Debug.Log("received total products: " + allProducts.Count); _products = allProducts; }; bool canMakePayments = StoreKitBinding.canMakePayments(); Debug.Log("StoreKit canMakePayments: " + canMakePayments); // array of product ID's from iTunesConnect. MUST match exactly what you have there! var productIdentifiers = new string[] { "coin1", "coin3", "coin4", "coin2", "VIP", "wingman" }; StoreKitBinding.requestProductData(productIdentifiers); // if( GUILayout.Button( "Restore Completed Transactions" ) ) // { // StoreKitBinding.restoreCompletedTransactions(); // } // if( GUILayout.Button( "Enable High Detail Logs" ) ) // { // StoreKitBinding.enableHighDetailLogs( true ); // } }
public void init(string key, string[] skus) { #if UNITY_ANDROID GoogleIAB.init(key); //copiedSkus = new string[skus.Length]; copiedSkus = skus; //GoogleIAB.queryInventory(skus); #elif UNITY_IPHONE bool canMakePayments = StoreKitBinding.canMakePayments(); if (canMakePayments) { StoreKitBinding.requestProductData(skus); } else { ShowMessages sm = new ShowMessages(); sm.ShowMessageWindow("ERROR ACCESSING APPLE STORE", "You can't connect to Apple Store, network error detected"); } #endif }
void Start() { // you cannot make any purchases until you have retrieved the products from the server with the requestProductData method // we will store the products locally so that we will know what is purchaseable and when we can purchase the products StoreKitManager.productListReceivedEvent += allProducts => { Debug.Log("received total products: " + allProducts.Count); _products = allProducts; }; canMakePayments = StoreKitBinding.canMakePayments(); Debug.Log("StoreKit canMakePayments: " + canMakePayments); if (isFree) { var productIdentifiers = new string[] { "com.DMDEnterprise.kicktheballfree.100coins", "com.DMDEnterprise.kicktheballfree.250coins", "com.DMDEnterprise.kicktheballfree.500coins", "com.DMDEnterprise.kicktheballfree.1500coins", "com.DMDEnterprise.kicktheballfree.3000coins", "com.DMDEnterprise.kicktheballfree.5000coins" }; StoreKitBinding.requestProductData(productIdentifiers); } else { var productIdentifiers = new string[] { "com.immanitas.KickTheBall.100coins", "com.immanitas.KickTheBall.250coins", "com.immanitas.KickTheBall.500coins", "com.immanitas.KickTheBall.1500coins", "com.immanitas.KickTheBall.3000coins", "com.immanitas.KickTheBall.5000coins" }; StoreKitBinding.requestProductData(productIdentifiers); } StoreKitManager.purchaseSuccessfulEvent += purchaseSuccessful; }
public void Buy(string pid, DelFinish onFinish) { isBuying = true; CurProduct.pid = pid; m_delFinish = onFinish; #if UNITY_IPHONE if (StoreKitBinding.canMakePayments()) { string[] strRequests = { pid }; StoreKitBinding.requestProductData(strRequests); } else { BuyFail(FailType.CANNOTBUY, ""); Debug.Log("can't purchase"); } #else if (null != m_delFinish) { m_delFinish(false); } #endif }
public override void PurchaseProduct(InAppPurchase purchase) { #if UNITY_EDITOR base.PurchaseProduct(purchase); #elif UNITY_IPHONE if (StoreKitBinding.canMakePayments()) { purchasingProduct = purchase; RequestProductList(); StoreKitManager.productPurchaseAwaitingConfirmationEvent += OnProductAwaitingVerification; StoreKitManager.purchaseFailedEvent += OnProductFailed; StoreKitManager.purchaseCancelledEvent += OnProductCanceled; Debug.Log("Purchasing product: " + productIds[(int)purchasingProduct]); StoreKitBinding.purchaseProduct(GetPurchaseId(purchase), 1); } else { OnInAppDisabled(purchase); } #endif }
void OnGUI() { beginColumn(); if (GUILayout.Button("Get Can Make Payments")) { bool canMakePayments = StoreKitBinding.canMakePayments(); Debug.Log("StoreKit canMakePayments: " + canMakePayments); } if (GUILayout.Button("Request Product Data")) { // array of product ID's from iTunesConnect. MUST match exactly what you have there! var productIdentifiers = new string[] { "anotherProduct", "tt", "testProduct", "sevenDays", "oneMonthSubsciber" }; StoreKitBinding.requestProductData(productIdentifiers); } if (GUILayout.Button("Restore Completed Transactions")) { StoreKitBinding.restoreCompletedTransactions(); } endColumn(true); // enforce the fact that we can't purchase products until we retrieve the product data if (_products != null && _products.Count > 0) { if (GUILayout.Button("Purchase Random Product")) { var productIndex = Random.Range(0, _products.Count); var product = _products[productIndex]; Debug.Log("preparing to purchase product: " + product.productIdentifier); StoreKitBinding.purchaseProduct(product.productIdentifier, 1); } } else { GUILayout.Label("Once you successfully request product data a purchase button will appear here for testing"); } if (GUILayout.Button("Get Saved Transactions")) { List <StoreKitTransaction> transactionList = StoreKitBinding.getAllSavedTransactions(); // Print all the transactions to the console Debug.Log("\ntotal transaction received: " + transactionList.Count); foreach (StoreKitTransaction transaction in transactionList) { Debug.Log(transaction.ToString() + "\n"); } } if (GUILayout.Button("Turn Off Auto Confirmation of Transactions")) { // this is used when you want to validate receipts on your own server or when dealing with iTunes hosted content // you must manually call StoreKitBinding.finishPendingTransactions when the download/validation is complete StoreKitManager.autoConfirmTransactions = false; } if (GUILayout.Button("Cancel Downloads")) { StoreKitBinding.cancelDownloads(); } if (GUILayout.Button("Display App Store")) { StoreKitBinding.displayStoreWithProductId("305967442"); } endColumn(); }
public bool CanMakePayments() { return(StoreKitBinding.canMakePayments()); }
void OnGUI() { return; if (GUILayout.Button("Get Can Make Payments")) { canMakePayments = StoreKitBinding.canMakePayments(); Debug.Log("StoreKit canMakePayments: " + canMakePayments); } if (GUILayout.Button("Get Product Data")) { // array of product ID's from iTunesConnect. MUST match exactly what you have there! var productIdentifiers = new string[] { "com.DMDEnterprise.kicktheballfree.100coins", "com.DMDEnterprise.kicktheballfree.200coins" }; StoreKitBinding.requestProductData(productIdentifiers); } if (GUILayout.Button("Restore Completed Transactions")) { StoreKitBinding.restoreCompletedTransactions(); } // enforce the fact that we can't purchase products until we retrieve the product data if (_products != null && _products.Count > 0) { if (GUILayout.Button("Purchase Random Product")) { var productIndex = Random.Range(0, _products.Count); var product = _products[productIndex]; Debug.Log("preparing to purchase product: " + product.productIdentifier); StoreKitBinding.purchaseProduct(product.productIdentifier, 1); } } if (GUILayout.Button("Get Saved Transactions")) { List <StoreKitTransaction> transactionList = StoreKitBinding.getAllSavedTransactions(); // Print all the transactions to the console Debug.Log("\ntotal transaction received: " + transactionList.Count); foreach (StoreKitTransaction transaction in transactionList) { Debug.Log(transaction.ToString() + "\n"); } } if (GUILayout.Button("Turn Off Auto Confirmation of Transactions")) { // this is used when you want to validate receipts on your own server or when dealing with iTunes hosted content // you must manually call StoreKitBinding.finishPendingTransactions when the download/validation is complete StoreKitManager.autoConfirmTransactions = false; } if (GUILayout.Button("Display App Store")) { StoreKitBinding.displayStoreWithProductId("305967442"); } }
void OnGUI() { float yPos = 5.0f; float xPos = 5.0f; float width = (Screen.width >= 960 || Screen.height >= 960) ? 320 : 160; float height = (Screen.width >= 960 || Screen.height >= 960) ? 80 : 40; float heightPlus = height + 10.0f; if (GUI.Button(new Rect(xPos, yPos, width, height), "Get Can Make Payments")) { bool canMakePayments = StoreKitBinding.canMakePayments(); Debug.Log("StoreKit canMakePayments: " + canMakePayments); } if (GUI.Button(new Rect(xPos, yPos += heightPlus, width, height), "Get Product Data")) { // array of product ID's from iTunesConnect. MUST match exactly what you have there! var productIdentifiers = new string[] { "anotherProduct", "tt", "testProduct", "sevenDays", "oneMonthSubsciber" }; StoreKitBinding.requestProductData(productIdentifiers); } if (GUI.Button(new Rect(xPos, yPos += heightPlus, width, height), "Restore Completed Transactions")) { StoreKitBinding.restoreCompletedTransactions(); } if (GUI.Button(new Rect(xPos, yPos += heightPlus, width, height), "Validate Receipt")) { // grab the transactions, then just validate the first one List <StoreKitTransaction> transactionList = StoreKitBinding.getAllSavedTransactions(); if (transactionList.Count > 0) { StoreKitBinding.validateReceipt(transactionList[0].base64EncodedTransactionReceipt, true); } } // Second column xPos = Screen.width - width - 5.0f; yPos = 5.0f; // enforce the fact that we can't purchase products until we retrieve the product data if (_products != null && _products.Count > 0) { if (GUI.Button(new Rect(xPos, yPos, width, height), "Purchase Random Product")) { var productIndex = Random.Range(0, _products.Count); var product = _products[productIndex]; Debug.Log("preparing to purchase product: " + product.productIdentifier); StoreKitBinding.purchaseProduct(product.productIdentifier, 1); } } if (GUI.Button(new Rect(xPos, yPos += heightPlus, width, height), "Validate Subscription")) { // grab the transactions and if we have a subscription in there validate it List <StoreKitTransaction> transactionList = StoreKitBinding.getAllSavedTransactions(); foreach (var t in transactionList) { if (t.productIdentifier == "sevenDays") { StoreKitBinding.validateAutoRenewableReceipt(t.base64EncodedTransactionReceipt, "YOUR_SECRET_FROM_ITC", true); break; } } } if (GUI.Button(new Rect(xPos, yPos += heightPlus, width, height), "Get Saved Transactions")) { List <StoreKitTransaction> transactionList = StoreKitBinding.getAllSavedTransactions(); // Print all the transactions to the console Debug.Log("\ntotal transaction received: " + transactionList.Count); foreach (StoreKitTransaction transaction in transactionList) { Debug.Log(transaction.ToString() + "\n"); } } }
void OnGUI() { float yPos = 10.0f; float xPos = 20.0f; float width = 210.0f; if (GUI.Button(new Rect(xPos, yPos, width, 40), "Get Can Make Payments")) { bool canMakePayments = StoreKitBinding.canMakePayments(); Debug.Log("StoreKit canMakePayments: " + canMakePayments); } if (GUI.Button(new Rect(xPos, yPos += 50, width, 40), "Get Product Data")) { // comma delimited list of product ID's from iTunesConnect. MUST match exactly what you have there! string productIdentifiers = "anotherProduct,tt,testProduct,sevenDays,oneMonthSubsciber"; StoreKitBinding.requestProductData(productIdentifiers); } if (GUI.Button(new Rect(xPos, yPos += 50, width, 40), "Restore Completed Transactions")) { StoreKitBinding.restoreCompletedTransactions(); } if (GUI.Button(new Rect(xPos, yPos += 50, width, 40), "Validate Receipt")) { // grab the transactions, then just validate the first one List <StoreKitTransaction> transactionList = StoreKitBinding.getAllSavedTransactions(); if (transactionList.Count > 0) { StoreKitBinding.validateReceipt(transactionList[0].base64EncodedTransactionReceipt, true); } } // Second column xPos += xPos + width; yPos = 10.0f; if (GUI.Button(new Rect(xPos, yPos, width, 40), "Purchase Product 1")) { StoreKitBinding.purchaseProduct("testProduct", 1); } if (GUI.Button(new Rect(xPos, yPos += 50, width, 40), "Purchase Product 2")) { StoreKitBinding.purchaseProduct("anotherProduct", 1); } if (GUI.Button(new Rect(xPos, yPos += 50, width, 40), "Purchase Subscription")) { StoreKitBinding.purchaseProduct("sevenDays", 1); } if (GUI.Button(new Rect(xPos, yPos += 50, width, 40), "Validate Subscription")) { // grab the transactions and if we have a subscription in there validate it List <StoreKitTransaction> transactionList = StoreKitBinding.getAllSavedTransactions(); foreach (var t in transactionList) { if (t.productIdentifier == "sevenDays") { StoreKitBinding.validateAutoRenewableReceipt(t.base64EncodedTransactionReceipt, "YOUR_SECRET_FROM_ITC", true); break; } } } if (GUI.Button(new Rect(xPos, yPos += 50, width, 40), "Get Saved Transactions")) { List <StoreKitTransaction> transactionList = StoreKitBinding.getAllSavedTransactions(); // Print all the transactions to the console Debug.Log("\ntotal transaction received: " + transactionList.Count); foreach (StoreKitTransaction transaction in transactionList) { Debug.Log(transaction.ToString() + "\n"); } } }
// initialize IAPs, billing systems and database, // as well as shop components in this order void Awake() { //make sure we keep one instance of this script in the game if (instance) { Destroy(gameObject); return; } DontDestroyOnLoad(this); //ensure that we are always developing on a mobile platform, //otherwise print a warning #if !UNITY_ANDROID && !UNITY_IPHONE Debug.LogWarning("IAPManager: Detected non-mobile platform. Purchases for real money are" + " not supported on this platform. Please switch to iOS/Android."); #endif //set static reference instance = this; //populate IAP dictionary and arrays with product ids InitIds(); //map Prime31 IAP handler delegates to fire corresponding methods #if UNITY_ANDROID GoogleIABManager.billingSupportedEvent += RequestProductData; GoogleIABManager.billingNotSupportedEvent += BillingNotSupported; GoogleIABManager.queryInventorySucceededEvent += ProductDataReceived; GoogleIABManager.queryInventoryFailedEvent += BillingNotSupported; GoogleIABManager.purchaseSucceededEvent += PurchaseSucceeded; GoogleIABManager.purchaseFailedEvent += PurchaseFailed; GoogleIABManager.consumePurchaseSucceededEvent += ConsumeSucceeded; GoogleIABManager.consumePurchaseFailedEvent += PurchaseFailed; //initializes Google's billing system //by passing in your google dev key if (!string.IsNullOrEmpty(googleStoreKey)) { GoogleIAB.init(googleStoreKey); } else { Debug.LogWarning("IAPManager: Google Store Key missing on IAP Manager prefab. " + "Purchases for real money won't be supported on the device."); } //enables high detail logging to the console, //do not comment out in production versions! //this is for testing only GoogleIAB.enableLogging(false); #elif UNITY_IPHONE StoreKitManager.productListReceivedEvent += ProductDataReceived; StoreKitManager.productListRequestFailedEvent += BillingNotSupported; StoreKitManager.purchaseSuccessfulEvent += PurchaseSucceeded; StoreKitManager.purchaseFailedEvent += PurchaseFailed; StoreKitManager.purchaseCancelledEvent += PurchaseFailed; StoreKitManager.restoreTransactionsFinishedEvent += RestoreSucceeded; StoreKitManager.restoreTransactionsFailedEvent += RestoreFailed; //initializes Apple's billing system //when parental controls aren't active if (StoreKitBinding.canMakePayments()) { RequestProductData(); } else { BillingNotSupported("Apple App Store not available."); } #endif //initialize database, remote and shop managers GetComponent <DBManager>().Init(); StartCoroutine(RemoteDownload()); OnLevelWasLoaded(-1); }