com.android.billingclient.api.AcknowledgePurchaseParams Java Examples
The following examples show how to use
com.android.billingclient.api.AcknowledgePurchaseParams.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PreferencesBillingHelper.java From CommonUtils with Apache License 2.0 | 6 votes |
@Override public void onPurchasesUpdated(BillingResult br, @Nullable List<Purchase> purchases) { if (br.getResponseCode() == BillingResponseCode.OK) { listener.showToast(Toaster.build().message(R.string.thankYou).extra(purchases == null ? null : purchases.toString())); if (purchases == null || purchases.isEmpty()) return; for (Purchase p : purchases) { if (p.isAcknowledged()) continue; AcknowledgePurchaseParams params = AcknowledgePurchaseParams.newBuilder() .setPurchaseToken(p.getPurchaseToken()) .build(); billingClient.acknowledgePurchase(params, br1 -> { if (br1.getResponseCode() != BillingResponseCode.OK) handleBillingErrors(br1.getResponseCode()); }); } } else { handleBillingErrors(br.getResponseCode()); } }
Example #2
Source File: PictureInPictureUpgradeActivity.java From dtube-mobile-unofficial with Apache License 2.0 | 6 votes |
void handlePurchase(Purchase purchase) { if (purchase.getPurchaseState() == Purchase.PurchaseState.PURCHASED) { // Grant entitlement to the user. //already purchased setContentView(R.layout.pipm_upgrade_activity_purchased); PreferenceManager.getDefaultSharedPreferences(PictureInPictureUpgradeActivity.this) .edit().putBoolean("upgraded",true).apply(); Preferences.hasUpgrade = true; setResult(RESULT_OK); // Acknowledge the purchase if it hasn't already been acknowledged. if (!purchase.isAcknowledged()) { AcknowledgePurchaseParams acknowledgePurchaseParams = AcknowledgePurchaseParams.newBuilder() .setPurchaseToken(purchase.getPurchaseToken()) .build(); billingClient.acknowledgePurchase(acknowledgePurchaseParams, acknowledgePurchaseResponseListener); } } }
Example #3
Source File: MainActivity.java From PixelWatchFace with GNU General Public License v3.0 | 5 votes |
private void handlePurchase(Purchase purchase) { if (purchase.getSku().equals("unlock_weather")) { if (purchase.getPurchaseState() == PurchaseState.PURCHASED) { // Grant entitlement to the user. advanced = true; sharedPreferences.edit() .putBoolean("advanced", advanced).apply(); loadSettingStates(); syncToWear(); updatePurchaseUI(true); // Acknowledge the purchase if it hasn't already been acknowledged. if (!purchase.isAcknowledged()) { AcknowledgePurchaseParams acknowledgePurchaseParams = AcknowledgePurchaseParams.newBuilder() .setPurchaseToken(purchase.getPurchaseToken()) .build(); billingClient.acknowledgePurchase(acknowledgePurchaseParams, this); } } else if (purchase.getPurchaseState() == PurchaseState.PENDING){ Snackbar.make(findViewById(android.R.id.content), "Purchase pending... weather will unlock when purchase is complete", Snackbar.LENGTH_LONG) .show(); } else if (advanced){ // advanced mode should no longer be active revokeAdvancedPurchase(); } } }
Example #4
Source File: DefaultBillingManager.java From SAI with GNU General Public License v3.0 | 5 votes |
private void acknowledgePurchase(Purchase purchase) { AcknowledgePurchaseParams acknowledgePurchaseParams = AcknowledgePurchaseParams.newBuilder() .setPurchaseToken(purchase.getPurchaseToken()) .build(); mBillingClient.acknowledgePurchase(acknowledgePurchaseParams, billingResult -> { if (billingResult.getResponseCode() == BillingClient.BillingResponseCode.OK) { Log.d(TAG, String.format("Acknowledged %s", purchase.getSku())); loadPurchases(); return; } Log.w(TAG, String.format("Unable to acknowledge purchase, code %d - %s", billingResult.getResponseCode(), billingResult.getDebugMessage())); }); }
Example #5
Source File: GoogleIap.java From remixed-dungeon with GNU General Public License v3.0 | 5 votes |
private void handlePurchase(Purchase purchase) { if (!verifySignature(purchase.getOriginalJson(), purchase.getSignature())) { EventCollector.logException("bad signature"); return; } //GLog.w("purchase: %s",purchase.toString()); //mBillingClient.consumeAsync(purchase.getPurchaseToken(),this); if (purchase.getPurchaseState() == Purchase.PurchaseState.PURCHASED) { // Acknowledge the purchase if it hasn't already been acknowledged. if (!purchase.isAcknowledged()) { AcknowledgePurchaseParams acknowledgePurchaseParams = AcknowledgePurchaseParams.newBuilder() .setPurchaseToken(purchase.getPurchaseToken()) .build(); mBillingClient.acknowledgePurchase(acknowledgePurchaseParams, billingResult -> { EventCollector.logEvent("billing_result", billingResult.getResponseCode() + "->" + billingResult.getDebugMessage()); }); } mPurchases.put(purchase.getSku().toLowerCase(Locale.ROOT), purchase); String orderId = purchase.getOrderId(); String purchaseData = purchase.getOrderId() +"," + purchase.getPackageName() + "," + purchase.getSku() + "," + purchase.getPurchaseToken(); if( !Preferences.INSTANCE.getBoolean(orderId,false) ) { EventCollector.logEvent("iap_data", purchaseData); Preferences.INSTANCE.put(orderId,true); } } }
Example #6
Source File: GoogleBillingHelper.java From Augendiagnose with GNU General Public License v2.0 | 5 votes |
/** * Acknowledge a purchase. * * @param purchase The purchase. */ private void doAcknowledgePurchaseIfRequired(final Purchase purchase) { if (!purchase.isAcknowledged()) { Log.d(TAG, "Acknowledging purchase " + purchase.getSku()); mBillingClient.acknowledgePurchase( AcknowledgePurchaseParams.newBuilder().setPurchaseToken(purchase.getPurchaseToken()).build(), new AcknowledgePurchaseResponseListener() { @Override public void onAcknowledgePurchaseResponse(final BillingResult billingResult) { Log.d(TAG, "Acknowledgement result: " + billingResult.getResponseCode()); } }); } }
Example #7
Source File: ActivityBilling.java From FairEmail with GNU General Public License v3.0 | 4 votes |
private void acknowledgePurchase(final Purchase purchase, int retry) { Log.i("IAB acknowledging purchase SKU=" + purchase.getSku()); AcknowledgePurchaseParams params = AcknowledgePurchaseParams.newBuilder() .setPurchaseToken(purchase.getPurchaseToken()) .build(); billingClient.acknowledgePurchase(params, new AcknowledgePurchaseResponseListener() { @Override public void onAcknowledgePurchaseResponse(BillingResult result) { if (result.getResponseCode() == BillingClient.BillingResponseCode.OK) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(ActivityBilling.this); SharedPreferences.Editor editor = prefs.edit(); editor.putBoolean("pro", true); editor.putLong(purchase.getSku() + ".cached", new Date().getTime()); editor.apply(); for (IBillingListener listener : listeners) listener.onPurchased(purchase.getSku()); WidgetUnified.updateData(ActivityBilling.this); } else { if (retry < 3) { new Handler().postDelayed(new Runnable() { @Override public void run() { acknowledgePurchase(purchase, retry + 1); } }, (retry + 1) * 10 * 1000L); } else reportError(result, "IAB acknowledged SKU=" + purchase.getSku()); } } }); }