/// <summary> /// Dumy method. /// </summary> /// <param name="inAppID"></param> /// <param name="purchasedCallback"></param> public void BuyInApp(string inAppID, InAppPurchaseBuyCallbackMethod purchasedCallback) { if (purchasedCallback != null) { purchasedCallback(inAppID, null, false); } }
public void BuyInApp(string inAppID, InAppPurchaseBuyCallbackMethod purchasedCallback) { #if !IOS_DISABLE_APPLE_IAP this.purchasedCallback = purchasedCallback; BuyInAppPurchase(native, inAppID); #endif }
/// <summary> /// Use to when the user wants to buy a IAP. /// </summary> /// <param name="inAppID">IAP ID</param> /// <param name="buyCallback">The callback that fires when done.</param> public void Buy(string inAppID, InAppPurchaseBuyCallbackMethod buyCallback) { if (buyingProduct || restoringProducts) { Debug.LogError("You must wait for the last buy, restore or consume to finish!"); if (buyCallback != null) { buyCallback(inAppID, null, false); } return; } buyingProduct = true; this.buyCallback = buyCallback; // skip if item is already purchased locally if (IsPurchased(inAppID)) { Debug.Log("InApp already puchased: " + inAppID); buyingProduct = false; if (buyCallback != null) { buyCallback(inAppID, null, true); } return; } plugin.BuyInApp(inAppID, async_BuyCallback); }
public void BuyInApp(string inAppID, InAppPurchaseBuyCallbackMethod purchasedCallback) { PlayerPrefs.SetInt("ReignIAP_PurchasedAwarded_" + inAppID, 0); if (purchasedCallback != null) { purchasedCallback(inAppID, null, true); } }
public void BuyInApp(string inAppID, InAppPurchaseBuyCallbackMethod purchasedCallback) { if (purchasedCallback == null) return; buyInAppID = inAppID; this.purchasedCallback = purchasedCallback; native.CallStatic("BuyApp", inAppID); }
public void BuyInApp(string inAppID, InAppPurchaseBuyCallbackMethod purchasedCallback) { if (purchasedCallback == null) { return; } buyInAppID = inAppID; this.purchasedCallback = purchasedCallback; native.CallStatic("BuyApp", inAppID); }
public void BuyInApp(string inAppID, InAppPurchaseBuyCallbackMethod purchasedCallback) { if (purchasedCallback == null) { return; } int id = Common.getpid(); string windowGroup = id.ToString(); uint reqID = 0; if (paymentservice_purchase_request(inAppID, null, null, null, null, null, windowGroup, ref reqID) != 0) { purchasedCallback(inAppID, null, false); return; } // wait for event while (true) { IntPtr _event = IntPtr.Zero; Common.bps_get_event(ref _event, -1); // wait here for next event if (_event != IntPtr.Zero) { if (paymentservice_get_domain() == Common.bps_event_get_domain(_event)) { if (paymentservice_event_get_response_code(_event) == 0) { if (Common.bps_event_get_code(_event) == 0) { // purchased purchasedCallback(inAppID, null, true); return; } else { // already purchased purchasedCallback(inAppID, null, true); return; } } else { IntPtr errorPtr = paymentservice_event_get_error_text(_event); Debug.LogError(Marshal.PtrToStringAnsi(errorPtr)); purchasedCallback(inAppID, null, false); return; } } } } }
public void BuyInApp(string inAppID, InAppPurchaseBuyCallbackMethod purchasedCallback) { PlayerPrefs.SetInt("ReignIAP_PurchasedAwarded_" + inAppID, 0); if (purchasedCallback != null) purchasedCallback(inAppID, null, true); }
public void BuyInApp(string inAppID, InAppPurchaseBuyCallbackMethod purchasedCallback) { buyInAppAsync(inAppID, purchasedCallback); }
public void BuyInApp(string inAppID, InAppPurchaseBuyCallbackMethod purchasedCallback) { this.purchasedCallback = purchasedCallback; BuyInAppPurchase(native, inAppID); }
/// <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); }
public void BuyInApp(string inAppID, InAppPurchaseBuyCallbackMethod purchasedCallback) { Native.BuyInApp(inAppID, purchasedCallback); }
public void BuyInApp(string inAppID, InAppPurchaseBuyCallbackMethod purchasedCallback) { if (purchasedCallback == null) return; int id = Common.getpid(); string windowGroup = id.ToString(); uint reqID = 0; if (paymentservice_purchase_request(inAppID, null, null, null, null, null, windowGroup, ref reqID) != 0) { purchasedCallback(inAppID, null, false); return; } // wait for event while (true) { IntPtr _event = IntPtr.Zero; Common.bps_get_event(ref _event, -1);// wait here for next event if (_event != IntPtr.Zero) { if (paymentservice_get_domain() == Common.bps_event_get_domain(_event)) { if (paymentservice_event_get_response_code(_event) == 0) { if (Common.bps_event_get_code(_event) == 0) { // purchased purchasedCallback(inAppID, null, true); return; } else { // already purchased purchasedCallback(inAppID, null, true); return; } } else { IntPtr errorPtr = paymentservice_event_get_error_text(_event); Debug.LogError(Marshal.PtrToStringAnsi(errorPtr)); purchasedCallback(inAppID, null, false); return; } } } } }
/// <summary> /// Use to when the user wants to buy a IAP. /// </summary> /// <param name="inAppID">IAP Index</param> /// <param name="buyCallback">The callback that fires when done.</param> public void Buy(int inAppIndex, InAppPurchaseBuyCallbackMethod buyCallback) { Buy(plugin.InAppIDs[inAppIndex].ID, buyCallback); }
/// <summary> /// Use to when the user wants to buy a IAP. /// </summary> /// <param name="inAppID">IAP ID</param> /// <param name="buyCallback">The callback that fires when done.</param> public void Buy(string inAppID, InAppPurchaseBuyCallbackMethod buyCallback) { if (buyingProduct || restoringProducts) { Debug.LogError("You must wait for the last buy, restore or consume to finish!"); if (buyCallback != null) buyCallback(inAppID, null, false); return; } buyingProduct = true; this.buyCallback = buyCallback; // skip if item is already purchased locally if (IsPurchased(inAppID)) { Debug.Log("InApp already puchased: " + inAppID); buyingProduct = false; if (buyCallback != null) buyCallback(inAppID, null, true); return; } plugin.BuyInApp(inAppID, async_BuyCallback); }
private void buyInAppAsync(string inAppID, InAppPurchaseBuyCallbackMethod purchasedCallback)
private async void buyInAppAsync(string inAppID, InAppPurchaseBuyCallbackMethod purchasedCallback) #endif { #if WINDOWS_PHONE WinRTPlugin.Dispatcher.BeginInvoke(async delegate() #else await WinRTPlugin.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async delegate() #endif { #if WINDOWS_PHONE if ((testing && (!wp8TestLicenseInformation.ProductLicenses[inAppID].IsActive || wp8TestLicenseInformation.ProductLicenses[inAppID].IsConsumable)) || (!testing && (!licenseInformation.ProductLicenses[inAppID].IsActive || licenseInformation.ProductLicenses[inAppID].IsConsumable))) #else if (!licenseInformation.ProductLicenses[inAppID].IsActive || isConsumbable(inAppID)) #endif { try { string receipt = null; #if WINDOWS_PHONE string productID = null; if (testing) { productID = wp8TestListingInformation.ProductListings[inAppID].ProductId; } else { productID = licenseInformation.ProductLicenses[inAppID].ProductId; } #elif UNITY_METRO_8_0 string productID = licenseInformation.ProductLicenses[inAppID].ProductId; #else PurchaseResults results; string productID = licenseInformation.ProductLicenses[inAppID].ProductId; #endif if (testing) { #if WINDOWS_PHONE receipt = await CurrentAppSimulator.RequestProductPurchaseAsync(productID, true); if (wp8TestLicenseInformation.ProductLicenses[inAppID].IsActive) { PlayerPrefsEx.SetIntAsync("ReignIAP_PurchasedAwarded_" + inAppID, 0, true); } #elif UNITY_METRO_8_0 receipt = await CurrentAppSimulator.RequestProductPurchaseAsync(productID, true); #else results = await CurrentAppSimulator.RequestProductPurchaseAsync(productID); receipt = results.ReceiptXml; #endif } else { #if WINDOWS_PHONE receipt = await CurrentApp.RequestProductPurchaseAsync(productID, true); if (licenseInformation.ProductLicenses[inAppID].IsActive) { PlayerPrefsEx.SetIntAsync("ReignIAP_PurchasedAwarded_" + inAppID, 0, true); } #elif UNITY_METRO_8_0 receipt = await CurrentApp.RequestProductPurchaseAsync(productID, true); #else results = await CurrentApp.RequestProductPurchaseAsync(productID); receipt = results.ReceiptXml; #endif } #if UNITY_METRO_8_0 if (!string.IsNullOrEmpty(receipt) || licenseInformation.ProductLicenses[inAppID].IsActive) { PlayerPrefsEx.SetIntAsync("ReignIAP_PurchasedAwarded_" + inAppID, 0, true); } #elif UNITY_METRO if (results.Status == ProductPurchaseStatus.Succeeded || results.Status == ProductPurchaseStatus.AlreadyPurchased || licenseInformation.ProductLicenses[inAppID].IsActive) { PlayerPrefsEx.SetIntAsync("ReignIAP_PurchasedAwarded_" + inAppID, 0, true); } #endif if (purchasedCallback != null) { #if WINDOWS_PHONE if (testing) { purchasedCallback(inAppID, receipt, wp8TestLicenseInformation.ProductLicenses[inAppID].IsActive); if (wp8TestLicenseInformation.ProductLicenses[inAppID].IsConsumable) { CurrentAppSimulator.ReportProductFulfillment(productID); } } else { purchasedCallback(inAppID, receipt, licenseInformation.ProductLicenses[inAppID].IsActive); if (licenseInformation.ProductLicenses[inAppID].IsConsumable) { CurrentApp.ReportProductFulfillment(productID); } } #elif UNITY_METRO_8_0 purchasedCallback(inAppID, receipt, !string.IsNullOrEmpty(receipt) || licenseInformation.ProductLicenses[inAppID].IsActive); if (isConsumbable(inAppID)) { Debug.LogError("NOTE: Consumable IAP not supported in 8.0"); } #else purchasedCallback(inAppID, receipt, results.Status == ProductPurchaseStatus.Succeeded || results.Status == ProductPurchaseStatus.AlreadyPurchased || licenseInformation.ProductLicenses[inAppID].IsActive); if (isConsumbable(inAppID)) { if (testing) { await CurrentAppSimulator.ReportConsumableFulfillmentAsync(productID, results.TransactionId); } else { await CurrentApp.ReportConsumableFulfillmentAsync(productID, results.TransactionId); } } #endif } } catch (Exception e) { Debug.LogError(e.Message); if (purchasedCallback != null) { purchasedCallback(inAppID, null, false); } } } else { if (purchasedCallback != null) { purchasedCallback(inAppID, null, true); } } }); }
private async void buyInAppAsync(string inAppID, InAppPurchaseBuyCallbackMethod purchasedCallback) #endif { #if WINDOWS_PHONE WinRTPlugin.Dispatcher.BeginInvoke(async delegate() #else await WinRTPlugin.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async delegate() #endif { #if WINDOWS_PHONE if ((testing && (!wp8TestLicenseInformation.ProductLicenses[inAppID].IsActive || wp8TestLicenseInformation.ProductLicenses[inAppID].IsConsumable)) || (!testing && (!licenseInformation.ProductLicenses[inAppID].IsActive || licenseInformation.ProductLicenses[inAppID].IsConsumable))) #else if (!licenseInformation.ProductLicenses[inAppID].IsActive || isConsumbable(inAppID)) #endif { try { string receipt = null; #if WINDOWS_PHONE string productID = null; if (testing) productID = wp8TestListingInformation.ProductListings[inAppID].ProductId; else productID = licenseInformation.ProductLicenses[inAppID].ProductId; #elif UNITY_METRO_8_0 string productID = licenseInformation.ProductLicenses[inAppID].ProductId; #else PurchaseResults results; string productID = licenseInformation.ProductLicenses[inAppID].ProductId; #endif if (testing) { #if WINDOWS_PHONE receipt = await CurrentAppSimulator.RequestProductPurchaseAsync(productID, true); if (wp8TestLicenseInformation.ProductLicenses[inAppID].IsActive) { PlayerPrefsEx.SetIntAsync("ReignIAP_PurchasedAwarded_" + inAppID, 0, true); } #elif UNITY_METRO_8_0 receipt = await CurrentAppSimulator.RequestProductPurchaseAsync(productID, true); #else results = await CurrentAppSimulator.RequestProductPurchaseAsync(productID); receipt = results.ReceiptXml; #endif } else { #if WINDOWS_PHONE receipt = await CurrentApp.RequestProductPurchaseAsync(productID, true); if (licenseInformation.ProductLicenses[inAppID].IsActive) { PlayerPrefsEx.SetIntAsync("ReignIAP_PurchasedAwarded_" + inAppID, 0, true); } #elif UNITY_METRO_8_0 receipt = await CurrentApp.RequestProductPurchaseAsync(productID, true); #else results = await CurrentApp.RequestProductPurchaseAsync(productID); receipt = results.ReceiptXml; #endif } #if UNITY_METRO_8_0 if (!string.IsNullOrEmpty(receipt) || licenseInformation.ProductLicenses[inAppID].IsActive) { PlayerPrefsEx.SetIntAsync("ReignIAP_PurchasedAwarded_" + inAppID, 0, true); } #elif UNITY_METRO if (results.Status == ProductPurchaseStatus.Succeeded || results.Status == ProductPurchaseStatus.AlreadyPurchased || licenseInformation.ProductLicenses[inAppID].IsActive) { PlayerPrefsEx.SetIntAsync("ReignIAP_PurchasedAwarded_" + inAppID, 0, true); } #endif if (purchasedCallback != null) { #if WINDOWS_PHONE if (testing) { ReignServices.InvokeOnUnityThread(delegate { purchasedCallback(inAppID, receipt, wp8TestLicenseInformation.ProductLicenses[inAppID].IsActive); }); if (wp8TestLicenseInformation.ProductLicenses[inAppID].IsConsumable) CurrentAppSimulator.ReportProductFulfillment(productID); } else { ReignServices.InvokeOnUnityThread(delegate { purchasedCallback(inAppID, receipt, licenseInformation.ProductLicenses[inAppID].IsActive); }); if (licenseInformation.ProductLicenses[inAppID].IsConsumable) CurrentApp.ReportProductFulfillment(productID); } #elif UNITY_METRO_8_0 ReignServices.InvokeOnUnityThread(delegate { purchasedCallback(inAppID, receipt, !string.IsNullOrEmpty(receipt) || licenseInformation.ProductLicenses[inAppID].IsActive); }); if (isConsumbable(inAppID)) { Debug.LogError("NOTE: Consumable IAP not supported in 8.0"); } #else ReignServices.InvokeOnUnityThread(delegate { purchasedCallback(inAppID, receipt, results.Status == ProductPurchaseStatus.Succeeded || results.Status == ProductPurchaseStatus.AlreadyPurchased || licenseInformation.ProductLicenses[inAppID].IsActive); }); if (isConsumbable(inAppID)) { if (testing) await CurrentAppSimulator.ReportConsumableFulfillmentAsync(productID, results.TransactionId); else await CurrentApp.ReportConsumableFulfillmentAsync(productID, results.TransactionId); } #endif } } catch (Exception e) { Debug.LogError(e.Message); ReignServices.InvokeOnUnityThread(delegate { if (purchasedCallback != null) purchasedCallback(inAppID, null, false); }); } } else { ReignServices.InvokeOnUnityThread(delegate { if (purchasedCallback != null) purchasedCallback(inAppID, null, true); }); } }); }
/// <summary> /// Dumy method. /// </summary> /// <param name="inAppID"></param> /// <param name="purchasedCallback"></param> public void BuyInApp(string inAppID, InAppPurchaseBuyCallbackMethod purchasedCallback) { if (purchasedCallback != null) purchasedCallback(inAppID, null, false); }