Search in sources :

Example 1 with AndroidPurchaseTask

use of com.odysee.app.tasks.lbryinc.AndroidPurchaseTask in project odysee-android by OdyseeTeam.

the class HandleBillingPurchase method handleBillingPurchase.

public static void handleBillingPurchase(Purchase purchase, BillingClient billingClient, Context context, View progressView, RewardVerifiedHandler handler) {
    String sku = purchase.getSku();
    if (MainActivity.SKU_SKIP.equalsIgnoreCase(sku)) {
        // send purchase token for verification
        if (purchase.getPurchaseState() == Purchase.PurchaseState.PURCHASED) /*&& isSignatureValid(purchase)*/
        {
            // consume the purchase
            String purchaseToken = purchase.getPurchaseToken();
            ConsumeParams consumeParams = ConsumeParams.newBuilder().setPurchaseToken(purchaseToken).build();
            billingClient.consumeAsync(consumeParams, new ConsumeResponseListener() {

                @Override
                public void onConsumeResponse(@NonNull BillingResult billingResult, @NonNull String s) {
                }
            });
            // send the purchase token to the backend to complete verification
            AndroidPurchaseTask task = new AndroidPurchaseTask(purchaseToken, progressView, context, handler);
            task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
        }
    }
}
Also used : ConsumeParams(com.android.billingclient.api.ConsumeParams) ConsumeResponseListener(com.android.billingclient.api.ConsumeResponseListener) BillingResult(com.android.billingclient.api.BillingResult) AndroidPurchaseTask(com.odysee.app.tasks.lbryinc.AndroidPurchaseTask)

Aggregations

BillingResult (com.android.billingclient.api.BillingResult)1 ConsumeParams (com.android.billingclient.api.ConsumeParams)1 ConsumeResponseListener (com.android.billingclient.api.ConsumeResponseListener)1 AndroidPurchaseTask (com.odysee.app.tasks.lbryinc.AndroidPurchaseTask)1