Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

Unity IAP,Completion without reward

Discussion in 'Unity IAP' started by JustjNme, Apr 2, 2019.

  1. JustjNme

    JustjNme

    Joined:
    Nov 13, 2018
    Posts:
    12
    I made the content about unity IAP according to the official document, but I could not get the purchased props, and the method specified On Purchase Complete(Product) was never executed. According to the information displayed On the console, the payment process should have been completed(I'm not sure). I am very confused about this, and I hope you can help me find out the problem, thank you!
     

    Attached Files:

  2. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    5,911
    You have Runtime Only in the click event, so it would not be expected to trigger while in the Editor. Also, IAP purchases do not work in the Editor environment and use the fake store only. You need to deploy to an actual device.
     
  3. JustjNme

    JustjNme

    Joined:
    Nov 13, 2018
    Posts:
    12
    Thank you for your help. I understand that you mean that I need to select editor and runtime to deploy the game to my iPhone for testing at the same time to get the reward?
     
  4. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    5,911
    Sorry no, and not sure what you mean "at the same time to get the reward". "Editor and Runtime" means that the method will trigger both in the Editor ("Editor") and on the device ("Runtime"). That simply means the method will be executed, it applies to any click event and not just IAP. Use Debug.Log to confirm, the output will show in the Unity Console window. Ensure you follow the directions here to properly implement IAP: https://docs.unity3d.com/Manual/UnityIAPAppleConfiguration.html (Apple) and https://docs.unity3d.com/Manual/UnityIAPGoogleConfiguration.html (Google)
     
  5. JustjNme

    JustjNme

    Joined:
    Nov 13, 2018
    Posts:
    12
    Thank you for your patience. My problem now is that I test the function of purchasing and removing ads. I set it as "Editor and Runtime".Then I deployed the project to my IOS device, but I still couldn't get the remove ads after I bought it in the sandbox environment.What I want to solve is what method I should use to get the remove ads. I don't know if you can understand me. It is really difficult for me to express myself in English.The normal process is to pay and then remove the ads. I don't know how to use On Purchase ComPlete to remove the ads after the payment.
     
  6. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    5,911
    Please show the code that you are using to remove the ads (or just the code that you are using to show ads). Do you have ads working in your game? Typically to show an ad you use ad.Show(). Once your user buys the NoAds product, set a Boolean or similar, and then don't show any ads if it is true. You are going to need to write some code! https://unityads.unity3d.com/help/unity/integration-guide-unity . Also, check out the Sample IAP Project here https://forum.unity.com/threads/sample-iap-project.529555/
     
  7. JustjNme

    JustjNme

    Joined:
    Nov 13, 2018
    Posts:
    12
    Here's the code and setup for the sections involved.If you have errors, please help me point out that part of PurchaseManager is numbered
     

    Attached Files:

    • 1.png
      1.png
      File size:
      95.6 KB
      Views:
      204
    • 2.png
      2.png
      File size:
      71.2 KB
      Views:
      197
    • 3.png
      3.png
      File size:
      89.7 KB
      Views:
      187
    • 4.png
      4.png
      File size:
      59.9 KB
      Views:
      241
    • 5.png
      5.png
      File size:
      65.4 KB
      Views:
      207
  8. JustjNme

    JustjNme

    Joined:
    Nov 13, 2018
    Posts:
    12
     

    Attached Files:

  9. JustjNme

    JustjNme

    Joined:
    Nov 13, 2018
    Posts:
    12
    Console output at the time of purchase
     

    Attached Files:

  10. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    5,911
    Looks great! For real purchases, you'll need to test on a device. Be sure to use Debug.Log as I did in the Sample project to confirm your program flow and logic.
     
  11. JustjNme

    JustjNme

    Joined:
    Nov 13, 2018
    Posts:
    12
    I've tested it On the device, and apple's payment process has been triggered, but the method set in On Purchase Complete(Product), StartManger.RemoveAds(), is still not executed.So there's still no payoff after the payment is made.Because the test has been paid before, so here is a hint whether I need to resume the purchase.
     

    Attached Files:

  12. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    5,911
    The purchase was successful. Please use appropriate debugging techniques to determine the logic flow in your code. I would not want to guess at the reason at this point without debugging information. As a simple test, just put a non-IAP button on the forum and hook it up to your reward logic. Make sure this simple test works first. If not, then place liberal Debug.Log statements through your code and/or step debug in Visual Studio. Did you test and compare with the Sample project? Please confirm.
     
  13. JustjNme

    JustjNme

    Joined:
    Nov 13, 2018
    Posts:
    12
    One thing is I feel strange, see I provide screenshots, I didn't click "BUY", has carried out the return PurchaseProcessingResult.Complete;Isn't this the state where the purchase has been completed?Is this normal?
     

    Attached Files:

  14. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    5,911
    Please follow my previous instructions first instead of asking additional questions. It looks like you are mixing Codeless and scripted IAP. You should not be calling into the IAP methods for your success logic. Again, see the sample project.
     
  15. JustjNme

    JustjNme

    Joined:
    Nov 13, 2018
    Posts:
    12
    Problem has been solved, I can't clear expression of the specific reasons, generally do as you say I am mixing Codeless and scripted IAP, anyway, thank you for your time and patience!Have a nice day
     
  16. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    5,911
    You definitely do not want to be mixing the two (Codeless and scripted), unexpected results and errors would be likely to occur. Be sure to test during a reinstall scenario also.