React-native-iap: [Android] acknowledgePurchaseAndroid() Google is indicating that we have some issue connecting to payment.

Created on 18 Sep 2019  ·  32Comments  ·  Source: dooboolab/react-native-iap

Version of react-native-iap > 3.4.12

Version of react-native > 0.58.3

Platforms you faced the error > Android

Actual behavior

I have got a
Google is indicating that we have some issue connecting to payment. error
In logcat I get a E/DoobooUtils: Error Code : 5

I was using version 2.5.5 previously, it was working fine.
The only thing not working there is the acknowledgePurchaseAndroid call

Tested environment > Real Device

Here is my code :

  handleServerSubscribe = async purchase => {
    const {
      productId,
      transactionReceipt,
    } = purchase
    if (transactionReceipt) {
      try {
          // FIXME it fails right here
          await acknowledgePurchaseAndroid(purchase.purchaseToken)

      } catch (e) {
        console.log('subscription error ', e)
      }
    }
  }


componentDidMount() {
    this.purchaseUpdateSubscription = purchaseUpdatedListener(purchase => {
      this.handleServerSubscribe(purchase)
    })
  }
🙏 help wanted 🤖 android

Most helpful comment

I got it working: I just made these specific lines for Android, but the need to do so was not very apparent from the documentation. Now it works both on Android and iOS:
// on Android we need to acknowledge purchase or finishTransaction fails
// if we do not acknowledge, purchase will roll back in 5 min
RNIap.acknowledgePurchaseAndroid(purchase.purchaseToken).then(() => {
RNIap.finishTransaction(purchase, true).catch(err => {
console.log(err.code, err.message);
});
});

All 32 comments

If acknowledgePurchase isn't working, it feels like you've not correctly updated billingClient in android to 2.0.3. Could you check your build.gradle?

@hyochan well, it looks like I don't have it but I have no clue where I can get the correct syntax.
Is it supposed to be in the README ?

Try to find the line com.android.billingclient:billing by searching.

Well, I didn't have it, I only had

 implementation project(':react-native-iap')

Do I need both implementations ?

 implementation 'com.android.billingclient:billing:2.0.3'
 implementation project(':react-native-iap')

I stil have the same error

@MeisterTea I wanted you to check the version of the billingclient in your installed react-native-iap project. Check inside node_modules/react-native-iap/android/build.gradle

oh, my bad... Yes, it does have the right version

  implementation 'com.android.billingclient:billing:2.0.3'

Any idea ?

@MeisterTea I think I found useful LINK for you.

@MeisterTea Was this helpful?

Well, I still have the error :
js bridge: Google is indicating that we have some issue connecting to payment.
logcat: E/DoobooUtils: Error Code : 5

await acknowledgePurchaseAndroid(purchase.purchaseToken)

, I have some questions:

  • Do you have any other idea how I could fix the issue ?
  • How can I debug and use my release key ? react-native run-android seems to always install a generic debug key even after copying my release keystore as debug.keystore and pointing to it inside the build.gradle

EDIT: It's all the same with the sample project of react-native-iap.
I change the versionCode to the latest I uploaded on the beta track, gave it the release key, added my subscription id, changed the code to load subscriptions, done a react-native run-android variant=release

I can buy the subscription but I am still getting the error 5

having the same issue. any solution for this?

Yes, it's to due to acknowledging a PENDING payment.
IMO, licence testers shouldn't have a PENDING state anyway so maybe Google is at fault there.

I get the same issue also for payments which have the state purchaseStateAndroid 1 (PURCHASED)

Yes, it's to due to acknowledging a PENDING payment.

I confirm this. I never get an error when the purchaseState is 1.

Edit:

Yet the purchase is still acknowledged. in other words, there is an error, but it's still working.

I had the same problem and I realized that problem was that the PurchaseToken was already confirmed. So I fix the problem controlling the call toawait acknowledgePurchaseAndroid(purchase.purchaseToken). @hyochan

So i had to check if purchases[0].isAcknowledgedAndroid from RNIap.getAvailablePurchases() is false to call the acknowledgePurchaseAndroid.

