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

.clearTransaction() throwing "Cannot finish a purchasing transaction" #491

Closed
ilyakar opened this issue May 18, 2019 · 5 comments · Fixed by #510
Closed

.clearTransaction() throwing "Cannot finish a purchasing transaction" #491

ilyakar opened this issue May 18, 2019 · 5 comments · Fixed by #510
Labels
🙏 help wanted Extra attention is needed 📱 iOS Related to iOS

Comments

@ilyakar
Copy link

ilyakar commented May 18, 2019

Version of react-native-iap

2.4.8

Version of react-native

0.57.1

Platforms you faced the error (IOS or Android or both?)

iOS

Expected behavior

Purchase to go through

Actual behavior

Crashes sometimes when .clearTransaction() above .buyProduct()

Tested environment (Emulator? Real Device?)

Real device

Steps to reproduce the behavior

The doc states:

await RNIap.clearTransaction(); // add this method at the start of purchase.
const purchase = await RNIap.buyProduct(...)
...

Not having the .clearTransaction causes "Already bought this product" for consumables, having the .clearTransaction throws "Cannot finish a purchasing transaction" (sometimes).

What's the solution?

@hyochan
Copy link
Owner

hyochan commented May 20, 2019

@ilyakar Can you try clearProducts?

@hyochan hyochan added 🙏 help wanted Extra attention is needed 📱 iOS Related to iOS labels May 20, 2019
@javascripter
Copy link

We observed the same error in our production app too. In our case however, this happened for .clearTransaction() above .buySubscription().
I'm not too sure whether .clearTransaction() is really required for auto-renewable subscriptions, but we have similar code for consumables too.

If this should be a separate issue, please tell me so.

Version of react-native-iap

2.4.8

Version of react-native

0.59.8

Platforms you faced the error (IOS or Android or both?)

iOS

Tested environment (Emulator? Real Device?)

Real device

Steps to reproduce the behavior

let subscription = null

async function subscribe() {
  let purchase = null

  try {
    if (subscription) {
      subscription.remove()
      subscription = null
    }
    await RNIap.clearTransaction()

    purchase = await RNIap.buySubscription(SUBSCRIPTION_SKU)
  } catch (ex) {
    purchase = await new Promise((resolve, reject) => {
      subscription = RNIap.addAdditionalSuccessPurchaseListenerIOS(
        purchase => {
          // ... (code for checking item sku)
          resolve(purchase)
          subscription.remove()
          subscription = null
        }
      )
    })
  }

  if (!purchase) {
    return
  }
  // purchased 
}

The error is thrown only sometimes. We suspect calling subscribe again while subscribe is running may be causing errors

@hyochan hyochan mentioned this issue Jun 9, 2019
17 tasks
@WJimmyCook
Copy link

@javascripter I'm having the same error occasionally and I think you are right about calling subscribe again while subscribe is running. For me, I believe it happens because the user is quickly tapping the purchase button two or more times before the purchase confirmation screen from apple pops up.

@curiousdustin
Copy link
Contributor

I am getting this error, and associated crash.

I am using react-native-iap 2.4.4, and I don't necessarily want to upgrade to 3.x yet.

I am calling clearTransaction() before buySubscription().

It is only crashing occasionally.

I am only using subscription IAP.

Like @javascripter , it is unclear to me if clearTransaction() is needed for subscriptions.

Is there anything I can do to avoid this issue and crash?

@hyochan
Copy link
Owner

hyochan commented Jul 9, 2019

Might be related to #581. We are looking forward to digging it.

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

Successfully merging a pull request may close this issue.

6 participants
@javascripter @curiousdustin @ilyakar @WJimmyCook @hyochan and others