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

Cannot connect to iTunes Store for sandbox users #277

Closed
raynor85 opened this issue Oct 2, 2018 · 17 comments
Closed

Cannot connect to iTunes Store for sandbox users #277

raynor85 opened this issue Oct 2, 2018 · 17 comments
Labels
🙏 help wanted Extra attention is needed 📱 iOS Related to iOS

Comments

@raynor85
Copy link
Contributor

raynor85 commented Oct 2, 2018

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

@raynor85
Copy link
Contributor Author

raynor85 commented Oct 3, 2018

I think it is an old link. https://developer.apple.com/system-status/

@hyochan hyochan added 🙏 help wanted Extra attention is needed 📱 iOS Related to iOS labels Oct 4, 2018
@hyochan
Copy link
Member

hyochan commented Oct 4, 2018

@raynor85 Are you still facing this issue?

@raynor85
Copy link
Contributor Author

raynor85 commented Oct 4, 2018

@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?

@raynor85
Copy link
Contributor Author

raynor85 commented Oct 8, 2018

@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?

@JJMoon
Copy link
Contributor

JJMoon commented Oct 9, 2018

@raynor85 Did you connect the transaction result to your server ?

@raynor85
Copy link
Contributor Author

raynor85 commented Oct 9, 2018

@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).

@hyochan
Copy link
Member

hyochan commented Oct 9, 2018

@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!

@raynor85
Copy link
Contributor Author

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?

@raynor85
Copy link
Contributor Author

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

@hyochan
Copy link
Member

hyochan commented Oct 10, 2018

@raynor85

  1. You can check validating receipt in ios which explains that the password is "Only used for receipts that contain auto-renewable subscriptions. Your app’s shared secret (a hexadecimal string).".
  2. I haven't tried this actually. I've developed this feature for other developers to contribute easily who are aware of these things. However, I think you can get the accessToken via play console. You can get this by following process.
    Select your app > Services & APIs > "YOUR LICENSE KEY FOR THIS APPLICATION Base64-encoded RSA public key to include in your binary". reference.

@hyochan
Copy link
Member

hyochan commented Oct 10, 2018

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!

hyochan added a commit that referenced this issue Oct 10, 2018
Get originalJson in Android as a transanctionReceipt for validation #277.
@mattsidjohn
Copy link

@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?

@mattsidjohn
Copy link

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.

@hyochan hyochan closed this as completed Oct 24, 2018
@JulianKingman
Copy link

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.

@JulianKingman
Copy link

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.

@ilyausorov
Copy link

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.

@DataGreed
Copy link

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

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

No branches or pull requests

7 participants