public void setupPurchaseManager() { PurchaseSystem.onAppRestarted(); if (PurchaseSystem.hasManager()) { PurchaseManagerConfig purchaseManagerConfig = getPurchaseManagerConfig(); PurchaseSystem.install(new PurchaseObserver(), purchaseManagerConfig); } }
public void purchaseSku(String sku) { if (PurchaseSystem.hasManager()) { PurchaseSystem.purchase(sku); } }
@Override public void onActivityResult (int requestCode, int resultCode, Intent data) { // forward to corresponding Android IAP-system PurchaseManager manager = PurchaseSystem.getManager(); if (manager != null) { try { // this might fail which is OK! --> some implementations will not require this... Method method = manager.getClass().getMethod("onActivityResult", int.class, int.class, Intent.class); method.invoke(manager, requestCode, resultCode, data); } catch (Exception e) { Log.d(TAG, "Failed to invoke onActivityResult(...) on purchase manager.", e); } } }
@SuppressWarnings("unused") // Unit tested with reflection. (as in IAP.java) public AndroidGooglePlayPurchaseManager(Activity activity, AndroidFragmentApplication application, int activityRequestCode) { PurchaseResponseActivityResultConverter converter = new PurchaseResponseActivityResultConverter(this); AsyncExecutor executor = new NewThreadSleepAsyncExecutor(); ApplicationProxy.FragmentProxy proxy = new ApplicationProxy.FragmentProxy(activity, application); googleInAppBillingService = new V3GoogleInAppBillingService(proxy, activityRequestCode, converter, executor); PurchaseSystem.setManager(this); }
public void restorePurchase() { PurchaseSystem.purchaseRestore(); }
@Override public void dispose () { // dispose the purchase system PurchaseSystem.dispose(); }