Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Android] acknowledgePurchaseAndroid() Google is indicating that we have some issue connecting to payment. #721

Closed
francois-pasquier opened this issue Sep 18, 2019 · 39 comments
Labels
🤖 android Related to android 🙏 help wanted Extra attention is needed

Comments

@francois-pasquier
Copy link

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)
    })
  }
@hyochan
Copy link
Member

hyochan commented Sep 18, 2019

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 hyochan added 🤖 android Related to android 🙏 help wanted Extra attention is needed labels Sep 18, 2019
@francois-pasquier
Copy link
Author

francois-pasquier commented Sep 18, 2019

@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 ?

@hyochan
Copy link
Member

hyochan commented Sep 19, 2019

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

@francois-pasquier
Copy link
Author

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

@hyochan
Copy link
Member

hyochan commented Sep 19, 2019

@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

@francois-pasquier
Copy link
Author

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

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

Any idea ?

@hyochan
Copy link
Member

hyochan commented Sep 20, 2019

@MeisterTea I think I found useful LINK for you.

@hyochan
Copy link
Member

hyochan commented Sep 28, 2019

@MeisterTea Was this helpful?

@francois-pasquier
Copy link
Author

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

@ivpusic
Copy link

ivpusic commented Oct 14, 2019

having the same issue. any solution for this?

@francois-pasquier
Copy link
Author

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.

@ivpusic
Copy link

ivpusic commented Oct 15, 2019

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

@maximedupre
Copy link

maximedupre commented Oct 29, 2019

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.

@matamicen
Copy link

matamicen commented Nov 2, 2019

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 to await 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.

@stale
Copy link

stale bot commented Mar 26, 2020

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.

@stale stale bot added the 🚶🏻 stale Stale label Mar 26, 2020
@schumannd
Copy link
Contributor

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

@stale stale bot removed the 🚶🏻 stale Stale label Apr 21, 2020
@creativemind1
Copy link

I'm getting the same error with RNIap.finishTransaction

@hyochan
Copy link
Member

hyochan commented May 3, 2020

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

@creativemind1
Copy link

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

@dmitrybolt
Copy link

dmitrybolt commented May 22, 2020

Same error, but on getProducts

@rafaeelrf
Copy link

rafaeelrf commented Jun 6, 2020

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

@creativemind1
Copy link

creativemind1 commented Jun 6, 2020 via email

@rafaeelrf
Copy link

I already added, but the problem was not solved

@francois-pasquier
Copy link
Author

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

@Rashi-jain21
Copy link

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

@faris-mohamed10
Copy link

I'm getting the same error with RNIap.finishTransaction

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

@compelling
Copy link

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.

@compelling
Copy link

compelling commented Sep 22, 2020

@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?

@faris-mohamed10
Copy link

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

@compelling
Copy link

compelling commented Sep 24, 2020

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);
});
});

@odanicola
Copy link

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.

@lukefanning
Copy link

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

@ksielyov
Copy link

ksielyov commented Jun 3, 2021

Getting same when:

IAP.requestPurchase(product.productId) .then(r => { console.log("purchase success", r); props.navigation.navigate("ChatLists"); }) .catch(r => console.log("purchase error", r));

@ksielyov
Copy link

ksielyov commented Jun 3, 2021

purchase error Error: Google is indicating that we have some issue connecting to payment.
at Object.promiseMethodWrapper [as buyItemByType] (VM4 index.bundle:2242)
at VM4 index.bundle:142829
at step (VM4 index.bundle:142328)
at Object.next (VM4 index.bundle:142258)
at fulfilled (VM4 index.bundle:142212)
at tryCallOne (VM4 index.bundle:27056)
at VM4 index.bundle:27157
at VM4 index.bundle:30708
at _callTimer (VM4 index.bundle:30596)
at _callImmediatesPass (VM4 index.bundle:30635)

@diegogurgel
Copy link

I was getting this error and I added implementation 'com.android.billingclient:billing:4.0.0' to my /app/build.gradle. I didn't test in release mode yet but it seems to solve the issue.

@pasindu-codimite
Copy link

I used hooks given in react-native-iap library, Then I had to use above solution like below,

      if (Platform.OS == 'android' && currentPurchase.purchaseToken) {
        acknowledgePurchaseAndroid({
          token: currentPurchase.purchaseToken,
          developerPayload: currentPurchase.developerPayloadAndroid,
        })
          .then(() => {
            finishTransaction({
              purchase: currentPurchase,
              isConsumable: true,
              developerPayloadAndroid:
                currentPurchase.developerPayloadAndroid,
            }).catch(err => {
              console.error(err.code+" finish", err.message);
            });
          })
          .catch(err => {
            console.error(err.code+ " acknowledge", err.message);
          });
      } else {
        await finishTransaction({
          purchase: currentPurchase,
          isConsumable: true,
        });
      }

@jiemar
Copy link

jiemar commented Oct 7, 2023

I used hooks given in react-native-iap library, Then I had to use above solution like below,

      if (Platform.OS == 'android' && currentPurchase.purchaseToken) {
        acknowledgePurchaseAndroid({
          token: currentPurchase.purchaseToken,
          developerPayload: currentPurchase.developerPayloadAndroid,
        })
          .then(() => {
            finishTransaction({
              purchase: currentPurchase,
              isConsumable: true,
              developerPayloadAndroid:
                currentPurchase.developerPayloadAndroid,
            }).catch(err => {
              console.error(err.code+" finish", err.message);
            });
          })
          .catch(err => {
            console.error(err.code+ " acknowledge", err.message);
          });
      } else {
        await finishTransaction({
          purchase: currentPurchase,
          isConsumable: true,
        });
      }

It doesn't work.
After changing code like this, err remain
'E_DEVELOPER_ERROR finish', 'Google is indicating that we have some issue connecting to payment.'

@cetfu
Copy link

cetfu commented Dec 18, 2023

Getting same error. Is there any solution?

[Error: Google is indicating that we have some issue connecting to payment.]

Tested on real Android device. in debug-release modes
When using acknowledge and finishTransaction for subscriptions

@cetfu
Copy link

cetfu commented Dec 18, 2023

https://github.com/dooboolab-community/react-native-iap/blob/aab948226fd075c759022503af45286262e8ff97/IapExample/src/screens/Subscriptions.tsx#L68C12-L68C32
i guess it was a wrong usage.

#2578 (comment)
This usage solved my problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🤖 android Related to android 🙏 help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests