Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice
  2. Ever participated in one our Game Jams? Want pointers on your project? Our Evangelists will be available on Friday to give feedback. Come share your games with us!
    Dismiss Notice

Codeless IAP 1.23.2 Restore Workflow

Discussion in 'Unity IAP' started by icanhazscreenid, Jun 30, 2020 at 10:17 PM.

  1. icanhazscreenid

    icanhazscreenid

    Joined:
    Jun 2, 2016
    Posts:
    7
    Thanks for the Unity IAP package. It's a wonderful tool. I am working on an iOS app which is not live yet so I am testing in the Sandbox. Purchases appear to be working great. The Codeless Restore button is not making sense to me so I think I'm missing something about it's functionality. As I see it, a Restore press can essentially have three different outcomes:

    1. IAPButton.OnTransactionRestored(false) -> The restoration event was unsuccessful
    2. IAPButton.OnTransactionRestored(true) without any calls to a OnPurchaseComplete -> The restoration event was successful and no IAP receipts were found
    3. IAPButton.OnTransactionRestored(true) with calls OnPurchaseComplete button(s) -> The restoration event was successful and one or more IAP receipts were found

    I believe I can only test cases 1 and 2 while I'm in development. (I've purchased from the Sandbox successfully but I do not see these purchases on subsequent Restore calls). Please correct my understanding if I am wrong.

    Assuming I understand, I have two questions:

    1. For Case #3 above, will OnPurchaseComplete of the relevant Button be called before or after IAPButton.OnTransactionRestored?
    2. How do i get the success value of IAPButton.OnTransactionRestored from my project? (I see the Debug output of the function but I want to condition in my app based upon the success / failure).
     
  2. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    7,372
    You might be able to trigger (1) if you turn off the network after IAP initializes. If you plan to customize your use of IAP, then don't use Codeless. Use scripted IAP since you will be modifying code anyway and would be overwritten in the next IAP update if you aren't careful. What type of product(s) are trying to restore? Only non-consumables and subscriptions would be expected to restore. You can safely ignore the restore return code, your ProcessPurchase during Restore (which can happen after the restore method returns) will be called just like a user clicked the Purchase button. I would suggest that you test with the Sample IAP project here https://forum.unity.com/threads/sample-iap-project.529555/
     
  3. icanhazscreenid

    icanhazscreenid

    Joined:
    Jun 2, 2016
    Posts:
    7
    Hi, thanks for the fast response. Yes, I trigger (1) by turning off the network. (3) is the case I cannot duplicate (but you may know something I don't). I don't necessarily need a customized IAP but I want to know the value of IAPButton.OnTransactionRestored because that's the difference between telling the user to check their connection vs telling them there are no purchases to restore. Or is their another way with Codeless? When you say:

    You can safely ignore the restore return code, your ProcessPurchase during Restore (which can happen after the restore method returns) will be called just like a user clicked the Purchase button​

    My concern with this implementation is if the user presses the Restore button, I can only detect Case 3 above. Cases 1 and 2 cannot be differentiated.

    Unless I'm missing something, I totally understand your recommendation to migrate to scripted. I think that's what I need to do. But please let me know if I'm not understanding something.

    Thanks for the solid feedback and fast responses. You run a great forum and are very helpful!
     
  4. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    7,372
    What type of product are you trying to restore? It would either be Consumable, Non-Consumable, or Subscription. Once you have successfully purchased a non-consumable or subscription and Restore is successful, ProcessPurchase will be fired. I'm not familiar with a Codeless way to see if Restore failed, but you could look at IAPButton.cs. Editing this file would not be supported. Please provide the logs, they will contain additional information valuable for troubleshooting https://forum.unity.com/threads/how-to-capturing-device-logs-on-ios.529920/
     
  5. icanhazscreenid

    icanhazscreenid

    Joined:
    Jun 2, 2016
    Posts:
    7
    I'm trying to restore a Non-Consumable. I'm totally good with the case where ProcessPurchase is fired. I'm not good with the case that it doesn't. I'm imagining a paying customer pressing the Restore button and nothing is happening because my app can't tell the difference between no connection vs. no purchases. The last thing I want to do is frustrate paying customers. The logs show exactly what you would expect based upon the Debug lines in the IAP project. The debug line in the IAPButton.OnTransactionRestored function executes with the expected value from within Xcode but the problem is my app can't get see that value.
     
  6. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    7,372
    Yes, you would need to modify the codeless code :)
     
  7. icanhazscreenid

    icanhazscreenid

    Joined:
    Jun 2, 2016
    Posts:
    7
    Thanks for your gentle push. I've migrated to codeless and I now have the desired functionality. As is typical, I spent more time trying to figure out how not to change my code than the time it took to change my code. Once day I'll learn (maybe). Thanks!
     
unityunity