InvalidProductTypeException on iOS when using StoreKit testing in Xcode

Our game has a subscription that has worked fine in production and TestFlight. We are looking at enabling billing grace period, and Apple recommends testing it out first in development. I updated to Unity IAP 4.11.0, generated the AppleStoreKitTestTangle file, and made a build that uses that for testing. It works fine for non-consumable products, but when I call SubscriptionManager.getSubscriptionInfo() with the subscription product, I get an InvalidProductTypeException. I have checked and confirmed the product’s type is Subscription.

InvalidProductTypeException: Exception of type 'UnityEngine.Purchasing.InvalidProductTypeException' was thrown.
  at UnityEngine.Purchasing.SubscriptionInfo..ctor (UnityEngine.Purchasing.Security.AppleInAppPurchaseReceipt r, System.String intro_json) [0x00000] in <00000000000000000000000000000000>:0
  at UnityEngine.Purchasing.SubscriptionManager.getAppleAppStoreSubInfo (System.String payload, System.String productId) [0x00000] in <00000000000000000000000000000000>:0
  at UnityEngine.Purchasing.SubscriptionManager.getSubscriptionInfo () [0x00000] in <00000000000000000000000000000000>:0

This is on Unity 2022.3.18f1, Unity IAP 4.11.0, on an iPad with iOS 17.4.1. The problem does not occur in TestFlight or production using the regular AppleTangle.

Reviving this thread - did you manage to find a pathway here? I am experiencing the same problem in 2022.3.47 + IAP 4.12.2. Testing using StoreKit debug store on the vision os simulator (1.2).

I duplicated some code from SubscriptionManager to see what was actually happening, and Unity reports the subscriptions from StoreKit as type 0 (NonConsumable). However, the receipt itself (if you copy how SubscriptionManager parses the receipt info) will tell you the expiration date and you can compare against DateTime.Now.

So, possibly it’s a bug in how StoreKit communicates to Unity - but there IS a workaround as you can catch the exception and perform receipt processing yourself when running through xcode storekit tangle file.

It wasn’t worth spending more time on it, so I didn’t go further. Good to know there’s a workaround!