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

unity IAP json

Discussion in 'Unity IAP' started by bobcccc, Jun 25, 2020.

  1. bobcccc

    bobcccc

    Joined:
    Mar 12, 2014
    Posts:
    96
    So i have successfully setup the IAP in unity and the items of the play developer console and it seems to all work...right now i have this code the outputs once the transaction is successful


    Code (CSharp):
    1. public PurchaseProcessingResult ProcessPurchase(PurchaseEventArgs args)
    2.     {
    3.         if (String.Equals(args.purchasedProduct.definition.id, resource500, StringComparison.Ordinal))
    4.         {
    5.             Debug.Log("buy 500 resource");
    6.         }
    7.         else if (String.Equals(args.purchasedProduct.definition.id, resource1000, StringComparison.Ordinal))
    8.         {
    9.             Debug.Log("buy 1000 resource");
    10.         }else
    11.         {
    12.             Debug.Log("Purchase Failed");
    13.         }
    14.         return PurchaseProcessingResult.Complete;
    15.     }
    The problem I have now is that once the transaction has been verified I need to send the JSON and signature to php to verify them and once verified add the resources to the mysqli database...are they somewhere in args.purchasedProduct??
     
  2. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    7,372
    This should help, it sounds like you want to send the receipts. But no need to reinvent the wheel, there are several services that already provide this feature, like PlayFab and ChilliConnect. You should not have users connect directly to your PHP server, but rather implement a web service API for security and scalability.

    https://docs.unity3d.com/Manual/UnityIAPValidatingReceipts.html

    e.purchasedProduct.receipt
     
  3. bobcccc

    bobcccc

    Joined:
    Mar 12, 2014
    Posts:
    96
    THanks I did look at them but I don't really want to be paying a monthly fee as well as have another bulky api added to my game when all i really need is just a quick verification of the payment receipt. If possible would just like to do it myself.

    Also having having developed my games on fb for the last 6-8 yrs and seeing my games slowly decimated by their incompetence and constant bugs i really don't want to rely on another system these days lol especially when it really should be easy to setup yourself...I just cannot find a recent tutorial on doing it.
     
    Last edited: Jun 26, 2020
  4. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    7,372
    Got it, happy to assist!
     
unityunity