question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Acknowledge Purchase does not work for Android

See original GitHub issue

I try to Acknowledge consumable products but it is not working. I’m getting {"acknowledged":false} response with receipt

I tried two methods according to docs.

v:4.4.8 platform: android device: real device

try {
          if (Platform.OS === 'ios') {
            RNIap.finishTransactionIOS(purchase.transactionId);
          } else if (Platform.OS === 'android') {
            // If consumable (can be purchased again)
            RNIap.consumePurchaseAndroid(purchase.purchaseToken);
          }
        } catch (ackErr) {
          console.warn('ackErr', ackErr);
        }

and

 try {
          const ackResult = await finishTransaction(purchase, true);
          console.log('ackResult', ackResult);
        } catch (ackErr) {
          console.warn('ackErr', ackErr);
        }

Errors:

Possible Unhandled Promise Rejection (id: 1):
Error: Google is indicating that we have some issue connecting to payment.
Error: Google is indicating that we have some issue connecting to payment.

But I can see purchase in my Google Play console and its accepted.

I’m testing my purchases with Google Test Account, and Android docs says:

https://developer.android.com/google/play/billing/billing_library_overview#test_acknowledging_purchase_with_license_testers

Test acknowledging purchase with license testers For purchases made by license testers, the acknowledgement window is shorter. Instead of three days, purchases are refunded and revoked if they are not acknowledged within five minutes.

After 5 minutes my purchases there (actually I’m trying for 3-4 hours and all purchases there). There is no problem on Google Play side but some things are not consistent.

{"acknowledged":false} worries me

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:3
  • Comments:12 (1 by maintainers)

github_iconTop GitHub Comments

4reactions
triplumixcommented, Aug 7, 2020

I’m experiencing the same issue. Purchase is done, I can see it in Publisher Console, but then it gets refunded.

2reactions
yusufpamukcucommented, Nov 18, 2020

I’m experiencing the same issue. Purchase is done, I can see it in Publisher Console, but then it gets refunded.

Hi, Although the purchase was completed, it was making a refund and I solved it with the following function.

requestPurchase = async () => {
    await RNIap.initConnection();
    try {
      await RNIap.requestPurchase("productCode", true);
       await RNIap.purchaseUpdatedListener(
        purchase => {
          RNIap.consumePurchaseAndroid(purchase.purchaseToken);
          RNIap.acknowledgePurchaseAndroid(purchase.purchaseToken);
        // the purchase has been made
        });
    } catch (err) {
      console.log(err)
       console.warn(err.code, err.message);
    }
  }
Read more comments on GitHub >

github_iconTop Results From Across the Web

How to acknowledge in-app purchases in android?
First, create the AcknowledgePurchaseParams Class object. For this you need the purchase token which you should be able to get easily as you ......
Read more >
Problems with in-app purchases - Google Play Help
If you're trying to make an in-app purchase but the transaction is declined or the payment won't go through, try to fix payment...
Read more >
Integrate the Google Play Billing Library into your app
To acknowledge non-consumable purchases, use either BillingClient.acknowledgePurchase() from the Google Play Billing Library or Product.
Read more >
How do I acknowledge an android subscription or purchase?
Google will give you up to 3 days to acknowledge the purchase from your side. If not acknowledged, it will be refunded to...
Read more >
Method: purchases.products.acknowledge - Google Developers
The token provided to the user's device when the inapp product was purchased. Request body. The request body contains data with the following...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found