com.android.billingclient.api.AcknowledgePurchaseResponseListener Java Examples
The following examples show how to use
com.android.billingclient.api.AcknowledgePurchaseResponseListener.
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: 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 #2
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()); } } }); }