Need help/advice for handling IAP subscription

Hello
I’m creating an app for android and ios platform and I’m not sure how to handle properly IAP subscription.

My application have 2 kind of subscription, the first remove limitation for creating object (limited to 1 object not subscribed, and limitless when subscribed) and the second one change how much an item count is set ( for example Gold item is reset to 100 every month)

For The first kind of subscription(monthly auto renew), all I do is when user want to create an item, I’m checking if user has subscribed or not using following code

if (TargetProduct.receipt == null){return false;}
var subscriptionManager = new SubscriptionManager(TargetProduct, null);
var info = subscriptionManager.getSubscriptionInfo();
return info.isSubscribed() == Result.True;

if return is true, I allow the user to create object otherwise allow user to create only 1 object.
Is this test enough or should I also check isExpired/isCancel for example?

For the second subscription(monthly auto renew), let’s say that I have a Gold property. the only way for user to have gold is to subscribe and every time the subscription is renew (so every month) Gold is reset to some value.
Concerning this type of subscription I’m not sure how to properly handle it.
When the product is bought, I can set the Gold property to some value, but how can I handle auto renew and restore?
As for checking if user subscribed or not does the handling like the first type of subscription enough?

I really thank you in advance for your help
Best regards

After some research, it seems that ProcessPurchase callback is also called everytime a renew is triggered and trial end, is it correct? (I’m not using IAPButton)
If this is the case then handling reset property value can be handled when this callback is triggered.

Hi there!

I would invite you to look at the samples to handle subscriptions.
You can find the samples in WINDOW>PACKAGEMANAGER

There are a few samples involving subscriptions and how to call them.

You will call process purchase when a user first subscribes then poll the IAP SDK to find out which subscriptions are available and what you are subscribed to on subsequent launches. You can find more here:

Once the user has passed verification you can give extra gold if isAutoRenewing() is also true.

Hope this gets you on the right path.

Hello
Thank you for your reply.
I’ve download all sample in a test project before implementing IAP in my project.
I don’t understand some sample but for the subscsription one, it only show how to purchase (same as consumable) and check if is subscribe using Restore function is isSubscribed() from SubscriptionInfo.

Because I didn’t found information in the documentation, I’ve check with ChatGPT(only use it when I’m stuck)
Because I’m not using IAPButton, apparently ProcessPurchase callback should also be called for auto renewal subscription. However yesturday during my test on android sandbox, I did received the mail from Google every 5 minutes for auto renewal but ProcessPurchase callback was not called. I saw in a old unity thread (around 2021) that this callback was not triggered in android sandbox, is it still the case? My version of In App Purchasing is 4.12.2

I also wanted to try my application on IOS however when I try to buy any product I have a dialog saying that my account has not authority to buy a product and the purchase failed. (app installed from xcode)
On Android, in sandbox, google provide a test card but Apple doesn’t provide such test card.
Is there a way to test IAP in sanbox without any card registered?

I really thank you in advance for your help.