public unsafe void GetProductInfo(InAppPurchaseGetProductInfoCallbackMethod callback) { #if !IOS_DISABLE_APPLE_IAP if (callback == null) { return; } byte **ptr = GetInAppPurchaseProductInfo(native); if (ptr == (byte **)0) { callback(null, false); return; } var products = new List <InAppPurchaseInfo>(); while (ptr[0] != (byte *)0) { string id = Marshal.PtrToStringAnsi(new IntPtr(ptr[0])); ptr++; string price = Marshal.PtrToStringAnsi(new IntPtr(ptr[0])); ptr++; var product = new InAppPurchaseInfo() { ID = id, FormattedPrice = price }; products.Add(product); } callback(products.ToArray(), true); #endif }
public void GetProductInfo (InAppPurchaseGetProductInfoCallbackMethod productInfoCallback) { if (productInfoCallback == null) return; this.productInfoCallback = productInfoCallback; native.CallStatic("GetProductInfo"); }
public void GetProductInfo(InAppPurchaseGetProductInfoCallbackMethod callback) { if (callback == null) { return; } var priceInfos = new List <InAppPurchaseInfo>(); foreach (var iapID in InAppIDs) { int id = Common.getpid(); string windowGroup = id.ToString(); uint reqID = 0; if (paymentservice_get_price(iapID.ID, iapID.ID, windowGroup, ref reqID) != 0) { callback(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) { IntPtr pricePtr = paymentservice_event_get_price(_event); string price = Marshal.PtrToStringAnsi(pricePtr); var product = new InAppPurchaseInfo() { ID = iapID.ID, FormattedPrice = price }; priceInfos.Add(product); } else { IntPtr errorPtr = paymentservice_event_get_error_text(_event); Debug.LogError(Marshal.PtrToStringAnsi(errorPtr)); callback(null, false); return; } break; } } } } callback(priceInfos.ToArray(), priceInfos.Count != 0); }
public void GetProductInfo(InAppPurchaseGetProductInfoCallbackMethod productInfoCallback) { if (productInfoCallback == null) { return; } this.productInfoCallback = productInfoCallback; native.CallStatic("GetProductInfo"); }
public void GetProductInfo (InAppPurchaseGetProductInfoCallbackMethod callback) { if (callback == null) return; var priceInfos = new List<InAppPurchaseInfo>(); foreach (var iapID in InAppIDs) { int id = Common.getpid(); string windowGroup = id.ToString(); uint reqID = 0; if (paymentservice_get_price(iapID.ID, iapID.ID, windowGroup, ref reqID) != 0) { callback(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) { IntPtr pricePtr = paymentservice_event_get_price(_event); string price = Marshal.PtrToStringAnsi(pricePtr); var product = new InAppPurchaseInfo() { ID = iapID.ID, FormattedPrice = price }; priceInfos.Add(product); } else { IntPtr errorPtr = paymentservice_event_get_error_text(_event); Debug.LogError(Marshal.PtrToStringAnsi(errorPtr)); callback(null, false); return; } break; } } } } callback(priceInfos.ToArray(), priceInfos.Count != 0); }
/// <summary> /// Use to get product price information /// </summary> /// <param name="callback"></param> public void GetProductInfo(InAppPurchaseGetProductInfoCallbackMethod callback) { if (restoringProducts || buyingProduct) { Debug.LogError("You must wait for the last restore, buy or consume to finish!"); if (callback != null) { callback(null, false); } return; } plugin.GetProductInfo(callback); }
public void GetProductInfo(InAppPurchaseGetProductInfoCallbackMethod callback) { if (callback != null) { var infos = new InAppPurchaseInfo[InAppIDs.Length]; for (int i = 0; i != infos.Length; ++i) { infos[i] = new InAppPurchaseInfo() { ID = InAppIDs[i].ID, FormattedPrice = InAppIDs[i].CurrencySymbol + InAppIDs[i].Price }; } callback(infos, true); } }
public async void GetProductInfo(InAppPurchaseGetProductInfoCallbackMethod callback) { if (callback == null) { return; } #if WINDOWS_PHONE WinRTPlugin.Dispatcher.BeginInvoke(async delegate() #else await WinRTPlugin.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async delegate() #endif { var infos = new List <InAppPurchaseInfo>(); try { #if WINDOWS_PHONE if (testing) { var listingInfo = wp8TestListingInformation; foreach (var l in listingInfo.ProductListings) { var info = new InAppPurchaseInfo() { ID = l.Value.ProductId, FormattedPrice = l.Value.FormattedPrice }; infos.Add(info); } } else { var listingInfo = await CurrentApp.LoadListingInformationAsync(); foreach (var l in listingInfo.ProductListings) { var info = new InAppPurchaseInfo() { ID = l.Value.ProductId, FormattedPrice = l.Value.FormattedPrice }; infos.Add(info); } } #else ListingInformation listingInfo; if (testing) { listingInfo = await CurrentAppSimulator.LoadListingInformationAsync(); } else { listingInfo = await CurrentApp.LoadListingInformationAsync(); } foreach (var l in listingInfo.ProductListings) { var info = new InAppPurchaseInfo() { ID = l.Value.ProductId, FormattedPrice = l.Value.FormattedPrice }; infos.Add(info); } #endif ReignServices.InvokeOnUnityThread(delegate { callback(infos.ToArray(), true); }); } catch (Exception e) { Debug.LogError(e.Message); ReignServices.InvokeOnUnityThread(delegate { callback(null, false); }); } }); }
public void GetProductInfo(InAppPurchaseGetProductInfoCallbackMethod callback) { Native.GetProductInfo(callback); }
public async void GetProductInfo(InAppPurchaseGetProductInfoCallbackMethod callback) { if (callback == null) { return; } var infos = new List <InAppPurchaseInfo>(); try { #if WINDOWS_PHONE if (testing) { var listingInfo = wp8TestListingInformation; foreach (var l in listingInfo.ProductListings) { var info = new InAppPurchaseInfo() { ID = l.Value.ProductId, FormattedPrice = l.Value.FormattedPrice }; infos.Add(info); } } else { var listingInfo = await CurrentApp.LoadListingInformationAsync(); foreach (var l in listingInfo.ProductListings) { var info = new InAppPurchaseInfo() { ID = l.Value.ProductId, FormattedPrice = l.Value.FormattedPrice }; infos.Add(info); } } #else ListingInformation listingInfo; if (testing) { listingInfo = await CurrentAppSimulator.LoadListingInformationAsync(); } else { listingInfo = await CurrentApp.LoadListingInformationAsync(); } foreach (var l in listingInfo.ProductListings) { var info = new InAppPurchaseInfo() { ID = l.Value.ProductId, FormattedPrice = l.Value.FormattedPrice }; infos.Add(info); } #endif callback(infos.ToArray(), true); } catch (Exception e) { Debug.LogError(e.Message); callback(null, false); } }
/// <summary> /// Use to get product price information /// </summary> /// <param name="callback"></param> public void GetProductInfo(InAppPurchaseGetProductInfoCallbackMethod callback) { if (restoringProducts || buyingProduct) { Debug.LogError("You must wait for the last restore, buy or consume to finish!"); if (callback != null) callback(null, false); return; } plugin.GetProductInfo(callback); }
public unsafe void GetProductInfo (InAppPurchaseGetProductInfoCallbackMethod callback) { if (callback == null) return; byte** ptr = GetInAppPurchaseProductInfo(native); if (ptr == (byte**)0) { callback(null, false); return; } var products = new List<InAppPurchaseInfo>(); while (ptr[0] != (byte*)0) { string id = Marshal.PtrToStringAnsi(new IntPtr(ptr[0])); ptr++; string price = Marshal.PtrToStringAnsi(new IntPtr(ptr[0])); ptr++; var product = new InAppPurchaseInfo() { ID = id, FormattedPrice = price }; products.Add(product); } callback(products.ToArray(), true); }
public async void GetProductInfo(InAppPurchaseGetProductInfoCallbackMethod callback) { if (callback == null) return; #if WINDOWS_PHONE WinRTPlugin.Dispatcher.BeginInvoke(async delegate() #else await WinRTPlugin.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async delegate() #endif { var infos = new List<InAppPurchaseInfo>(); try { #if WINDOWS_PHONE if (testing) { var listingInfo = wp8TestListingInformation; foreach (var l in listingInfo.ProductListings) { var info = new InAppPurchaseInfo() { ID = l.Value.ProductId, FormattedPrice = l.Value.FormattedPrice }; infos.Add(info); } } else { var listingInfo = await CurrentApp.LoadListingInformationAsync(); foreach (var l in listingInfo.ProductListings) { var info = new InAppPurchaseInfo() { ID = l.Value.ProductId, FormattedPrice = l.Value.FormattedPrice }; infos.Add(info); } } #else ListingInformation listingInfo; if (testing) listingInfo = await CurrentAppSimulator.LoadListingInformationAsync(); else listingInfo = await CurrentApp.LoadListingInformationAsync(); foreach (var l in listingInfo.ProductListings) { var info = new InAppPurchaseInfo() { ID = l.Value.ProductId, FormattedPrice = l.Value.FormattedPrice }; infos.Add(info); } #endif ReignServices.InvokeOnUnityThread(delegate { callback(infos.ToArray(), true); }); } catch (Exception e) { Debug.LogError(e.Message); ReignServices.InvokeOnUnityThread(delegate { callback(null, false); }); } }); }
/// <summary> /// Dumy method /// </summary> /// <param name="callback">Callback</param> public void GetProductInfo(InAppPurchaseGetProductInfoCallbackMethod callback) { // do nothing... }