Search Unity

Codeless IAP and subscriptions

Discussion in 'Unity IAP' started by aholla, Dec 13, 2020.

  1. aholla

    aholla

    Joined:
    May 27, 2014
    Posts:
    81
    I am using the codeless IAP for a simple app.

    It has a subscription purchase.

    This works and I am very happy with it.

    My question is how does it handle subscriptions that have either expired or cancelled?

    Thanks
     
  2. Mauri

    Mauri

    Joined:
    Dec 9, 2010
    Posts:
    2,665
  3. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Codeless support for subscriptions is limited, there currently isn't a way to get this information. You would need to use scripted IAP
     
  4. aholla

    aholla

    Joined:
    May 27, 2014
    Posts:
    81
    Thanks for the reply, ive used the scripted IAP in the past but would prefer to use the codeless iap if possible.

    So what would happen in the following situations:

    • If they have subscribed and cancelled during a trial, i would expect it to return FALSE.

    • If they have subscribed but cancelled, id expect it to return TRUE until the expiration date and then return FALSE.


    Also on a side not, is the SubscriptionManager partially populated via the codeless iap?
     
  5. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    What are you expecting to be TRUE or FALSE? To use SubscriptionManager, you would need to use Scripted IAP.
     
  6. aholla

    aholla

    Joined:
    May 27, 2014
    Posts:
    81
    Sorry not true or false, but the IAP Listener would call the On Purchase Complete method if the subscription is valid and not call it if it is not valid.

    So if the user subscribes and later cancels, does the IAPListener continue to OnPurchaseComplete until the expiration date?

    If the the user subscribes and cancels during the trial, does the IAPListener still call the OnPurchaseComplete? I would expect it not to.
     
  7. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    The IAP Listener only triggers on the initial purchase and subsequent Restore operations. But not on each game start.
     
  8. aholla

    aholla

    Joined:
    May 27, 2014
    Posts:
    81
    thanks @JeffDUnity3D .

    I know you always recommend the coded api but do you know if there are any plans to improve the CodlessIAP system. It seems to do almost everything that is needed apart from validation.

    Thanks.
     
  9. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Yes, I brought this very topic up with the engineering team today! It will take some time though, perhaps even a few months as we might want to make overall improvements.
     
  10. John_Corbett

    John_Corbett

    Joined:
    May 17, 2019
    Posts:
    151
    Hi @aholla.

    We have a sort of workaround within our test project, where we use Codeless IAP, but you'll need to add some code yourself into another class.

    You can check for a valid receipt for a given subscription

    First, you can get the list of products from Codeless IAP:
    Code (CSharp):
    1. var products = CodelessIAPStoreListener.Instance?.StoreController?.products;
    Then get your product:
    Code (CSharp):
    1. var product = products.WithID(productId);
    Then use the SubscriptionManager to check its status
    Code (CSharp):
    1. var subscriptionManager = new SubscriptionManager(product, null);
    2. var isSubscribed = subscriptionManager.getSubscriptionInfo()?.isSubscribed();
    You can then do what you want with isSubscribed.
     
    Last edited: Dec 15, 2020
    Zhelatin and aholla like this.
  11. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Be sure to track your changes if you update the codeless files as suggested or they will be overwritten during an upgrade. Source control is best for this.
     
  12. John_Corbett

    John_Corbett

    Joined:
    May 17, 2019
    Posts:
    151
    Hmmm... great point Jeff,

    I will need to look into a workaround for pending purchases and receipt validation without modifying our API directly. There may be a solution, but maybe not.
     
  13. Maisey

    Maisey

    Joined:
    Feb 17, 2014
    Posts:
    302
    "Be sure to track your changes if you update the codeless files as suggested or they will be overwritten during an upgrade. Source control is best for this." - or you can actually make the methods virtual and protected (in IAPButton, IAPListener etc.) so we can add implementation properly (by inheriting and thus not overwrite). I thought I could save some time by using Codeless IAP but I regret deeply that I added this to our project.
     
  14. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Understood, we have some work to do on Codeless, we were suggesting sub-optimum work-arounds.
     
    Maisey likes this.
  15. MousePods

    MousePods

    Joined:
    Jul 19, 2012
    Posts:
    811
    I am also interested in using the codeless api. Would these improvements consist of:

    1. Implementation into UIToolkit.
    2. Receipt validation on startup so I can check if the IAP item was purchsed?
    Thanks!
     
  16. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    No specific integration into UIToolKit. And yes, we are looking into receipt validation for Codeless as a high priority improvement, but likely not until early next year.
     
    MousePods likes this.
  17. aholla

    aholla

    Joined:
    May 27, 2014
    Posts:
    81
    @JeffDUnity3D Thanks for looking into that and thanks @John_Corbett for your suggestion, this was actually something I was thinking about doing, I was just a little scared of the "dont mix the codeless with the coded api" posts :)

    Thanks for all of your work on this, its really great and I will look forward to hearing about future developments.
     
  18. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    To be clear, the other posts about not "mixing" was due to incorrect coding. People were placing a ProcessPurchase callback as their "successful purchase" method in Codeless which is incorrect. The documentation correctly uses a method you write would yourself like "GrantCredits"
     
    aholla likes this.
  19. aholla

    aholla

    Joined:
    May 27, 2014
    Posts:
    81
    So just one more question...

    I remember from my logs that my app retrieves the purchase history when it loads. My question is, is this invoked via the IAPListener or doesn't just happen.

    What I'm wondering, is if I can use the IAPListener to retrieve the products the user has purchased when the open the app. OR does this only get called when the products are initially purchased?

    Perhaps this is not necessary...

    I would like to do something like @John_Corbett suggested when the app has loaded, I could then check the subscription state and enable the relevant content in the app.

    ALSO, is there a way to know that the codelessIAPListerner singleton has received data so I can check the status?


    Thanks.
     
    Last edited: Dec 20, 2020
  20. John_Corbett

    John_Corbett

    Joined:
    May 17, 2019
    Posts:
    151

    Sadly the CodelessIAPListener isn't that robust. You'd need to modify it.
     
  21. zak666

    zak666

    Joined:
    Mar 3, 2014
    Posts:
    40
    Any update on this Cant find anything. no tutorials on how to do subscriptions, Nothing on the internet on how to valadate and see if subscriptions are active. (using Codeless for subscriptions) its now 2022...
    Purchases work but nothing In any tutorials online on how to chekc subsriptions, in fact, THEIR ARE NO SUBCRIPTION TUTORIALS on the internet I look every month.

    the only thing you can do Is have a single pursuance and a in-game timer and save the timestamp and when it hits +20 days reset premium to 0, then make them make a single purchase again, (Manually rather then having it automatic) why even have subscriptions on their if you can't even use it?

    just be nice if users could buy it and set it and forget it rather then every month the game says "Your subscription has expired" and have a buy again button in the game. that's the only work around I could find.

    (And yes, we are looking into receipt validation for Codeless as a high priority improvement, but likely not until early next year. ITS 2022. AND NO TUTORIALS ON SUBSCRIPTIONS, ITS ALL SINGLE PURCHASES WITH CODLESS WHY HAVE THE OPTION FOR SUBSCRIPOTIONS IF THEIRS NO WAY TO CHECK IT WITH CODELESS?)


    Devs posting random lines of code saying "Heres a fix" without a complete script to show you how it works.

    Like It works to buy the subscriptions, but if it dosn't Automaticly check for you whats the point its not really codless? you cna just buy a subcription, then cancel it and always have the subscribed content, , Thats called a feature that dosn't work.
     
    nathanlin likes this.
  22. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446