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.

Buying the same product twice will give an error

See original GitHub issue

Version of react-native-iap

0.3.13

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

iOS

Expected behavior

Expected to buy a product without an issues

Actual behavior

First time I buy a product_A on a “new” device - it works. Second time I try to buy the same product_A (no matter if I restart the app or not) will not work. The error message is: “An unknown or unexpected error has occurred. Please try again later.”

Steps to reprodue the behabior

1.Implement IAP as in ReadME. Try to buy an item with this code:


try {
      const msg = await RNIap.prepare()
      const products = await RNIap.getProducts([`${productId}`])
      const purchase = await RNIap.buyProduct(productId)
      this.props.purchaseCoinsPack(coinsPack)
      await RNIap.consumePurchase(purchase.transactionReceipt)
    } catch (err) {
      alert(err.message);
    }

Just in case I have this code in my componentDidMount() and componentWillUnmount():


getPurchases = async () => {
    try {
      const purchases = await RNIap.getAvailablePurchases();
      purchases.forEach(async purchase => {
        const boughtPack = R.find(R.propEq('androidStoreId', purchase.productId))(this.props.coinsPacks)
        if (boughtPack) {
          this.props.purchaseCoinsPack(boughtPack);
          await RNIap.consumePurchase(purchase.transactionReceipt);
        }
      })
    } catch (err) {
      console.warn(err); // standardized err.code and err.message available
    } finally {
      this.setState({ isLoading: false })
    }
  }

  async componentDidMount() {
    try {
      await RNIap.prepare()
    } catch (err) {
      console.warn(err);
    }
    this.getPurchases()
  }

  async componentWillUnmount() {
    RNIap.endConnection()
  }

2.First buy works ok. Try to buy same product once again Get an alert with "“An unknown or unexpected error has occurred. Please try again later.”

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
benevbrightcommented, Apr 20, 2018

latest v0.3.15 will give you the error code with a message. So can you please try the latest release again and what the error code is? If the error code is -1001, it might be a temporary sandbox’s issue from Apple. I will look this issue as well.

1reaction
benevbrightcommented, Apr 21, 2018

Good to hear that! It may be a temporary issue from Apple since new release did not change anything but the log. There have been so many problems when we test with the sandbox. Most cases do not happen in production released by App Store.

Read more comments on GitHub >

github_iconTop Results From Across the Web

What do you do when you accidentally buy the same thing ...
Contact the seller. apologize for your mistake and ask seller to send you a cancel Transaction Request for one of the.. It's important...
Read more >
What to do when you're billed twice for the same goods or ...
“If cardholders identify a purchase they didn't authorize, they should immediately contact the bank that issued their card and dispute the ...
Read more >
Purchased same item twice - Microsoft Community
If you could make the purchase again, it sounds like you tried it from another account and not the one that made the...
Read more >
purchased twice use the same apple id - Apple Developer
when i purchased the same product twice using the same apple id .The second time i recieved SKErrorPaymentCancelled status at first, then i...
Read more >
Does anyone know if we can grab the same product twice on ...
You'll get a "you've already requested a version of that item" error msg. There's no need to make up artificial restrictions on yourself....
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