@Nonnull public BillingRequests create() { return new Requests(mTag, mOnMainThread == null ? true : mOnMainThread); } }
@Override public int changeSubscription(@Nonnull List<Sku> oldSkus, @Nonnull Sku newSku, @Nullable String payload, @Nonnull PurchaseFlow purchaseFlow) { Check.isTrue(ProductTypes.SUBSCRIPTION.equals(newSku.id.product), "Only subscriptions can be downgraded/upgraded"); final List<String> oldSkuIds = new ArrayList<>(oldSkus.size()); for (Sku oldSku : oldSkus) { Check.isTrue(oldSku.id.product.equals(newSku.id.product), "Product type can't be changed"); oldSkuIds.add(oldSku.id.code); } return changeSubscription(oldSkuIds, newSku.id.code, payload, purchaseFlow); }
@Override public int isBillingSupported(@Nonnull final String product, @Nonnull RequestListener<Object> listener) { return isBillingSupported(product, V3, listener); }
final Set<String> loadingProducts = new HashSet<>(ProductTypes.ALL); for (final String product : ProductTypes.ALL) { requests.isBillingSupported(product, new RequestListener<Object>() {
/** * Method clears all listeners and cancels all pending requests. After this method is called no * more work can be done with this class unless {@link Checkout#start()} method is called * again. */ public void stop() { Check.isMainThread(); synchronized (mLock) { if (mState != State.INITIAL) { mState = State.STOPPED; } if (mRequests != null) { mRequests.cancelAll(); mRequests = null; } if (mState == State.STOPPED) { mBilling.onCheckoutStopped(); } } }
@Override public int isChangeSubscriptionSupported(RequestListener<Object> listener) { return isBillingSupported(ProductTypes.SUBSCRIPTION, Billing.V5, listener); }
@Override public int isBillingSupported(@Nonnull String product) { return isBillingSupported(product, emptyListener()); }
@Override public void execute(Runnable command) { final Executor executor; synchronized (mLock) { executor = mRequests != null ? mRequests.getDeliveryExecutor() : null; } if (executor != null) { executor.execute(command); } else { Billing.error("Trying to deliver result on a stopped checkout."); } } }
@Override public int isBillingSupported(@Nonnull String product, int apiVersion) { return isBillingSupported(product, apiVersion, emptyListener()); }
@Override public int getSkus(@Nonnull String product, @Nonnull List<String> skus, @Nonnull RequestListener<Skus> listener) { Check.isNotEmpty(product); Check.isNotEmpty(skus); return runWhenConnected(new GetSkuDetailsRequest(product, skus), wrapListener(listener), mTag); }
@Override public int getAllPurchases(@Nonnull String product, @Nonnull RequestListener<Purchases> listener) { Check.isNotEmpty(product); final GetPurchasesRequest request = new GetPurchasesRequest(product, null, mConfiguration.getPurchaseVerifier()); return runWhenConnected(request, wrapListener(new GetAllPurchasesListener(request, listener)), mTag); }
@Override public int consume(@Nonnull String token, @Nonnull RequestListener<Object> listener) { Check.isNotEmpty(token); return runWhenConnected(new ConsumePurchaseRequest(token), wrapListener(listener), mTag); }
@Override public int changeSubscription(@Nonnull List<String> oldSkus, @Nonnull String newSku, @Nullable String payload, @Nonnull PurchaseFlow purchaseFlow) { Check.isNotEmpty(oldSkus); Check.isNotEmpty(newSku); return runWhenConnected( new ChangePurchaseRequest(ProductTypes.SUBSCRIPTION, oldSkus, newSku, payload), wrapListener(purchaseFlow), mTag); }
@Override public int purchase(@Nonnull String product, @Nonnull String sku, @Nullable String payload, @Nullable Bundle extraParams, @Nonnull PurchaseFlow purchaseFlow) { Check.isNotEmpty(product); Check.isNotEmpty(sku); return runWhenConnected(new PurchaseRequest(product, sku, payload, extraParams), wrapListener(purchaseFlow), mTag); }
@Override public int isBillingSupported(@Nonnull String product, int apiVersion, @Nonnull Bundle extraParams, @Nonnull RequestListener<Object> listener) { Check.isNotEmpty(product); return runWhenConnected(new BillingSupportedRequest(product, apiVersion, extraParams), wrapListener(listener), mTag); }
@Override public int isPurchaseWithExtraParamsSupported(@Nonnull String product, @Nonnull RequestListener<Object> listener) { Check.isNotEmpty(product); return isBillingSupported(product, Billing.V6, listener); }
@Override public int purchase(@Nonnull String product, @Nonnull String sku, @Nullable String payload, @Nonnull PurchaseFlow purchaseFlow) { Check.isNotEmpty(product); Check.isNotEmpty(sku); return runWhenConnected(new PurchaseRequest(product, sku, payload), wrapListener(purchaseFlow), mTag); }
@Override public int getPurchaseHistory(@Nonnull String product, @Nullable String continuationToken, @Nullable Bundle extraParams, @Nonnull RequestListener<Purchases> listener) { Check.isNotEmpty(product); return runWhenConnected(new GetPurchaseHistoryRequest(product, continuationToken, extraParams), wrapListener(listener), mTag); }
@Override public int isBillingSupported(@Nonnull String product, int apiVersion, @Nonnull RequestListener<Object> listener) { Check.isNotEmpty(product); return runWhenConnected(new BillingSupportedRequest(product, apiVersion, null), wrapListener(listener), mTag); }
@Override public int purchase(@Nonnull Sku sku, @Nullable String payload, @Nonnull PurchaseFlow purchaseFlow) { return purchase(sku.id.product, sku.id.code, payload, purchaseFlow); }