No receipt found for subscription got with an Apple promo code

My app uses subscriptions and recently we are trying to offer free promos. In the manage subscription settings of my iPhone, it does show that my test promo of 3 days was accepted. When I look through the products in the store controller through xCode, none of them have receipts so I don’t find any subscriptions. Where can I find if the user has a free promo subscription? Here is my code for checking for subscriptions:

public void CheckPurchases()
{
MyDebug("Checking for purchases");

if (!IsInitialized())
{
MyDebug("Not initialized");
return;
}

Dictionary<string, string> dict = m_AppleExtensions.GetIntroductoryPriceDictionary();
bool foundItem = false;
bool foundMonthly = false;
bool foundAnnual = false;
foreach (UnityEngine.Purchasing.Product item in m_StoreController.products.all)
{
MyDebug("Found an item in intialization");

if (item.receipt != null)
{
string intro_json = (dict == null || !dict.ContainsKey(item.definition.storeSpecificId)) ? null : dict[item.definition.storeSpecificId];
MyDebug("Item type: " + item.definition.type);
if (item.definition.type == ProductType.Subscription)
{
SubscriptionManager p = new SubscriptionManager(item, intro_json);
SubscriptionInfo info = p.getSubscriptionInfo();
MyDebug("Info subbed: " + info.isSubscribed());
if(info.isSubscribed() == Result.True)
{
foundItem = true;
if(info.getProductId().ToString() == MONTHLY_SUB_ANDROID || info.getProductId().ToString() == MONTHLY_SUB_APPLE)
{
foundMonthly = true;
} else if (info.getProductId().ToString() == ANNUAL_SUB_ANDROID || info.getProductId().ToString() == ANNUAL_SUB_APPLE)
{
foundAnnual = true;
}
}

MyDebug("SubInfo: " + info.getProductId().ToString());
MyDebug("isSubscribed: " + info.isSubscribed().ToString());
MyDebug("isFreeTrial: " + info.isFreeTrial().ToString());
MyDebug("timeLeft: " + info.getRemainingTime().ToString());
}
} else {
MyDebug("Item receipt is null");
}
}
if (foundItem)
{

StateManager.instance.PlayerData.ownGame = true;
StateManager.instance.gameLocked = false;
if(foundMonthly)
{
StateManager.instance.PlayerData.monthly = true;
MyDebug("Found a monthly");
} else if (foundAnnual) {
StateManager.instance.PlayerData.monthly = false;
MyDebug("Found an annual");
} else {
MyDebug("Didn't find monthly or annual");
}
} else {
StateManager.instance.PlayerData.ownGame = false;
StateManager.instance.gameLocked = true;
MyDebug("Found no subscriptions");
}
}

I believe the problem was that the app needed to be downloaded from the App Store for the promo to work, and not just Test Flight which is annoying and almost impossible to debug, but that’s how it is.

1 Like