react-native-iap: Cannot connect to iTunes Store for sandbox users
Version of react-native-iap
2.2.2
Platforms you faced the error (IOS or Android or both?)
iOS
Expected behavior
await RNIap.buyProduct(MIXED_PACK); should not fail
Actual behavior
I get the error Cannot connect to iTunes Store even if I use a sandbox user
Tested environment (Emulator? Real Device?)
Real device, iPad and iPhone 7
Steps to reproduce the behavior
Just try to run that piece of code. I have read thoroughly the Blog to create a sandbox environment here https://medium.com/@dooboolab/react-native-in-app-purchase-121622d26b67
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 6
- Comments: 17 (11 by maintainers)
Commits related to this issue
- Released 2.3.4. Get originalJson in Android as a transanctionReceipt for validation #277. — committed to dooboolab-community/react-native-iap by hyochan 6 years ago
For anyone else stumbling onto issue, also note “Your app is running in the Simulator, which does not support in-app purchase.” is another reason that you may get this error. Must do this on a real device.
@dooboolab I have tried using both
RNIap.buyProduct(sku)andRNIap.buyProductWithoutFinishTransaction(sku)withRNIap.finishTransaction(), and for both I have usedRNIap.validateReceiptIos(receiptBody, true);, withconst receiptBody = {'receipt-data': purchase.transactionReceipt, password: '[apple-id-password]'};, but no luck. Also it is worth noting that whichever password I put in ‘[apple-id-password]’,validateReceiptIosresponse is always the same. This is an example:As you might have noticed,
receipt_type: 'ProductionSandbox', which should be caused by the fact I am using a real Apple ID username in a sandbox environment (I am not able to create a working test sandbox user, thank you Apple for making our life a living hell).A note from apple in relation to this error: https://developer.apple.com/library/archive/technotes/tn2413/_index.html#//apple_ref/doc/uid/DTS40016228-CH1-ERROR_MESSAGES-CANNOT_CONNECT_TO_ITUNES_STORE
I think in my case, I get this error when attempting to subscribe to a product when I’m already subscribed to it. It also appears to come up when I’m subscribed and attempting to change my subscription (by initiating a new
RNIAP.buySubscriptionrequest.Figured it out, I wasn’t calling the “finishTransaction()” so i was stuck in a loop on my sandbox test account “Purchase was successful” but didn’t not fully process on Apple’s side they called it a dead loop.