Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

Google Play Subscription Upgrade / Downgrade

Discussion in 'Unity IAP' started by eylulatilgan, Apr 25, 2018.

  1. datvt2236

    datvt2236

    Joined:
    Jul 11, 2018
    Posts:
    13
    @JeffDUnity3D this issue appears much time. so please check it
     
  2. datvt2236

    datvt2236

    Joined:
    Jul 11, 2018
    Posts:
    13
    And now i have a problem when update subscription in android:

    When a player subscribed to a pack named Pack 1 (pack 1 month, in testing environment time duration is 5 minutes) which has a duration of 5 minutes. At the 2nd minute, the player upgrades to Pack 2 and in the Google Play, the subscription displays it will renew on the 5th minute. But at the 5th minute, we notice that the subscription renew status has not changed and we do not get an email for order receipt (this email notifies about billing information). However, if the client/server call Google API for billing status, it still shows that the subscription is still active and the order ID is not changed, and the properties "expiryTimeMillis" get increased.

    The player is recognized as a subscriber of pack 2 and can not re-subscribe it. We think that the player is not getting charged for Pack 2, but have no obvious clue to confirm it. There is an abnormal number for the expired time of Pack 2 attached with the player.

    When purchase pack1 we get receipt with order id: GAP.xxxx-xxxx-xxxx-xxxx. after purchase pack1 we upgrade to pack2 have new order id GAP.xxxx-xxxx-xxxx-xxxx.
    expect pack2 will auto-renew at the end of pack 1 with new order id: GAP.xxxx-xxxx-xxxx-xxxx..0 but pack 2 not auto-renew and order still is GAP.xxxx-xxxx-xxxx-xxxx.
    However, if the client/server call Google API to check billing status expiryTimeMilis has update

    Does anyone get the same problem?
     
  3. datvt2236

    datvt2236

    Joined:
    Jul 11, 2018
    Posts:
    13
    @JeffDUnity3D these issues appear much of time. so please check it. thanks
     
  4. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    5,429
    @datvt2236 Are you seeing this in testing only, or in your Released app also?
     
  5. datvt2236

    datvt2236

    Joined:
    Jul 11, 2018
    Posts:
    13
    It appears in testing only, we not release yet
     
  6. datvt2236

    datvt2236

    Joined:
    Jul 11, 2018
    Posts:
    13
    @JeffDUnity3D I have same question with this issue.
    What is default mode in GetExtension<IGooglePlayStoreExtensions>().UpgradeDowngradeSubscription?
    thank you
     
  7. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    5,429
  8. datvt2236

    datvt2236

    Joined:
    Jul 11, 2018
    Posts:
    13
  9. datvt2236

    datvt2236

    Joined:
    Jul 11, 2018
    Posts:
    13
    @JeffDUnity Do you have infor about this issue?
     
  10. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    5,429
    @datvt2236 Are you able to catch the exception in a Try/Catch block? We will check here also.
     
  11. datvt2236

    datvt2236

    Joined:
    Jul 11, 2018
    Posts:
    13
    it exception from unity iap, so i can't use Try/Catch block
     
  12. IvanTesseract

    IvanTesseract

    Joined:
    Jul 1, 2013
    Posts:
    71
    Hi,

    In the last few days I've been having an issue upgrading and downgrading subscriptions on Google Play.
    What I noticed is that when I do the following in the UpgradeDowngrade callback:

    IGooglePlayStoreExtensions extensions = _storeExtensionProvider.GetExtension<IGooglePlayStoreExtensions>();

    the variable extensions is of type UnityEngine.Purchasing.FakeGooglePlayStoreExtensions.

    I'm assuming that this is the problem since it says fake. :D

    Thank you in advance.
     
  13. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    5,429
    Are you running this on a device? The fake store would be expected in the Unity Editor play mode. And can you elaborate, last few days? It was working previously with no changes made since? Do you get an error?
     
  14. IvanTesseract

    IvanTesseract

    Joined:
    Jul 1, 2013
    Posts:
    71
    I am running this on a device, I saw the class using adb logcat (see attached image).
    Last time that I can be certain that it worked is since out last release on Google Play in February.
    I don't get any errors.

    I'm afraid that this might be a bug since Android released their subscription restore feature.
     

    Attached Files:

  15. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    5,429
    So no errors and the user is not seeing any issues and can upgrade and downgrade, so your only concern is the log entry? I suspect I am missing something :)
     
  16. IvanTesseract

    IvanTesseract

    Joined:
    Jul 1, 2013
    Posts:
    71
    Haha, no, I already said I'm having issues upgrading/downgrading the subscription using Unity IAP.

    When I call extensions.UpgradeDowngradeSubscription(oldSKU, newSKU); nothing happens, and I'm supposed to get the Google Play window.

    I mentioned the name of the class because someone might have it as a lead to solve the problem.
     
  17. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    5,429
    So it was working correctly previously, and then your released app started to fail? And you didn't update the code?
     
  18. IvanTesseract

    IvanTesseract

    Joined:
    Jul 1, 2013
    Posts:
    71
    What do you mean I didn't update the code? How am I supposed to update a one method call?

    Not sure how is this important, but we just noticed that the update fails.. Looks like an issue with Unity IAP code itself, because the same code was working perfectly fine before.

    Unity IAP is updated to 1.22.
     
  19. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    5,429
    I am asking you if you updated your app. Or did your app stop working on its own, without changing any code or submitting a new release ("didn't update the code"). This would imply a possible Google server side issue. You mentioned "worked perfectly fine before", before what? The Google update?
     
  20. IvanTesseract

    IvanTesseract

    Joined:
    Jul 1, 2013
    Posts:
    71
    The code that handles Unity IAP was not updated at all. The implementation worked perfectly fine until we tested it a week ago, and the feature where you can update your subscription does not work any more on Android.

    I updated Unity IAP to 1.22 and still the same issue persists. When I debugged the code it works well until I have to excute the following code to initiate the update:

    IGooglePlayStoreExtensions extensions = _storeExtensionProvider.GetExtension<IGooglePlayStoreExtensions>();
    extensions.UpgradeDowngradeSubscription(oldSKU, newSKU);

    Thanks.
     
  21. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    5,429
    @IvanTesseract So you are claiming that it worked at one point, but Google changed something at their end and it stopped working. I will test here also.
     
  22. IvanTesseract

    IvanTesseract

    Joined:
    Jul 1, 2013
    Posts:
    71
    @JeffDUnity3D yes, it worked well at one point. Thank you very much for your quick replies and your patience.
     
  23. OMatthew

    OMatthew

    Joined:
    Mar 4, 2013
    Posts:
    5
    @JeffDUnity3D Hi, I'm pretty confused as to how to use SubscriptionManager.UpdateSubscription...

    I know how to call it based on previously posts in this thread but, even after spending many hours pouring through the IAPDemo example and documentation, I have no idea where/when to call it. Is it instead of InitiatePurchase? Before InitiatePurchase? After InitiatePurchase? In OnPurchaseComplete?

    IAPButton only has Events for OnPurchaseComplete and OnPurchaseFailure... Why not also have an Event for something like OnPurchaseBegin (assuming SubscriptionManager.UpdateSubscription would be called before InitiatePurchase to either fire before the purchase is completed or instead of InitiatePurchase).

    My apologies, I'm so confused by this that I don't really know how to word my questions very precisely...

    Why is there no example of SubscriptionManager.UpdateSubscription usage in the IAPDemo.cs script?

    Speaking of that script, I assumed I could call SubscriptionManager.UpdateSubscription in my own PurchaseButtonClick method similar to how IAPDemo works, but that can't be right because that fires on my on UI button as opposed to the default app store UI buttons. In other words, my own UI buttons shouldn't initialize (and therefore complete) the purchase because the app store buttons do that. (Or am I misunderstanding something?) So I'm really confused as to why the IAPDemo script show a custom PurchaseButtonClick method initialing the purchase...

    Anyway, any help/guidance you could provide on when/where to successfully call SubscriptionManager.UpdateSubscription would be really helpful, thanks!

    (btw, I'm using Unity IAP v1.22.0)
     
    Last edited: May 6, 2019
  24. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    5,429
  25. OMatthew

    OMatthew

    Joined:
    Mar 4, 2013
    Posts:
    5
    @JeffDUnity3D Thanks for the quick reply, but please provide more details if possible (like I mentioned, I've thoroughly looked through this thread and am still confused)...

    So are you saying that I don't use IAPButtons? If not I assume I manually call this in my own ClickPurchaseButton method:

    m_Controller.InitiatePurchase(m_Controller.products.WithID(productID), "developerPayload");

    And if so, when updating a subscription, do I call SubscriptionManager.UpdateSubscription instead of, before, or after that InititiatePurchase method?
     
    Harrishun likes this.
  26. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    5,429
    Already mentioned, you just call it by itself. It has no relation to InitiatePurchase. You call it after IAP initialization. The link I provided has the exact code.
     
  27. OMatthew

    OMatthew

    Joined:
    Mar 4, 2013
    Posts:
    5
    Why is there no example in IAPDemo?
     
  28. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    5,429
    The feature is new. IAPDemo is already def'd bloated.
     
  29. OMatthew

    OMatthew

    Joined:
    Mar 4, 2013
    Posts:
    5
    True.

    OK, I got it all figured out I think. Everything made a lot more sense once I used IAPListener on my purchase button(s) instead of IAPButton (i.e. "IAP Scripting and not Codeless") and called SubscriptionManager.UpdateSubscription instead of m_Controller.InitiatePurchase(m_Controller.products.WithID(productID), "developerPayload"); when updating subscriptions.

    Thanks again!
     
  30. IceNiceV

    IceNiceV

    Joined:
    Apr 11, 2018
    Posts:
    3
    Hi. How can I change the replaceSkusProrationMode to upgrading/downgrading the subscription?
     
  31. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    5,429
    Are you getting an error with SubscriptionManager.UpdateSubscription?
     
  32. IceNiceV

    IceNiceV

    Joined:
    Apr 11, 2018
    Posts:
    3
    Last edited: Jun 13, 2019
  33. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    5,429
  34. IceNiceV

    IceNiceV

    Joined:
    Apr 11, 2018
    Posts:
    3
    Hello, what about my question?
     
  35. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    5,429
    No updates yet. If we decide to address this, any update would come in the next release, no ETA at this time.
     
  36. Egil-Sandfeld

    Egil-Sandfeld

    Joined:
    Oct 8, 2012
    Posts:
    48
    I'm really lost with regards to up/downgrading subscriptions. Testing out on Android, nothing happens after calling
    SubscriptionManager.UpdateSubscription(...) except for it immediately making the callback.

    I want to make it possible for the user to toggle between monthly and annual subscriptions. If the monthly is currently subscribed, the annual presents itself as an option and vice versa. I succesfully test-purchased both monthly and annual subs individually but now fail to toggle between these using the SubscriptionManager.UpdateSubscription method. I have also without success tried various alternatives:
    • SubscriptionManager.UpdateSubscriptionInGooglePlayStore(...
    • m_GooglePlayStoreExtensions.UpgradeDowngradeSubscription(...
    This is my code:

    Code (CSharp):
    1. public void BuyAnnualSubscription()
    2.     {
    3.         if (productSubMonthly.Purchased)
    4.         {
    5.             Debug.Log("Monthly already purchased, so upgrading to Annually");
    6.             SubscriptionManager.UpdateSubscription(m_Controller.products.WithID(kProductNameSubscriptionAnnually), m_Controller.products.WithID(kProductNameSubscriptionMonthly), "accountId", OnSubUpgradedApple, OnSubUpgradedGoogle);
    7. ...
    8. }
    9. }
    Code (CSharp):
    1. private void OnSubUpgradedGoogle(string arg1, string arg2)
    2.     {
    3.         Debug.Log("arg1: " + arg1 + " arg2: " + arg2);
    4.         productSubAnnually.Purchased = true;
    5.         productSubMonthly.Purchased = false;
    6.         m_PurchaseInProgress = false;
    7.         UpdateSubscriptionUI();
    8.     }

    The OnSubUpgradedGoogle is triggered immediately and but nothing happens on screen (should see a Google Play purchase confirmation dialogue I believe). In my log I have:

    Initializing UnityPurchasing via Codeless IAP

    UnityIAP Version: 1.22.0

    Using configuration builder objects


    --- [Pressing Monthly Subscription button]


    No other subscription, so purchasing Monthly

    Purchasing product asychronously: 'x.x.x.sub.monthly'

    purchase({0}): x.x.x.sub.monthly

    Purchase OK: x.x.x.sub.monthly

    Receipt:
    {"Store":"GooglePlay",
    "TransactionID":"GPA.xxxx",
    "Payload":
    "{\"json\":\"{\\\"orderId\\\":\\\"GPA.x\\\",
    \\\"packageName\\\":\\\"x.x.x\\\",
    \\\"productId\\\":\\\"x.x.x.sub.monthly\\\",
    \\\"purchaseTime\\\":1563634760488,
    \\\"purchaseState\\\":0,
    \\\"developerPayload\\\":
    \\\"{\\\\\\\"developerPayload\\\\\\\":\\\\\\\"xxx",
    \\\\\\\"is_free_trial\\\\\\\":false,
    \\\\\\\"has_introductory_price_trial\\\\\\\":false,
    \\\\\\\"is_updated\\\\\\\":false,
    \\\\\\\"accountId\\\\\\\":\\\\\\\"fake account id\\\\\\\"}\\\",
    \\\"purchaseToken\\\":\\\"xxx\\\",
    \\\"autoRenewing\\\":true}\",
    \"signature\":\"xxx",
    \"skuDetails\":\"{\\\"skuDetailsToken\\\":\\\"xxx\\\",
    \\\"productId\\\":\\\"x.x.x.sub.monthly\\\",
    \\\"type\\\":\\\"subs\\\",
    \\\"price\\\":\\\"124,99 kr.\\\",\
    \\"price_amount_micros\\\":124990000,
    \\\"price_currency_code\\\":\\\"DKK\\\",
    \\\"subscriptionPeriod\\\":\\\"P1M\\\",
    \\\"freeTrialPeriod\\\":\\\"P1W\\\",
    \\\"introductoryPriceAmountMicros\\\":39990000,
    \\\"introductoryPricePeriod\\\":\\\"P1M\\\",
    \\\"introductoryPrice\\\":\\\"39,99 kr.\\\",
    \\\"introductoryPriceCycles\\\":48,
    \\\"title\\\":\\\"Monthly Subscription\\\",
    \\\"description\\\":\\\"xxx.\\\"}\",
    \"isPurchaseHistorySupported\":true}"}


    Receipt is valid. Contents:
    x.x.x.sub.monthly
    07/20/2019 14:59:20
    GPA.xxx
    Purchased
    xxx
    ProcessPurchase: PASS. Product: 'x.x.x.sub.monthly'


    --- [Pressing Annual Subscription button]


    Monthly already purchased, so upgrading to Annually

    arg1: {"productId":"x.x.x.sub.monthly",
    "is_free_trial":"False",
    "is_introductory_price_period":false,
    "remaining_time_in_seconds":2678394.305506}

    arg2: x.x.x.sub.yearly

    I'm using
    • Unity 2018.3.11f1
    • Unity IAP 1.22.0
    • Unity IAP Package 2.0.6
    • Android 9.0, Pixel 2 XL rooted
     
  37. skrpeta

    skrpeta

    Joined:
    Nov 9, 2016
    Posts:
    7
    I have the same problem as the IvanTesseract
    One period upgrade method worked normally, but now when I call it google play panel doesnt show up. I see that app is paused and the music stops. Only thing I can do is press back on mobile phone to return to app.

    Cant say I changed something that would stop that method cause buying subcription works normaly. But when I call update subcription it looks like something happens, but nothing shows from google.

    IvanTesseract have you had any luck in solving this problem?

    EDIT:
    This was a tough nut to crack before I solved it. So get this, if you change CurrentCulture on current thread it wont show google upgrade subscription panel. I changed it to my culture because of sorting an array of names which have different symbols then English alphabet. So if you have this problem as I did than change CurrentCulture to default one:
    Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
     
    Last edited: Aug 19, 2019
  38. rtalerico

    rtalerico

    Joined:
    Oct 27, 2016
    Posts:
    7
    This one's driving me crazy... I'm attempting both UpgradeDowngradeSubscription and UpdateSubscription for Google Subscriptions.

    When I call UpdateSubscription I receive the message, "The product has not been purchased, a subscription can only be upgrade/downgrade when has already been purchased". Calling UpgradeDowngradeSubscription leaves me with a frozen app - very similar to skrpeta. Unfortunately his fix did not work for me, which leaves me wondering if there's anything else I can do.

    I'm trying to make sure this works in a test environment before publishing. The app is on a closed track, and I am purchasing with the test billing. I cannot assume this works without verifying.

    Do I have to pass in the product with its receipt when calling UpdateSubscription? If so, that's not going to be possible in every case. I'm only saving the receipt server-side, not the entire product data with it. The receipt field is read-only, so I cannot update a "fake" product including the receipt.

    Not sure what else I can do, but any advice would be appreciated! Documentation is next-to-none, and this thread is the only other lifeline I have come across.

    IvanTesseract JeffDUnity3D any chance for clarification?

    EDIT: It appears to be working all of a sudden.. I changed the developerPayload to an empty string. I can confirm it is now working using the SubscriptionManager.UpdateSubscription(newProduct, oldProduct, "", AppleStoreCallback, googlePlayCallback);.
     
    Last edited: Sep 18, 2019
  39. kevintlight

    kevintlight

    Joined:
    Oct 30, 2018
    Posts:
    1
    here is the update info and i cann't find the method to get the subscriptions upgrade process in the "Added "
    1. Unity IAP 1.20.1 is now available

      1.20.1: Replaces IAP 1.21 as stable release for non-UDP IAP developers. Those requiring UDP support should remain on 1.21.

      Developers currently using Unity IAP 1.21 that do not need support for the Unity Distribution Platform (UDP) Beta on Android should transition to this release.

      Added
      • Added a callback function that allows developers to check the state of the upgrade/downgrade process of subscriptions on GooglePlay.
     
  40. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    5,429
    I am checking, and will follow up here.
     
  41. Harrishun

    Harrishun

    Joined:
    Apr 13, 2016
    Posts:
    1
    So, I also got this issue, but for a far stupider reason. I just had the new product and the old product around the wrong way in UpdateSubscription(). I figured I'd post this here anyway in case someone was searching for potential answers, since this is the ONLY place on Google that this error message appears. I can't guarantee that will be your issue however.