public void OnServiceConnected(ComponentName name, IBinder service) { Service = IInAppBillingServiceStub.AsInterface(service); if (Service == null || Context == null) { tcsConnect?.TrySetResult(false); return; } var pkgName = Context.PackageName; var type = itemType == ItemType.Subscription ? ITEM_TYPE_SUBSCRIPTION : ITEM_TYPE_INAPP; try { if (Service.IsBillingSupported(3, pkgName, type) == 0) { IsConnected = true; tcsConnect?.TrySetResult(true); return; } } catch (System.Exception ex) { Console.WriteLine("Unable to check if billing is supported: " + ex.Message); } tcsConnect?.TrySetResult(false); }
public void OnServiceConnected(ComponentName name, IBinder service) { try { Service = IInAppBillingServiceStub.AsInterface(service); int response = Service.IsBillingSupported(BillingConstants.ApiVersion, Application.Context.PackageName, BillingConstants.ItemTypeInApp); var source = _connectSource; if (response == BillingConstants.ResultOk) { if (source != null) { source.TrySetResult(true); } } else { if (source != null) { source.TrySetException(new Exception("Billing not supported!")); } } } catch (Exception exc) { var source = _connectSource; if (source != null) { source.TrySetException(exc); } } }
public void OnServiceConnected(ComponentName name, IBinder service) { Service = IInAppBillingServiceStub.AsInterface(service); var packageName = _activity.PackageName; try { var response = Service.IsBillingSupported(Billing.APIVersion, packageName, ItemType.InApp); if (response != BillingResult.OK) { Connected = false; } // check for v3 subscriptions support response = Service.IsBillingSupported(Billing.APIVersion, packageName, ItemType.Subscription); if (response == BillingResult.OK) { Connected = true; RaiseOnConnected(Connected); } else { Connected = false; } } catch (Exception ex) { Connected = false; } }
public void OnServiceConnected(ComponentName name, IBinder service) { if (outerInstance.mDisposed) { return; } outerInstance.logDebug("Billing service connected."); outerInstance.mService = IInAppBillingServiceStub.AsInterface(service); string packageName = outerInstance.mContext.PackageName; try { outerInstance.logDebug("Checking for in-app billing 3 support."); // check for in-app billing v3 support int response = outerInstance.mService.IsBillingSupported(3, packageName, ITEM_TYPE_INAPP); if (response != BILLING_RESPONSE_RESULT_OK) { if (listener != null) { listener.onIabSetupFinished(new IabResult(response, "Error checking for billing v3 support.")); } // if in-app purchases aren't supported, neither are subscriptions. outerInstance.mSubscriptionsSupported = false; return; } outerInstance.logDebug("In-app billing version 3 supported for " + packageName); // check for v3 subscriptions support response = outerInstance.mService.IsBillingSupported(3, packageName, ITEM_TYPE_SUBS); if (response == BILLING_RESPONSE_RESULT_OK) { outerInstance.logDebug("Subscriptions AVAILABLE."); outerInstance.mSubscriptionsSupported = true; } else { outerInstance.logDebug("Subscriptions NOT AVAILABLE. Response: " + response); } outerInstance.mSetupDone = true; } catch (RemoteException e) { if (listener != null) { listener.onIabSetupFinished(new IabResult(IABHELPER_REMOTE_EXCEPTION, "RemoteException while setting up in-app billing.")); } Console.WriteLine(e.ToString()); Console.Write(e.StackTrace); return; } if (listener != null) { listener.onIabSetupFinished(new IabResult(BILLING_RESPONSE_RESULT_OK, "Setup successful.")); } }
/// <summary> /// /// </summary> /// <param name="name"></param> /// <param name="service"></param> public void OnServiceConnected(ComponentName name, IBinder service) { try { Connected = true; InAppService = IInAppBillingServiceStub.AsInterface(service); var packageName = MainContext.PackageName; Utils.LogDebug("InAppService connected. Checking for v3 support."); if (InAppService.IsBillingSupported(3, packageName, Consts.ITEM_TYPE_INAPP) != Consts.BILLING_RESPONSE_RESULT_OK) { //If in-app items are not supported, subscriptions are not as well. PurchasesSupported = SubscriptionsSupported = false; return; } PurchasesSupported = true; Utils.LogDebug("InAppService v3 is supported."); if (InAppService.IsBillingSupported(3, packageName, Consts.ITEM_TYPE_SUBS) != Consts.BILLING_RESPONSE_RESULT_OK) { Utils.LogDebug("Subscriptions are not available."); SubscriptionsSupported = true; } else { Utils.LogDebug("Subscriptions are not available."); } if (m_listener != null) { m_listener.Connected(); } } catch (RemoteException e) { Utils.LogError("Remote exception occurred in OnServiceConnected; " + e.ToString()); Connected = false; } finally { //Just indicates that the connect request has completed // check PurchasesSupported to know whether or not v3 is supported, if successful if (m_connectTcs != null) { m_connectTcs.SetResult(this.Connected); } } }
public void OnServiceConnected(ComponentName name, IBinder service) { Service = IInAppBillingServiceStub.AsInterface(service); var pkgName = Context.PackageName; if (Service.IsBillingSupported(3, pkgName, ITEM_TYPE_SUBSCRIPTION) == 0) { IsConnected = true; tcsConnect.TrySetResult(true); return; } tcsConnect.TrySetResult(false); }
public void OnServiceConnected(ComponentName name, Android.OS.IBinder service) { LogDebug("Billing service connected."); Service = IInAppBillingServiceStub.AsInterface(service); string packageName = _context.PackageName; try { LogDebug("Checking for in-app billing V3 support"); int response = Service.IsBillingSupported(19, packageName, "ReservedTestProductIDs.Purchased"); if (response != BillingResult.OK) { SetupFinished(false); } LogDebug("In-app billing version 3 supported for " + packageName); // check for v3 subscriptions support response = Service.IsBillingSupported(19, packageName, ItemType.Subscription); if (response == BillingResult.OK) { LogDebug("Subscriptions AVAILABLE."); SetupFinished(true); return; } else { LogDebug("Subscriptions NOT AVAILABLE. Response: " + response); } } catch (Exception ex) { LogDebug(ex.ToString()); SetupFinished(false); } SetupFinished(false); }
public void OnServiceConnected(ComponentName name, Android.OS.IBinder service) { Logger.Debug("Billing service connected."); Service = IInAppBillingServiceStub.AsInterface(service); string packageName = _activity.PackageName; try { Logger.Debug("Checking for in-app billing V3 support"); int response = Service.IsBillingSupported(Billing.APIVersion, packageName, ItemType.InApp); if (response != BillingResult.OK) { Connected = false; } Logger.Debug("In-app billing version 3 supported for {0}", packageName); // check for v3 subscriptions support response = Service.IsBillingSupported(Billing.APIVersion, packageName, ItemType.Subscription); if (response == BillingResult.OK) { Logger.Debug("Subscriptions AVAILABLE."); Connected = true; RaiseOnConnected(Connected); return; } else { Logger.Debug("Subscriptions NOT AVAILABLE. Response: {0}", response); Connected = false; } } catch (Exception ex) { Logger.Debug(ex.ToString()); Connected = false; } }