Search Unity

google IAP receipt and php

Discussion in 'Unity IAP' started by bobcccc, Jul 4, 2020.

  1. bobcccc

    bobcccc

    Joined:
    Mar 12, 2014
    Posts:
    122
    So I got IAP working and everything goes as plan and the receipt is sent to my php server to validate and then add the goods to the mysql database as the game is playable on multiple devices / website so storing on the mobile device will not work.

    The problem I am having is I cannot for the life of me figure out how to make the receipt useable, json decode just does not work and there seems to be a lot of / in the string.
     
    Last edited: Jul 5, 2020
  2. makaka-org

    makaka-org

    Joined:
    Dec 1, 2013
    Posts:
    1,026
    You can check successful work example with Simple IAP System.

    There are custom PHP sever code & JSON operating.
     
  3. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Please don't continue to multipost

    https://forum.unity.com/threads/unity-iap-and-verifying-with-php.908840/

    https://forum.unity.com/threads/unity-iap-json.919493/

    etc.

    You don't need to save the receipt, seems like a policy/privacy violation but I'm not a lawyer. I wouldn't want you storing my receipts! And why are you storing them? I understand parsing and validating, but that's it. Not sure how much your time is worth, but it would likely much easier and cheaper to use an existing receipt service. You don't need to store the receipt for IAP to work across multiple devices. Please share your logic/process flow for a user with 2 Android devices, what are you checking? The receipts are base64 encoded, as mentioned. You would need to decode them. And Simple IAP also uses PlayFab for their cloud save and receipt validation.
     
    Last edited: Jul 7, 2020
  4. bobcccc

    bobcccc

    Joined:
    Mar 12, 2014
    Posts:
    122
    Yeah I was saving the entire receipt to get the data to verify with google. But after a lot of trial and error I got it instead to get the purchase token and package within unity and then send that to my server. My server then sends that information to google and then verifies the order and adds the items to the database. Now it's setup and working perfectly but figuring out how it all worked together sucked lol.
     
  5. high-spy

    high-spy

    Joined:
    Oct 29, 2015
    Posts:
    4
    hey by chance can you help me??? this would be very useful, currently I have receipt data from purchase and sent to my server. The PHP part for verification, I can not get to work for the life of me.
     
  6. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Sorry, what code are you using on the server? Is there a specific reason you want to use server-side receipt validation and not client ? https://docs.unity3d.com/Manual/UnityIAPValidatingReceipts.html Have you checked out PlayFab or ChilliConnect? No need to reinvent the wheel! https://docs.chilliconnect.com/guide/iaps/