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

Acknowledge Purchase does not work for Android #1006

Closed
hakkikonu opened this issue May 13, 2020 · 12 comments
Closed

Acknowledge Purchase does not work for Android #1006

hakkikonu opened this issue May 13, 2020 · 12 comments
Labels
🤖 android Related to android 🕵️‍♂️ need more investigation Need investigation on current issue

Comments

@hakkikonu
Copy link

hakkikonu commented May 13, 2020

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

@hakkikonu hakkikonu changed the title Acknowledge Purchase does not working for Android Acknowledge Purchase does not work for Android May 19, 2020
@hyochan hyochan added 🤖 android Related to android 🕵️‍♂️ need more investigation Need investigation on current issue labels May 20, 2020
@hyochan
Copy link
Owner

hyochan commented May 20, 2020

Could someone else share anything about this? I've not experienced this yet.

@jsfit
Copy link

jsfit commented May 20, 2020

Getting same error

react-native-iap: 4.4.8
react-native: 0.61.5
on real device Nexus 6(7.1.1)

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

catch block executed most of the time

    purchaseUpdateSubscription = purchaseUpdatedListener(
      async (purchase: InAppPurchase | SubscriptionPurchase) => {
        const receipt = purchase.transactionReceipt;
        if (receipt) {
          try {
            const ackResult = await finishTransaction(purchase);
            console.warn('ackResult', ackResult);
          } catch (ackErr) {
             console.warn('ackErr', ackErr);
          }

subscription is done
because getting purchases response

const purchases = await RNIap.getAvailablePurchases()

@triplumix
Copy link

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

@ryandoss
Copy link

Has anyone found a solution for this? Have some very frustrated clients...

@kalideir
Copy link

Has anyone found a solution for this? Have some very frustrated clients...

Have you found the mystery behind this?

@stefanoromanello
Copy link

Any update on this issue?

@yusufpamukcu
Copy link

+++++

@wdospinal
Copy link

wdospinal commented Nov 18, 2020

Hi, I'm getting the same problem and also no clue about it

Sentry is reporting:
"ackErr",{"code":"E_DEVELOPER_ERROR","name":"Error","column":1111,"nativeStackAndroid":"[Array]","stack":"index.android.bundle:21:1111\nindex.android.bundle:1441:12207\[email protected]:740:3079\nindex.android.bundle:740:2380\nindex.android.bundle:740:2070\[email protected]:129:205\[email protected]:129:1586\[email protected]:129:484\[email protected]:740:1833\[email protected]:1441:11967\[email protected]:1441:12338\nindex.android.bundle:1440:3666\[email protected]:113:587\nindex.android.bundle:113:1890\[email protected]:113:587\[email protected]:113:1066\nindex.android.bundle:113:1209\[email protected]:129:155\nindex.android.bundle:129:864\[email protected]:134:581\[email protected]:134:947\[email protected]:134:3004\[email protected]:30:2919\nindex.android.bundle:30:1095\[email protected]:30:2611\[email protected]:30:1065\nvalue@[native code]\nvalue@[native code]","sourceURL":"index.android.bundle","userInfo":null,"line":21,"message":"Google is indicating that we have some issue connecting to payment."}]

purchaseUpdateSubscription = purchaseUpdatedListener(async purchase => {
      const receipt = purchase.transactionReceipt;
      if (receipt) {
        const platform = Platform.OS === "ios" ? "APP_STORE" : "PLAY_STORE";
        const { result, error } = await saveSubscriptionToServer(
          purchase,
          platform
        );
        if (!error) {
          console.log("subscription", result);
          this.props.setSubscription(result);
          try {
            if (Platform.OS === "ios") {
              finishTransactionIOS(purchase.transactionId);
            } else if (Platform.OS === "android") {
              acknowledgePurchaseAndroid(purchase.purchaseToken);
            }
            const ackResult = await finishTransaction(purchase);
            console.log(ackResult);
          } catch (ackErr) {
            console.warn("ackErr", ackErr);
            Sentry.captureException(ackErr);
          }
        }
        this.setState({ receipt });
      }
    });

@yusufpamukcu
Copy link

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

@andersmurphy
Copy link

Any updates on this? Billing is basically broken for android if you use finishTransaction.

@StefanoCremona
Copy link

StefanoCremona commented May 5, 2021

I had the same problem trying to purchase a subscription with "react-native-iap": "^5.0.1", and calling RNIap.finishTransaction(purchase, true).
Subscriptions can't be considered consumable, neither non consumable products, so I just removed the second parameter in the finishTransaction call:

RNIap.finishTransaction(purchase)

and it works.

If a put back RNIap.finishTransaction(purchase, true), I have the behaviour you have documented @hakkikonu
false works well either.

@andresesfm
Copy link
Contributor

This has been solved in 7.3.0. finishTransaction will call consumePurchaseAndroid or acknowledgePurchaseAndroid` depending on the parameter second parameter that indicates if the purchase was for a consumable.

This thread is a bit old and doesn't reflect the newest changes. If the issue remains on 7.3.0 or newer I'll be happy to take a look. Closing for now, please create a new issue if needed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🤖 android Related to android 🕵️‍♂️ need more investigation Need investigation on current issue
Projects
None yet
Development

No branches or pull requests