First, I would like to apologise if a similar thread exists, I have gone through a lot of them but I’m still stuck on this issue.
I’ve set up multiple auto renewable subscriptions on appstore connect and made sure that they are in the same subscription group.
When upgrading I’m checking to see if the user already has a subscription and based on that, when the subscription button is clicked (and confirmed) I try to update the subscription using this code:
However, every time I try to upgrade the subscription, on the sandbox it just treats it as a new purchase.
Is there something I’m missing?
I’ve used the sample upgrade sample for Android and got that working, but on iOS I could not find anything similar.
One more question, if on upgrade, I redirect to the app stores subscription page, and the user changes their subscriptions from there, would the older subscription give
subscriptionInfo.isCancelled() == Result.True?
If so that is something I could use to check if a subscription has been shifted or not.
Yup doing that.
But I really feel that it should be mentioned in the documentation that the upgrade functionality does not work on iOS. Right now there are two functions for upgrading subscriptions on iOS and they both don’t work.
So I added a bunch of debug logs for all properties that SubscriptionInfo gives. I subscribed to one subscription in the app and in the iOS’s sandbox subscription page subscribed to a different subscription. When I check the receipts the next time I open the apps I get two valid subscriptions. Even though I’ve made them part of the same subscription group.
Am I doings something wrong or is this an issue with IAP?
Jeff, I really don’t understand this. On the documentation all of these fields are mentioned and no where does it say it does not work for iOS.
Regardless, can you give me some alternatives has to how better to parse the store receipt to get my required fields or is it something that is not to be trusted at all, and that I should not use Unity’s IAP for the whole process…
Also, are the product details received OnInitialized of IStoreListener?
My use case is such that I want to re-fetch all product receipts(/subscriptioninfo) when the app is brought back to the foreground. Would I need to Initialize the IStoreListener again or is there some alternative?
Hey, I’ve run into another issue and I just wanted to ask if I’ve done something wrong, or is it another bug with the IAP package. On iOS is the restore purchases functionality buggy as well? I’ve used this code to restore transactions.
I’m using this for Auto Renewable subscriptions. I’m testing using Sandbox purchases, when I do a fresh install and it doesnt detect the subscription, I added this restore button to explicitly get the subscription.
private void OnRestoreTransactionsClicked()
{
#if UNITY_IOS
appleStoreExtensions.RestoreTransactions(OnRestore);
#endif
}
void OnRestore(bool success)
{
var restoreMessage = "";
if (success)
{
// This does not mean anything was restored,
// merely that the restoration process succeeded.
restoreMessage = "Restore Successful";
}
else
{
// Restoration failed.
restoreMessage = "Restore Failed";
}
Debug.Log(restoreMessage);
}
What my assumption here is that on restoration success, it will call the process purchase of the IStoreListener. But that’s not the result that I’m getting. It simply does nothing when I try to restore purchase.
IStoreListener? Are you using Codeless IAP? It sounds like you may be mixing Codeless and Scripted IAP. If you are using Codeless, you’ll just want to use the IAP Restore Button (not in code, like you have). If you are using Scripted IAP, please show your ProcessPurchase code.
I’m not using Codeless IAP. By IStoreListener I meant my implementation of the IStoreListener class.
This is what I have in my process purchase:
public PurchaseProcessingResult ProcessPurchase(PurchaseEventArgs args)
{
// Retrieve the purchased product
var product = args.purchasedProduct;
Debug.Log($"Purchase Complete - Product: {product.definition.id}");
switch (product.definition.id)
{
case GameConstants.InAppSubscriptionIds.BasicMonthlySubscriptionProductId:
Debug.Log("Basic Monthly Subscribed");
break;
case GameConstants.InAppSubscriptionIds.BasicYearlySubscriptionProductId:
Debug.Log("Basic Yearly Subscribed");
break;
case GameConstants.InAppSubscriptionIds.ProMonthlySubscriptionProductId:
Debug.Log("Pro Monthly Subscribed");
break;
case GameConstants.InAppSubscriptionIds.ProYearlySubscriptionProductId:
Debug.Log("Pro Yearly Subscribed");
break;
}
SetPriceValues();
RetrieveAllAndStoreAllSubscriptionInfo();
string highestIndividualSubscriptionSubscribedTo = GetHighestIndividualSubscriptionSubscribedToEvenIfCancelled();
GameSubscriptionManager.Instance.HighestIndividualSubscriptionSubscribedTo = highestIndividualSubscriptionSubscribedTo;
UiEventsManager.Instance.OnIndividualSubscriptionPaidSuccessfully?.Invoke(highestIndividualSubscriptionSubscribedTo);
isGetStoreDetailsComplete = true;
LoaderDisplayManager.Instance.TurnOffAllLoaders();
// We return Complete, informing IAP that the processing on our side is done and the transaction can be closed.
return PurchaseProcessingResult.Complete;
}
Please share your Debug.Log output. And could you try the same code here:
This should help getting the logs in XCode How To - Capturing Device Logs on iOS Also note that subscriptions in Sandbox expire in 5 minutes, and one user can only subscribe 6 times. So you need to be fast in your testing, and either use multiple products for testing, or multiple testers.