Hope it helps.

Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as "For Discussion" or "Good first issue" and I will leave it open. Thank you for your contributions.

I have had the same error message recently. So I'd say this should stay active.

I'm getting the same error with RNIap.finishTransaction

@creativemind1 What version are you using? finishTransaction should work on both iOS and android.

I'm using "react-native-iap": "^4.4.1" and when I'm calling finishTransaction in Android, I'm getting error from Google Google is indicating that we have some issue connecting to payment. So after getting successful response from my server I'm calling RNIap.acknowledgePurchaseAndroid which is working but not finishTransaction

Same error, but on getProducts

Same error, but on consumeProduct.

Error when making a subscription:
Error: Google is indicating that we have some issue connecting to payment. at Object.fn [as consumeProduct] (VM4 index.bundle:2143)

Error when buying a product:
Error: Purchase failed with code: 8 at Object.fn [as consumeProduct] (NativeModules.js:99)

react-native: 0.61
react-native-iap version: 4.4.9

I think if you add the email address in the test users of.google play
settings you will nit see tgat issue

On Sat, Jun 6, 2020, 8:41 PM rafaeelrf notifications@github.com wrote:

Same error, but in consumeProduct:
Error: Google is indicating that we have some issue connecting to payment.
at Object.fn [as consumeProduct] (VM4 index.bundle:2143)


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/dooboolab/react-native-iap/issues/721#issuecomment-640075737,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/ABH54CL5FLAY4C7CTL2V3V3RVJMA7ANCNFSM4IX5EJQA
.

I already added, but the problem was not solved

If I remember right, you can't do it client side when you are on test servers because there is a slight delay between issuing the payment and server validation.
We had to move this logic server side

Hi I am getting the same error while RNIap.acknowledgePurchaseAndroid(purchase.purchaseToken); API. Can someone please help

I'm getting the same error with RNIap.finishTransaction

me too having this issue using the latest version and test card is used

Same problem here, calling RNIap.finishTransaction(purchase, true) from my purchaseUpdatedListener that gets called as it should just after my RNIap.requestSubscription. This leads to the error. After 5 min I get the cancellation mail "This test purchase was canceled because it was not confirmed" from Google. Of course, I am using a test account, but that ought to be ok.
The same code works like a charm on iOS.

@MeisterTea what did you do in the backend, did you find out what the equivalent google request of RNIap.finishTransaction(purchase, true) was? Can you share some code snippet or other info, so the rest of us can use that solution until the plugin works again?

my issue was, I was calling finishtransaction 2 times. when I removed it, worked fine

I got it working: I just made these specific lines for Android, but the need to do so was not very apparent from the documentation. Now it works both on Android and iOS:
// on Android we need to acknowledge purchase or finishTransaction fails
// if we do not acknowledge, purchase will roll back in 5 min
RNIap.acknowledgePurchaseAndroid(purchase.purchaseToken).then(() => {
RNIap.finishTransaction(purchase, true).catch(err => {
console.log(err.code, err.message);
});
});

i dont know if this working or not for you (this code for consumeProduct):

await RNIap.finishTransaction(purchase).then(async () => { await RNIap.consumePurchaseAndroid(purchase.purchaseToken).then(async () => { console.log('purchase :', purchase) }).catch(err => { console.log('consume error: ', err.code, err.message) Alert.alert('consume finish error: ', err.message) }); }).catch(err => { console.log('finish error: ', err.code, err.message) Alert.alert('purchase finish error: ', err.message) })

I need to finish the transaction at first then revoke the purchase by hitting the consumePurchaseAndroid() as the code above. Hope it helps.

I got it working: I just made these specific lines for Android, but the need to do so was not very apparent from the documentation. Now it works both on Android and iOS:
// on Android we need to acknowledge purchase or finishTransaction fails
// if we do not acknowledge, purchase will roll back in 5 min
RNIap.acknowledgePurchaseAndroid(purchase.purchaseToken).then(() => {
RNIap.finishTransaction(purchase, true).catch(err => {
console.log(err.code, err.message);
});
});

That seems to work for me too, i'm using v5.0.0

Was this page helpful?
0 / 5 - 0 ratings