React-native-iap: No callback for transaction with state purchased.

Created on 10 Apr 2019  ·  2Comments  ·  Source: dooboolab/react-native-iap

Version of react-native-iap

2.4.7

Version of react-native

0.57.8

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

iOS

Actual behavior

its my first IAP test and i need help.

When I purchase the product i still purchased (Sandbox) I get "You allready buyed this product. The product will be restored." But i get no callback or return. How can i handle this restoring process so i can save the purchased state and the User can use the Product?
Or does'nt it work this way?

My Code

   const purchase = await RNIap.buyProduct(identifier);
    this.setState({
      receipt: purchase.transactionReceipt
    });
this._saveProductIsBuyed()

Tested environment (Emulator? Real Device?)

Real device (iPad)

Thanks for help

❓ question 📱 iOS

Most helpful comment

Hello @hyochan
thank you for answering so fast.
I don't think i missunderstood it. I think i did'nt explain it exactly:

Use-Case:
user can buy a product (one-time purchase for example 'Premium')

  1. user buys this product.
  2. user install the App on another device (same Apple ID)

Now, i have seen it on other Apps:
Product is not showed as buyed (because i don't want to ask for already buyed products at App-Start, as i said, i have seen it on other Apps)

  1. user clicks on "buy product"
  2. Alert "alredy buyed" is viewed and the Message that the purchase will be restored is showed.
    But nothing happens.

For this i need a return that the Product is restored but i do not get anything and the next console.log is not showed.

const purchase = await RNIap.buyProduct(productIdentifier);
console.log('TEST', purchase); <= will not be shown

All 2 comments

@Finneah You are not understanding the iap feature correctly. Restore purchase is to get products you've already purchased in other device when you reinstalled the app. To re-buy the item you should create product as consumable.

Hello @hyochan
thank you for answering so fast.
I don't think i missunderstood it. I think i did'nt explain it exactly:

Use-Case:
user can buy a product (one-time purchase for example 'Premium')

  1. user buys this product.
  2. user install the App on another device (same Apple ID)

Now, i have seen it on other Apps:
Product is not showed as buyed (because i don't want to ask for already buyed products at App-Start, as i said, i have seen it on other Apps)

  1. user clicks on "buy product"
  2. Alert "alredy buyed" is viewed and the Message that the purchase will be restored is showed.
    But nothing happens.

For this i need a return that the Product is restored but i do not get anything and the next console.log is not showed.

const purchase = await RNIap.buyProduct(productIdentifier);
console.log('TEST', purchase); <= will not be shown
Was this page helpful?
0 / 5 - 0 ratings

Related issues

chetstone picture chetstone  ·  4Comments

MacMillan13 picture MacMillan13  ·  3Comments

safciplak picture safciplak  ·  3Comments

Symyon picture Symyon  ·  5Comments

iutin picture iutin  ·  4Comments