Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Resolved Unity IAP transactions got all refunded in Google Play Store

Discussion in 'Unity IAP' started by kloseliebej, Apr 15, 2023.

  1. kloseliebej

    kloseliebej

    Joined:
    Nov 13, 2020
    Posts:
    3
    I have recently released a Unity mobile game developed using codeless IAP (have both IAP buttons, and IAP listeners set up). And I found out all google transactions are refunded while apple store transactions have no issues. Contacted google, they said it's because after Google Play Billing Library version 2.0 or newer, you must acknowledge all purchases within three days. Failure to properly acknowledge purchases results in those purchases being refunded. So I searched online for solutions, most of the solutions saying that I should switch to coded IAP version, but I do not want to do such change fearing this may affect Apple's billing system as well. So my question is, is there a way for the codeless IAP developers to acknowledge Google IAP purchases? And I am using 4.7.0 In-app Purchasing library version.

    BTW, I asked chatGPT, and it gave solution like this:

    Code (CSharp):
    1. public void OnPurchaseComplete(Product product)
    2. {
    3.     // Your purchase processing logic here
    4.  
    5.     if (Application.platform == RuntimePlatform.Android && product.definition.type == ProductType.NonConsumable)
    6.     {
    7.         var iapButton = GetComponent<IAPButton>();
    8.         var googlePlayStoreExtensions = iapButton.StoreController.extensions.GetExtension<IGooglePlayStoreExtensions>();
    9.         googlePlayStoreExtensions.AcknowledgePurchase(product.transactionID, OnAcknowledgePurchaseSuccess, OnAcknowledgePurchaseFailure);
    10.     }
    11.     else
    12.     {
    13.         product.ConfirmPendingPurchase();
    14.     }
    15. }
    Though this has compiler error: 'IAPButton' does not contain a definition for 'StoreController' and no accessible extension method 'StoreController' accepting a first argument of type 'IAPButton' could be found.
     
    Last edited: Apr 15, 2023
  2. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,256
    IAPButton does not have a StoreController reference, and IGooglePlayStoreExtensions does not have such a thing as a "AcknowledgePurchase" method. When coding I would recommend checking the official documentation, the Unity IAP scripting reference is not that bad and by skimming through, you would have already known that these methods do not exist and what to call instead.

    General information:
    https://docs.unity3d.com/Manual/UnityIAPProcessingPurchases.html

    Specifically, finish all transactions at the end of ProcessPurchase() (by doing return PurchaseProcessingResult.Complete). Documentation with template code:
    https://docs.unity3d.com/Manual/UnityIAPInitialization.html
     
  3. kloseliebej

    kloseliebej

    Joined:
    Nov 13, 2020
    Posts:
    3
    Hi Baroni, thanks for your response. I did read all documentation thoroughly but I could not find anything about adding acknowledgement to Google using codeless IAP. The two doc you linked are all initialization method in coded IAP I believe. Based on the documentation, users can choose between codeless IAP and coded IAP depended on their situation. So I think Unity should provide the same support for codeless IAP users.
     
  4. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,256
    Unfortunately Unity recommends not using Codeless for a long time already, since it is not that feature rich, or in some cases not useable at all.

    The first documentation page I linked describes the general workflow when receiving and trying to finish a transaction with the App Store. The second documentation page, although listed in the initialization section, has the sample on how to finish a transaction.

    Code (CSharp):
    1.     /// <summary>
    2.     /// Called when a purchase completes.
    3.     ///
    4.     /// May be called at any time after OnInitialized().
    5.     /// </summary>
    6.     public PurchaseProcessingResult ProcessPurchase (PurchaseEventArgs e)
    7.     {
    8.         return PurchaseProcessingResult.Complete;
    9.     }
    You would definitely want to use scripted Unity IAP (there is actually no real choice), or my Simple IAP System asset which comes with an IAP editor, shop prefabs and shop initialization already, basically what you already know from codeless IAP (but it works).
     
    Julian-Unity3D likes this.
  5. Julian-Unity3D

    Julian-Unity3D

    Unity Technologies

    Joined:
    Apr 28, 2022
    Posts:
    192
    Codeless IAP is ideal for testing and demos, but I wouldn't recommend it at the moment for production ready builds. You would need to manually update the codeless script, not recommended as it would get overwritten on the next update.

    You are right Coded IAP has many more features, especially for what @kloseliebej is looking for.

    Overview | In App Purchasing | 4.8.0 (unity3d.com)
     
  6. kloseliebej

    kloseliebej

    Joined:
    Nov 13, 2020
    Posts:
    3
    I see, thank you all for responding! I will then continue to work on the coded version.

    I think when I read the documentation about IAP it still had the codeless option saying you can using the auto initialization and IAP catalog along with the IAP button, but it seems to be removed now. Probably worth mentioning codeless IAP is not production ready in the document somewhere.
     
    Julian-Unity3D likes this.
  7. Maris-Software

    Maris-Software

    Joined:
    Jun 11, 2019
    Posts:
    1
    Hello!
    I have a similar issue but I'm not using Codeless, from about 100 transactions only 7 were successful, and others were canceled after 3 days, I tested the game before launching it on Google Play both with a test account and with real money and it worked for me.
    Here is my code.
     

    Attached Files:

  8. kustom

    kustom

    Joined:
    May 11, 2012
    Posts:
    108
    I had more then 10 transactions in latest 8 days and no signal on PlayStore console, also no signal on Firebase Analytics.
    Unity Analytics is giving me high revenue these days but not real as i can see.
    Using “real code”, tested in last with my device making a real payment.
     
  9. cagri-gcia

    cagri-gcia

    Joined:
    Oct 19, 2018
    Posts:
    1
    @Julian-Unity3D Would it be possible to update the IAP package docs to include a warning at the top of each Codeless IAP saying it might not work in production environment or It's recommended to use Scripting api instead of Codeless?

    Also "Set up and integrating Unity IAP" defaulting to Codeless IAP, it should also not say that if it's not the preferred way to implement IAP.

    It is inconsistent that documentation is saying you can use Codeless to setup most of the things, but forum messages from Unity personnel saying "It's not working" and "Use scripting api".

    It feels like documentation tries to trick people into thinking "It's easy to implement this, you don't need to write any code" but in reality it's not supported/trusted by Unity.
     
  10. unitynoob24

    unitynoob24

    Joined:
    Dec 27, 2014
    Posts:
    398
    So what is the fix / suggested solution for this - I didn't see any non-codeless examples? I launched my game about two weeks ago now and all of my non-consumable IAPs on Google/Android have been refunded. I reached out to players on my discord who purchased this IAP and none of them said they refunded - but having them check their emails confirmed that they did receive refunds. Apple is working fine, no issues there to my knowledge. I'm using In App Purchasing 4.9.4 and Unity 2020.3.45 - codeless

    @Julian-Unity3D

    I also posted here: thread

     
    Last edited: Sep 13, 2023
  11. markmozza

    markmozza

    Joined:
    Oct 16, 2015
    Posts:
    85
    Last edited: Sep 15, 2023