SwiftyStoreKit: `retrieveProductsInfo` returns valid or invalid product randomly in sandbox

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!

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 27 (13 by maintainers)

Most upvoted comments

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

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.

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.

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.