Search Unity

Android : server-side validation issues

Discussion in 'Unity IAP' started by BBO_Lagoon, Feb 2, 2021.

  1. BBO_Lagoon

    BBO_Lagoon

    Joined:
    Mar 2, 2017
    Posts:
    97
    Hi,

    Before purchase delivery I validate receipts on my server, this work nearly everytime but sometimes on Android I have the following error:

    Code (JavaScript):
    1.  
    2. {
    3.     "error": {
    4.         "code": 400,
    5.         "message": "Invalid Value",
    6.         "errors": [ {
    7.             "message": "Invalid Value",
    8.             "domain": "global",
    9.             "reason": "invalid"
    10.         } ]
    11.     }
    12. }
    13.  
    For information I validate Android receipt using the following url:
    https://www.googleapis.com/androidpublisher/v3/applications/{PackageNameStr}/purchases/products/{ProductIdStr}/tokens/{PurchaseToken}

    Apparently each time I have this error, the purchaseToken variable on the Payload object of the receipt contains a space but the transactionId of the receipt don't (just replaced the space by empty string).

    Does anyone have this problem or know how to fix this ?
     
  2. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    10,707
    Please provide steps to reproduce. Is this for new or existing purchases? Can you check for the spaces, etc on your server?
     
  3. BBO_Lagoon

    BBO_Lagoon

    Joined:
    Mar 2, 2017
    Posts:
    97
    Hi Jeff,
    As I said, the receipt validation work most of time. I never got the problem during my tests but I see this at least once or twice a week on my server logs. I really don't know how to reproduce the bug.
    All purchases on my game are consumable so yes it's always new purchases.
    First I was thinking about cheating attempts but not sure about it as I don't know how to cheat a payment to test this.
    As I have the same problem on 3 different games, I think maybe someone else have this problem too.

    On my logs I see that when the issue happen, there are always 2 or 3 differents products trying to validate each product with a different purchaseToken and each products goes 2 times for validation all that for the same user on the same minute.

    Here are the logs of the last time error happened:

    The prices are not correct in the payload infos
    welcome = 1.99$
    boutiquerhum3 = 99.99$
    boutiquerhum1 = 1.99$

    Code (JavaScript):
    1.  
    2. LOG 1: Tue, Feb 2, 9:08 AM
    3. {
    4.     "Store": "GooglePlay",
    5.     "TransactionID": "owtgrhyvuibjuijphlxjodaw.AO-J1OGlnOtuceaMdYcgJGpbNKNkAwyHeIagJGEOsvRoDVr-qXeAyUa_EtfvhgNWpBCVjLhPvDApKnurdxaqTScxLhSWtYnloCTEhewOfjvCmdIXedzCVxvcVvlfBomAsJKfXalagIAP",
    6.     "Payload": "{\"json\":\"{\\\"orderId\\\":\\\"7003226697245705233.9461509384419562\\\",\\\"packageName\\\":\\\"com.lagoonsoft.pb\\\",\\\"productId\\\":\\\"welcome\\\",\\\"purchaseTime\\\":1612242507306,\\\"purchaseState\\\":0,\\\"purchaseToken\\\":\\\"owtgrhyvuibjuijphlxjodaw.AO-J1OGlnOtuceaMdYcgJGpbNKNkAwyHe IagJGEOsvRoDVr-qXeAyUa_EtfvhgNWpBCVjLhPvDApKnurdxaqTScxLhSWtYnloCTEhewOfjvCmdIXedzCVxvcVvlfBomAsJKfXalagIAP\\\"}\",\"signature\":\"TwUUvSoVzPN6d0FHNLVF1JxF7tvjw5TpAg4SBRhhJcvbPfvBSP9BNX1lTct9bBbOxnbYP1cx1OUSVe3LY72/7VIwqNpaHZ/QTCFbHfbebKIQcx6mgB+q5h6G+YFI3YN61lMDEqhRHFEn3bZ2QKjQ255NI8OAqYVWOOSkltExL0Gt1dCbzmNTLhLoZwVuu/zQ942olA1Rz71zVyc3vAZMosG5exU71+7XUwLGnoldX76I2Fom8bwvKGqJyJr8pKZMIYv0O7MRDu72wbQ6DvCuQCEnGx+Jx38ruhEdAjhFVOZ+nIWvztGXykkHN8Bti11QdpEGHEfdO36EsgyLS9K1sw==\",\"skuDetails\":\"{\\\"productId\\\":\\\"welcome\\\",\\\"type\\\":\\\"inapp\\\",\\\"price\\\":\\\"$14.00 \\\",\\\"title\\\":\\\"welcome \\\",\\\"description\\\":\\\"welcome \\\",\\\"price_amount_micros\\\":14000000,\\\"price_currency_code\\\":\\\"USD\\\"}\"}"
    7. }
    8. LOG 2: Tue, Feb 2, 9:08 AM
    9. {
    10.     "Store": "GooglePlay",
    11.     "TransactionID": "owtgrhyvuibjuijphlxjodaw.AO-J1OGlnOtuceaMdYcgJGpbNKNkAwyHeIagJGEOsvRoDVr-qXeAyUa_EtfvhgNWpBCVjLhPvDApKnurdxaqTScxLhSWtYnloCTEhewOfjvCmdIXedzCVxvcVvlfBomAsJKfXalagIAP",
    12.     "Payload": "{\"json\":\"{\\\"orderId\\\":\\\"7003226697245705233.9461509384419562\\\",\\\"packageName\\\":\\\"com.lagoonsoft.pb\\\",\\\"productId\\\":\\\"welcome\\\",\\\"purchaseTime\\\":1612242507306,\\\"purchaseState\\\":0,\\\"purchaseToken\\\":\\\"owtgrhyvuibjuijphlxjodaw.AO-J1OGlnOtuceaMdYcgJGpbNKNkAwyHe IagJGEOsvRoDVr-qXeAyUa_EtfvhgNWpBCVjLhPvDApKnurdxaqTScxLhSWtYnloCTEhewOfjvCmdIXedzCVxvcVvlfBomAsJKfXalagIAP\\\"}\",\"signature\":\"r9i+2Hf19AxggUxQjGn1TJ+lfrwwq5Qs7KSzo8J7IHItI9uDbZDtzpJCSyhDIKi+mFC0qF8dd4Sc9XBWYRgW55hIQVLFUqKG+mQnad6rmjPCVnfKgK0lwkHxs+GeWDcYMH8CtGY/3F73vlqNnkm4BWBcTGZWAT1gDaFaDiTJWbtcd3i1i7Is/KynXhs4IhblG34LwTXZPa80V7N/UqVrMSf8ZI9FuJc6gcvpLlTEMbp/eYmEiE72AW9Lc8i6eQ9KviM1kveywmygEGTHD2+U0ntlDSRMYmRNfEc0aKKWGSHzD0q32FHhCniLQmZ6LKVR5fqUF5Pb65ObY0v1hlJZog==\",\"skuDetails\":\"{\\\"productId\\\":\\\"welcome\\\",\\\"type\\\":\\\"inapp\\\",\\\"price\\\":\\\"$14.00 \\\",\\\"title\\\":\\\"welcome \\\",\\\"description\\\":\\\"welcome \\\",\\\"price_amount_micros\\\":14000000,\\\"price_currency_code\\\":\\\"USD\\\"}\"}"
    13. }
    14.  
    15.  
    16. LOG 3: Tue, Feb 2, 9:08 AM
    17. {
    18.     "Store": "GooglePlay",
    19.     "TransactionID": "emziqrnexapcyozxjggcdbok.AO-J1OEGvAGEnDAhrWclsPhkXlEmAzMCZtoScZPpskTqbEE-teTxBeS_qdycdvzRGfzHaEKADWDiuoCBOUwTNOEKqiOiRfeFJZaVUxVyYYIJRCzhKmhFaguOECBjRbOHzCKwaoeapXLO",
    20.     "Payload": "{\"json\":\"{\\\"orderId\\\":\\\"5168969973765284443.9391307208630490\\\",\\\"packageName\\\":\\\"com.lagoonsoft.pb\\\",\\\"productId\\\":\\\"welcome\\\",\\\"purchaseTime\\\":1612242518380,\\\"purchaseState\\\":0,\\\"purchaseToken\\\":\\\"emziqrnexapcyozxjggcdbok.AO-J1OEGvAGEnDAhrWclsPhkXlEmAzMCZ toScZPpskTqbEE-teTxBeS_qdycdvzRGfzHaEKADWDiuoCBOUwTNOEKqiOiRfeFJZaVUxVyYYIJRCzhKmhFaguOECBjRbOHzCKwaoeapXLO\\\"}\",\"signature\":\"JUjz6EZSwN8HSfgK2wjLFj+meCqq39R/C4YE9IoAUg41cGrQjKnJ/5/t68XAJiBxXGKKMboBfHZKl+3+mZ3N30H2ja+dhxJaVlT9OY5Xg8fJV6RWieB0+4+jyBXm+cjimQiECVUhFuFKnTBkbPIpBrfVJA8uvQPdqBuo/GG0KWFxA3HyqA30phujFS20UApXfdOCoxXILCspz8xgcN1n62HJsUsa9MqDcEcrlHVg3lcVUQWMfjd7aOmAoTlqMReR5qvYDkWLSpJwz6+C8Qb2VZxH1rv9rSQ7g4vkgB0jbVre4y4nV+cWNElQcEAgUwNs1SlTVPjwwo/WlbETSLaNNw==\",\"skuDetails\":\"{\\\"productId\\\":\\\"welcome\\\",\\\"type\\\":\\\"inapp\\\",\\\"price\\\":\\\"$14.00 \\\",\\\"title\\\":\\\"welcome \\\",\\\"description\\\":\\\"welcome \\\",\\\"price_amount_micros\\\":14000000,\\\"price_currency_code\\\":\\\"USD\\\"}\"}"
    21. }
    22.  
    23.  
    24. LOG 4: Tue, Feb 2, 9:08 AM
    25. {
    26.     "Store": "GooglePlay",
    27.     "TransactionID": "owqijwplpuuhlemocadefehm.AO-J1OeGmhaWgZUgeOOkMATIPdXtIUBzAREjBixYZFDqTbG-wAWyYUC_otHPbgDidFSpFdWyxJFMUCsTeQUCleLOoXhQPPLwRreuawwztgzyjwcIuTHRpCOpBpgTdNzCjUdNOrkNBizf",
    28.     "Payload": "{\"json\":\"{\\\"orderId\\\":\\\"7429016175542535239.8167050441942729\\\",\\\"packageName\\\":\\\"com.lagoonsoft.pb\\\",\\\"productId\\\":\\\"boutiquerhum3\\\",\\\"purchaseTime\\\":1612242523954,\\\"purchaseState\\\":0,\\\"purchaseToken\\\":\\\"owqijwplpuuhlemocadefehm.AO-J1OeGmhaWgZUgeOOkMA TIPdXtIUBzAREjBixYZFDqTbG-wAWyYUC_otHPbgDidFSpFdWyxJFMUCsTeQUCleLOoXhQPPLwRreuawwztgzyjwcIuTHRpCOpBpgTdNzCjUdNOrkNBizf\\\"}\",\"signature\":\"1NEs1ZeVFBiKaND1rrnzOplnYwLDolqeMpA3Qlo1CKJdebJc8fyBHs9jLP+US1WGs0BXuOD2FBPrreDut+i5zVy0OCw0l7EWLclgFKW2KPIzARzajOktcdwdUoP+JTjITS0tdtTMhyyhc93KjlYN41xJzMHX0tL4kBtGLQaTKENT1LHRFwVszmk2O37uU9HCTzWDk+Ci5EkamwC/2v1KTLVvGrWaLJLaiCFhpdvO2uKXdVJOX1DDTI5VNHE4rzorW7xbn82LfhBF1l1YXtmboZ73st8cl6gGheXMchSNF3ZVHg6ncu29FazrZkPyQZv7NR4yeHUGLF6d8y+YEw1BRA==\",\"skuDetails\":\"{\\\"productId\\\":\\\"boutiquerhum3\\\",\\\"type\\\":\\\"inapp\\\",\\\"price\\\":\\\"$5.00 \\\",\\\"title\\\":\\\"boutiquerhum3 \\\",\\\"description\\\":\\\"boutiquerhum3 \\\",\\\"price_amount_micros\\\":5000000,\\\"price_currency_code\\\":\\\"USD\\\"}\"}"
    29. }
    30. LOG 5: Tue, Feb 2, 9:08 AM
    31. {
    32.     "Store": "GooglePlay",
    33.     "TransactionID": "owqijwplpuuhlemocadefehm.AO-J1OeGmhaWgZUgeOOkMATIPdXtIUBzAREjBixYZFDqTbG-wAWyYUC_otHPbgDidFSpFdWyxJFMUCsTeQUCleLOoXhQPPLwRreuawwztgzyjwcIuTHRpCOpBpgTdNzCjUdNOrkNBizf",
    34.     "Payload": "{\"json\":\"{\\\"orderId\\\":\\\"7429016175542535239.8167050441942729\\\",\\\"packageName\\\":\\\"com.lagoonsoft.pb\\\",\\\"productId\\\":\\\"boutiquerhum3\\\",\\\"purchaseTime\\\":1612242523954,\\\"purchaseState\\\":0,\\\"purchaseToken\\\":\\\"owqijwplpuuhlemocadefehm.AO-J1OeGmhaWgZUgeOOkM ATIPdXtIUBzAREjBixYZFDqTbG-wAWyYUC_otHPbgDidFSpFdWyxJFMUCsTeQUCleLOoXhQPPLwRreuawwztgzyjwcIuTHRpCOpBpgTdNzCjUdNOrkNBizf\\\"}\",\"signature\":\"VOHllyIVDIILY7CfCS7cdxCKXbbcX8oN93LHWxH3jGEvCcNByIVi9HYsDm+HhK7OSHIvG1dFiiO47eYJm/ejh2Cyuh4jmKknRbuRI0UoMsHXjH2h/zcYdojhXWJ2Am7uhQK8/0nhBVuRqpUQjwIXVx+HLECB5vNoFixJMhaFuPffqLIBH+n7Jrpx6X6m3WMfZA4qlaDLiDKRh/VoJ2mAVdbuSKfhMOQF4ygPAj8PTiBNaG/1sRxMmDAX5fII54nNc1irlaCJaWt0Xb24A/Nr2WebjqQdCDq+rANKNksoMKjk1O8cv7oLRJj2FncNNcwaoieMBOJDTDjBJ4hkN7qW6w==\",\"skuDetails\":\"{\\\"productId\\\":\\\"boutiquerhum3\\\",\\\"type\\\":\\\"inapp\\\",\\\"price\\\":\\\"$5.00 \\\",\\\"title\\\":\\\"boutiquerhum3 \\\",\\\"description\\\":\\\"boutiquerhum3 \\\",\\\"price_amount_micros\\\":5000000,\\\"price_currency_code\\\":\\\"USD\\\"}\"}"
    35. }
    36.  
    37.  
    38. LOG 6: Tue, Feb 2, 9:08 AM
    39. {
    40.     "Store": "GooglePlay",
    41.     "TransactionID": "zzojrbkjonlyrgkrnuyuqxuq.AO-J1OBHIaGYTzwvFFFKOGShvrCEbkUuqFpJzZwLOhMioFo-ZfsmnHx_zsXPoeKJtWafCJuxnjQaKnOWhkSQpXyIBJyhESRXyWazXXKQKXMuhaWuixoOZnUzFNHxSWHKZgiDwGrYwLAL",
    42.     "Payload": "{\"json\":\"{\\\"orderId\\\":\\\"3534569678685951537.1039855532870498\\\",\\\"packageName\\\":\\\"com.lagoonsoft.pb\\\",\\\"productId\\\":\\\"boutiquerhum1\\\",\\\"purchaseTime\\\":1612242532006,\\\"purchaseState\\\":0,\\\"purchaseToken\\\":\\\"zzojrbkjonlyrgkrnuyuqxuq.AO-J1OBHIaGYTzwvFFFKO GShvrCEbkUuqFpJzZwLOhMioFo-ZfsmnHx_zsXPoeKJtWafCJuxnjQaKnOWhkSQpXyIBJyhESRXyWazXXKQKXMuhaWuixoOZnUzFNHxSWHKZgiDwGrYwLAL\\\"}\",\"signature\":\"tz9qV4B2gU9vG0CmEzPn2SjdMRqtCnC/j4RNN9NTFoMeJSDFTmsijHFq+abMYGsiDkLEu54a6CaISuIrYHbIPB2uP4eGFRZEQR8egyTwka6+16/sc0UdT0RPfU/WYNXon+x6Jm+7tZD5zHb/jZXTgMXu4wxvCBo2TSo4eDIYS6j1d+gZ6UYvDLWkvOou5cMoVs+sB6qpKzpybXp0ZEj0ElM14WXloxaOF7JlIGIVYjjGidUjjv6aT0gp/erSruLnUrCeUOhuVOzDJwz9NpHPKBBXA3tdgkfhpIEKEdRU7KttAxxOjfPL0OS7whbuWlbnUYnsj6i8HtgiUmucNpql0w==\",\"skuDetails\":\"{\\\"productId\\\":\\\"boutiquerhum1\\\",\\\"type\\\":\\\"inapp\\\",\\\"price\\\":\\\"$7.00 \\\",\\\"title\\\":\\\"boutiquerhum1 \\\",\\\"description\\\":\\\"boutiquerhum1 \\\",\\\"price_amount_micros\\\":7000000,\\\"price_currency_code\\\":\\\"USD\\\"}\"}"
    43. }
    44. LOG 7: Tue, Feb 2, 9:08 AM
    45. {
    46.     "Store": "GooglePlay",
    47.     "TransactionID": "zzojrbkjonlyrgkrnuyuqxuq.AO-J1OBHIaGYTzwvFFFKOGShvrCEbkUuqFpJzZwLOhMioFo-ZfsmnHx_zsXPoeKJtWafCJuxnjQaKnOWhkSQpXyIBJyhESRXyWazXXKQKXMuhaWuixoOZnUzFNHxSWHKZgiDwGrYwLAL",
    48.     "Payload": "{\"json\":\"{\\\"orderId\\\":\\\"3534569678685951537.1039855532870498\\\",\\\"packageName\\\":\\\"xxx.xxx.xxx\\\",\\\"productId\\\":\\\"boutiquerhum1\\\",\\\"purchaseTime\\\":1612242532006,\\\"purchaseState\\\":0,\\\"purchaseToken\\\":\\\"zzojrbkjonlyrgkrnuyuqxuq.AO-J1OBHIaGYTzwvFFFKO GShvrCEbkUuqFpJzZwLOhMioFo-ZfsmnHx_zsXPoeKJtWafCJuxnjQaKnOWhkSQpXyIBJyhESRXyWazXXKQKXMuhaWuixoOZnUzFNHxSWHKZgiDwGrYwLAL\\\"}\",\"signature\":\"hFD7MgB7UqWmFOhDgD7ptk0MTQ3Z96kKoeK00rkPon1byXE0g+rRcLlES/sX1Iet6XW6UapHLIPFq+hbkSEG0RxIfDnssbBB1Vez4JFSMNivprkOrN8KoHQrmIrokbPL0XfehyUK2Wow7xvhAjJJ+036t+vCuXkPWsn+H1rDmqrrjK7lq4P5aQnuOJovnqz4FgjKz6OMpgxly8Mud9P6Hb6Nb94Q5djGITYT6RS5vx9/81EvWxLcEUlaVqNFhZoqAiv8+HpZ15w9dNBjX60/D6NM73zKnldo/JUVJbv7Q/BUKMRRIe/2yKX89zLykK5bwIBapyMGy5s7urZ3R0QNjQ==\",\"skuDetails\":\"{\\\"productId\\\":\\\"boutiquerhum1\\\",\\\"type\\\":\\\"inapp\\\",\\\"price\\\":\\\"$7.00 \\\",\\\"title\\\":\\\"boutiquerhum1 \\\",\\\"description\\\":\\\"boutiquerhum1 \\\",\\\"price_amount_micros\\\":7000000,\\\"price_currency_code\\\":\\\"USD\\\"}\"}"
    49. }
    50.  
     
  4. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    10,707
    Unfortunately without steps to reproduce, there is nothing we can do. But since you mention multiple operations for a single purchase, that would point to possible problem in your code. Please compare to IAPManager.cs in the Sample IAP Project https://forum.unity.com/threads/sample-iap-project.529555/
     
  5. BBO_Lagoon

    BBO_Lagoon

    Joined:
    Mar 2, 2017
    Posts:
    97
    I added info to my server logs an I see that install store when I have this kind of errors are not "com.android.vending" but kind of "ru.ldxywdqq.ltemiawyf" so I think it's not a IAP error but maybe a hack attempt.
     
  6. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    10,707
    You would not want to validate the receipt in this case (not award the product to the user)
     
unityunity