2.2.2
iOS
await RNIap.buyProduct(MIXED_PACK);
should not fail
I get the error Cannot connect to iTunes Store
even if I use a sandbox user
Real device, iPad and iPhone 7
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
I think it is an old link. https://developer.apple.com/system-status/
@raynor85 Are you still facing this issue?
@dooboolab I’m still facing the issue, but I think it is an Apple problem. I have tried to purchase a product with my personal Apple ID user (which has been previously used for real purchases), and I was able to get a successful response after executing RNIap.buyProduct(“my.sku.product”)
.
The funny thing is in the modal which pops up just before the purchase it is written environment: sandbox
, probably because I was running a dev build, and most importantly I think I was not charged for the purchase at all. Checking the purchase history there is nothing related to that, and if I execute RNIap.getAvailablePurchases()
and RNIap.getPurchaseHistory()
I got empty responses from both. Why is that?
@dooboolab can you help me with that? Is there a reason why with a real apple ID I was able to successfully purchase a consumable without being charged, but RNIap.getPurchaseHistory()
is always an empty array?
@raynor85 Did you connect the transaction result to your server ?
@dooboolab I have tried using both RNIap.buyProduct(sku)
and RNIap.buyProductWithoutFinishTransaction(sku)
with RNIap.finishTransaction()
, and for both I have used RNIap.validateReceiptIos(receiptBody, true);
, with const 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]', validateReceiptIos
response is always the same.
This is an example:
{ receipt:
{ receipt_type: 'ProductionSandbox',
adam_id: 0,
app_item_id: 0,
bundle_id: 'io.fantastec.swap',
application_version: '8',
download_id: 0,
version_external_identifier: 0,
receipt_creation_date: '2018-10-09 19:16:09 Etc/GMT',
receipt_creation_date_ms: '1539112569000',
receipt_creation_date_pst: '2018-10-09 12:16:09 America/Los_Angeles',
request_date: '2018-10-09 19:16:10 Etc/GMT',
request_date_ms: '1539112570436',
request_date_pst: '2018-10-09 12:16:10 America/Los_Angeles',
original_purchase_date: '2013-08-01 07:00:00 Etc/GMT',
original_purchase_date_ms: '1375340400000',
original_purchase_date_pst: '2013-08-01 00:00:00 America/Los_Angeles',
original_application_version: '1.0',
in_app:
[ { quantity: '1',
product_id: 'basic_pack',
transaction_id: '1000000455003078',
original_transaction_id: '1000000455003078',
purchase_date: '2018-10-09 19:16:09 Etc/GMT',
purchase_date_ms: '1539112569000',
purchase_date_pst: '2018-10-09 12:16:09 America/Los_Angeles',
original_purchase_date: '2018-10-09 19:16:09 Etc/GMT',
original_purchase_date_ms: '1539112569000',
original_purchase_date_pst: '2018-10-09 12:16:09 America/Los_Angeles',
is_trial_period: 'false' } ] },
status: 0,
environment: 'Sandbox' }
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).
@raynor85 Actually, I don't know why this is happening. I might have to try this out in near future. Also, did you try to test this through the test flight? If you haven't upload the app to test flight
I think it may happen. Also, I agree with your last quote!
I haven't tried to upload the app on testFlight, because I'd like to have a dev version to work with before potentially upload a broken beta build. Maybe codepush could be handy in this case. Anyway, can you please explain the meaning of const receiptBody = {'receipt-data': purchase.transactionReceipt, password: '[apple-id-password]'}
? I have tried to put any password, and I still get the same outcome. Does password
represents the apple id password of the user? If that is the case, how can I get that information without asking the user to insert it?
Also, what about accessToken
needed for validateReceiptAndroid
? I have checked the amazing post on stack overflow you mentioned, but there is no clear guide on how I can get the accessToken, do you recommend a dead simple way to get that access_token without necessarily build a server? The doc says that it is possible to do receiptVerification on the device directly: https://developer.android.com/google/play/billing/billing_library_overview
@raynor85
accessToken
via play console. You can get this by following process.Also, please try 2.3.5
as a receiptValidation in android. The param was sending wrong identity in transactionReceipt
for android. I hope you can have some practice with this one and share your success story in our readme. Cheers!
@raynor85 I am not able to get a response from purchaseHistory() or getAvailablePurchases() either. I'm wondering if those functions just won't work until app is in production. @JJMoon Should those functions work in sandbox mode?
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.
This thread got a bit off track, but I'm seeing the same original error when running the app through xcode on my device with a sandbox account (Error: Cannot connect to iTunes Store
). I'm on 2.3.19, which I believe to be the most recent.
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.buySubscription
request.
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.
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.buySubscription request.
So, what are you supposed to do in this case? How do I know if the product was actually purchased by user?.. I tried restoring purchases, but nothing seems to change
Most helpful comment
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.