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

retrieveProductsInfo returns valid or invalid product randomly in sandbox #154

Closed
3 of 9 tasks
tbaranes opened this issue Mar 2, 2017 · 27 comments
Closed
3 of 9 tasks

Comments

@tbaranes
Copy link

tbaranes commented Mar 2, 2017

Platform

  • iOS
  • macOS
  • tvOS

In app purchase type

  • Consumable
  • Non-consumable
  • Auto-Renewable Subscription
  • Non-Renewing Subscription

Environment

  • Sandbox
  • Production

Version

0.8.2

Related issues

N/A

Report

Issue summary

Not sure if that's a real bug or just due to the sandbox environment: when fetching products from StoreKit using SwiftyStoreKit.retrieveProductsInfo, I'm randomly getting a valid or invalid product. Is that expected?

SwiftyStoreKit.retrieveProductsInfo(productsIdentifier) { result in
  print(result)
}

which is called directly in didFinishLaunchingWithOptions

What did you expect to happen

Always getting a valid product.

What happened instead

Valid or invalid.. depending of a mysterious mind!

@shuhrat10
Copy link

I'm also getting invalidProductIDs all the time.

@shuhrat10
Copy link

@bizz84 I'm having Auto-Renewable Subscriptions. I think this issue need to be fix as soon as possible as many users trying to fetch all available subscriptions from iTunesConnect and then display subscription details (Subscription Name and Price)

@bizz84
Copy link
Owner

bizz84 commented Mar 9, 2017

@shuhrat10 @tbaranes do you know which was the latest version where this was working for you?

I've been testing with the demo app and this works consistently with my sandbox user.

@bizz84
Copy link
Owner

bizz84 commented Mar 9, 2017

Also maybe this info is relevant:
http://troybrant.net/blog/2010/01/invalid-product-ids/

@shuhrat10
Copy link

@bizz84 it's working fine on iOS but it's not working on tvOS.

I'm using SwiftyStoreKit (0.8.2) tvOS 10.1.

@tbaranes
Copy link
Author

tbaranes commented Mar 10, 2017

It never worked fine (since it's working randomly) for me, but it's my first project using that SwiftyStoreKit, so hard to say... I will give a try to your link and keep you updated.

@bizz84
Copy link
Owner

bizz84 commented Mar 10, 2017

@tbaranes It's possible that only my sandbox users will work with the demo app. You could try to substitute your own product identifiers and see if it works with your sandbox users.

@bizz84
Copy link
Owner

bizz84 commented Mar 10, 2017

One of my apps is using SwiftyStoreKit v0.6.1 in production and I have verified that all product IDs are valid with that version as the purchase succeeds.

I'm going to update my app to the latest version 0.8.3 and submit to the App Store.

The only change concerning retrieving products info from v0.6.1 to v0.8.3 is that the SKProductsRequest request is now made on the calling thread (main), rather than on the background queue (DispatchQueue.global(qos: .default).async). I don't believe this should make any difference.

@tbaranes
Copy link
Author

tbaranes commented Mar 10, 2017

I don't think their an issue in the library itself, it looks like a bug from IAP itself since the fetchProduct is just a wrapper of StoreKit. That's a good idea to try it with your sample app and my own credentials, I will do it next week and keep you in touch!

@antonijap
Copy link

Weird thing happened. I commented out alert with "Invalid product ID", just included print and now it works. I tried with external tester and they were able to go through in-app purchase.

@munibrahman
Copy link

munibrahman commented Mar 11, 2017

If this is actually a bug, please fill out an apple bug report for this. I have already done so and am waiting for a reply.

Im getting invalid id all the time in iOS btw.

@bizz84
Copy link
Owner

bizz84 commented Mar 13, 2017

@returnzer0 I'm planning to write a small sample app including only the code in SwiftyStoreKit to retrieve products, test it and submit it to Apple with a radar.

@gerasimospy
Copy link

I am also having the same issue with AutoRenewSubscriptions in TVOS. I get Invalid Product ID Error when requesting list and the same when trying to purchase.

@tbaranes
Copy link
Author

tbaranes commented Mar 15, 2017

While trying to fetch product information using my bundle id in your sample app, I find a small difference: you fetched the products after a user action, whereas I'm fetching them in didFinishLaunchingWithOptions. So, since I can't reproduce the issue in the sample, I move my fetch in the viewDidAppear of the first UIViewController.

Up to now, I didn't reproduce it, but I will let you know if that issue appear again.

@bizz84
Copy link
Owner

bizz84 commented Mar 16, 2017

Has anyone ever got this working on tvOS?

I have added a tvOS demo app to SwiftyStoreKit here: https://github.com/bizz84/SwiftyStoreKit/tree/feature/tvOS-demo-app

I have configured a test app on my iTunes Connect account with iOS and tvOS versions sharing the same IAPs.

These match the bundle ID and IAP ids in the SwiftyStoreKit demo apps, however I can see that this works consistently on iOS with my sandbox users, but always fails on tvOS.

@gerasimospy Can anyone test this branch with their own bundle ID and IAPs with the demo app and let me know if you have some luck?

Steps

  1. Update Bundle ID with your own app bundle ID:

projectsetting

  1. Update product identifiers with your own:
enum RegisteredPurchase: String {

    case purchase1
    case purchase2
    case nonConsumablePurchase
    case consumablePurchase
    case autoRenewablePurchase
    case nonRenewingPurchase
}

class ViewController: UIViewController {

    let appBundleId = "com.musevisions.iOS.SwiftyStoreKit" // REPLACE THIS

    let purchase1Suffix = RegisteredPurchase.purchase1
    let purchase2Suffix = RegisteredPurchase.autoRenewablePurchase
    ...
}

@shuhrat10
Copy link

shuhrat10 commented Mar 16, 2017

@bizz84 I have my own project which is setup exactly the same way and I have the same problem. on iOS everything is working fine.

@bizz84
Copy link
Owner

bizz84 commented Mar 16, 2017

The demo app now runs identical code for iOS and tvOS, but one works and the other one doesn't.

It could be a configuration issue, but I have registered exactly the same IAPs in iTunes Connect.

Next step: file a radar or contact Apple about this.

@gerasimospy
Copy link

Tested this and still no luck :(

@bizz84
Copy link
Owner

bizz84 commented Mar 18, 2017

I filed a Technical Support Incident to Apple with a demo app showing the problem:
https://github.com/bizz84/SwiftyStoreDemo

Hopefully they'll shed some light.

@bizz84
Copy link
Owner

bizz84 commented Mar 21, 2017

I received a detailed response from Apple Support. Sharing here as I feel it may help.
I'll try to follow up with the suggested steps.


Hello Andrea,

In response to your finding, you are correct that the problem is likely not a problem with your code. It is more likely, an issue with the iTunes Store Server. When this issue occurs, my recommendation is that a bug report be submitted for the Apps Ops Engineering QA group to investigate. The Apps Ops Engineering team processes all such bug report - to replicate the issue, then forwards the validated bug reports to the iTunes Store Server engineers to be investigated and resolved.

When this issue is experienced by the developers who implement your framework, my first recommendation is that the developer review Tech Note 2413, iAP FAQ - https://developer.apple.com/library/content/technotes/tn2413/_index.html#//apple_ref/doc/uid/DTS40016228-CH1-TROUBLESHOOTING-WHY_ARE_MY_PRODUCT_IDENTIFIERS_BEING_RETURNED_IN_THE_INVALIDPRODUCTIDENTIFIERS_ARRAY_
The Technical Note lists all of the known reasons for the SKProductsRequest call to not validate an iAP identifier - assuming that these issue are not the cause of the problem, then the iTunes Store Server is the issue. You might wonder why things work one day and not the next. The iTunes Store Server engineers have not provided an answer to this question.

The standard response which I provide to developers follows - In your case, you can skip the Tech Note and move to the bug report submission. Please send me the bug report so that I can review the console log file which you will submit - to use to get some info to replicate the problem using the curl command-line tool.

You’ve reported that the In-App Purchase identifiers are failing the validation process when called using the SKProductsRequest method. There are 2 cases where this problem occurs.

  1. In the production environment, please verify that your products have the “Cleared for Sale” property set to YES in iTunesConnect to ensure that they are available for sale from your app. If the problem persists, a second reason for this problem is that when the app is first approved, the application may be activated before the In-App Purchase identifiers are activated. Please give the system 48 hours for the identifiers to be activated. You can proactively submit a bug report so that the issue can be investigated in case the problem is not resolved. See the section - Submitting a Bug Report to iTunes Production Support QA - below.

  2. In the sandbox environment, there are a number of reasons for this failure. The known reasons are documented in Tech Note 2413 “In-App Purchase FAQ Troubleshooting Question - “Why are my product identifiers being returned in the invalidProductIdentifiers array?”
    https://developer.apple.com/library/ios/technotes/tn2413/_index.html#//apple_ref/doc/uid/DTS40016228-CH1-TROUBLESHOOTING-WHY_ARE_MY_PRODUCT_IDENTIFIERS_BEING_RETURNED_IN_THE_INVALIDPRODUCTIDENTIFIERS_ARRAY_
    In the case where the In-App Purchase identifiers work one day, then fail to validate the next day, this is a bug report issue for iTunes Production Support QA to investigate.

  3. If you have recently renewed your developer membership, please check that you have also renewed the “Paid Applications” contract in the “Agreements, Tax, and Banking” section of your iTunesConnect account. Note that the agreement must also be completed by Apple. If there is no “Paid Application Contract” in effect, the call to SKProductsRequest to validate the In-App Purchase identifiers, will fail.

If none of the above issues apply, then this is a bug report issue to be investigated by iTunes Production Support. DTS does not investigate these issues.

Submitting a Bug Report to iTunes Production Support QA

There are 2 parts to submitting a bug report in the case that the In-App Purchase identifiers fail to validate. The first thing is to collect the evidence on the form of a console log. To capture the console log, you will need to install the StoreKit profile first, so that the commands issued by iOS for the StoreKit API’s can be captured.

THE FOLLOWING SECTION IS NEW
INSTALL THE StoreKit PROFILE
Please login to the Apple Developer Bug Report - Profiles and Logs website - using the device you will use to replicate the problem.
https://developer.apple.com/bug-reporting/profiles-and-logs/
Click the “Profile” URL associated with the “App Store/iTunes Store for iOS” item. Please follow the instructions to install the profile to your device.
IMPORTANT - PLEASE RESTART THE DEVICE

THE FOLLOWING SECTION IS NOW OMITTED
DOWNLOAD THE StoreKit PROFILE
Please login to the Apple Developer Bug Report - Profiles and Logs website
https://developer.apple.com/bug-reporting/profiles-and-logs/
Click the “Profile” URL associated with the “App Store/iTunes Store for iOS” item. You will download the “itmsdebugging.mobileconfig” file.

INSTALL THE PROFILE
To install the profile to your iOS device, with the Apple Configurator 2 tool follow these instructions.
Install the Apple Configurator 2 application available from the Mac App Store
https://itunes.apple.com/us/app/apple-configurator-2/id1037126344?mt=12

  1. Launch Apple Configurator 2, then attach your device to the system.
  2. Control click your device in the Apple Configurator 2 window and select the Add -> Profiles… contextual menu item.
  3. In the file selection menu, navigate to the itmsdebugging.mobileconfig profile and select it to install.
  4. Follow the Apple Configurator 2 instructions to install the profile to the device.
  5. Restart the device to activate the profile.
    IMPORTANT - PLEASE RESTART THE DEVICE

You can also install the profile via email. To do so, follow these instructions.

  1. Attach the profile to an email that you send and then view on your test device.
  2. Open the email and tap on the profile attachment icon.
  3. On the next page, tap Install at the upper right of the screen
  4. Enter a passcode, if asked to do so.
  5. Tap Install again in the upper right corner of the screen and tap install again when prompted and tap Done.
  6. Restart the device to activate the profile.
    IMPORTANT - PLEASE RESTART THE DEVICE
    END CHANGES

CAPTURE THE DEVICE CONSOLE LOG
To capture the device console log with the macOS Sierra 10.12 Console app.

  1. On a macOS Sierra 10.12 system, launch the Console application and attach the device to the system.
  2. Select the device in the Log List on the left side of the Console application window.
  3. Before starting the app, click “Clear”.
  4. Start the application and perform the steps to replicate the problem.
  5. Save the contents of the console window

To capture a log with Xcode,

  1. launch Xcode and open the Devices window
  2. attach your device and select it in the devices window
  3. Select your device; if the console log is not displayed by default, click the triangle-in-a-box button [^] located at the bottom of the Device Information section of the window to toggle the console log section open ( [v] when the console log section is open).
    4 Launch the application and replicate the issue. As soon as the in app purchase failure occurs in the app, save the contents of the console.
    END INSTRUCTIONS

To make sure that the console log has the correct information, please peruse the log file and search for the string “fetchSoftwareAddOns”. If this string is present, then proceed to filing the bug report. If the string is not present, the profile was not installed or the SKProductsRequest was not issued by the app.

To submit a bug report for investigation by iTunesConnect, please use the Apple Developer Bug Report web page - https://developer.apple.com/bug-reporting/.

After logging in, click the New button to author a new bug report, making sure to select the “iTunes Connect” Product from the product picker.
Set the title of the bug report to “SKProductsRequest fails to validate iAP identifiers for app ID “XXXXXXXXXX” ( where XXXXXXXXXX is the app ID of your application”
Please include the saved console log file with the bug report.

By following these instructions, the Bug Report team will be able to expedite the assignment of the bug report to the iTunes Production Support QA team.

@tbaranes
Copy link
Author

Personally, I don't reproduce that issue anymore, I'm letting it open since there a few more comments, but don't hesitate to close it whenever you think it's ok for you 👍

@shuhrat10
Copy link

shuhrat10 commented Apr 13, 2017 via email

@shuhrat10
Copy link

@bizz84 So, I did testing and I noticed I'm getting invalidProductIDs only in tvOS Simulator but if you run this code on real device via USB-cable it's working fine.

@DavidQL
Copy link

DavidQL commented Feb 14, 2018

My scenario: non-consumable IAP, everything works in development and sandbox mode. When my app got approved I downloaded from the production app store. Now I am getting .paymentInvalid "The purchase identifier was invalid" errors.

My solution: In iTunes Connect, go to your IAP page and uncheck "Cleared for Sale." Save. Re-check "Cleared for Sale." Save. Delete production app from your phone and re-download from App Store. Now it works.

@aivars
Copy link

aivars commented Feb 23, 2018

The same problem. in-app purchase works stable in the sandbox but I have "The purchase identifier was invalid" error in production.
Hope that my case will be from Apple note above "Please give the system 48 hours for the identifiers to be activated."
Disable/Enable "Cleared for Sale." status does not help in my case.

Update: Tested application 7 hours later, in-app purchases works without changes from my side.

@tbaranes tbaranes closed this as completed Mar 1, 2018
@DADOFKILL123
Copy link

Hello, I was in the same situation as you guys, the solution for me was simple : The productID is not "BundleID.iAPProductID" but is simply "ProductID". Assuming that you have the correct app-secret , bundler identifier and iAP correctly configured in both developer portal and xcode , you should be able to test in sandbox environment before submitting to the appStore

@kennylugo
Copy link

kennylugo commented Jul 5, 2019

This is what worked for me:

I was confusing the reference name ( left side ) with the Product ID ( right side )

So make sure that you're using iTunes Connect's Product ID in your code.

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

10 participants