Search Unity

  1. Check out our Unite Austin 2017 YouTube playlist to catch up on what you missed. More videos coming soon.
    Dismiss Notice
  2. Unity 2017.2 is now released.
    Dismiss Notice
  3. The Unity Gear Store is here to help you look great at your next meetup, user group or conference. With all new Unity apparel, stickers and more!
    Dismiss Notice
  4. Introducing the Unity Essentials Packs! Find out more.
    Dismiss Notice
  5. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice
  6. Unity 2017.3 beta is now available for download.
    Dismiss Notice
Dismiss Notice
Unity partners with Udacity on Nanodegree program credentials to help you get hired! For more more information see our blog here.

Unity IAP Facebook WebGl - Payload Issues on Pending Purchases

Discussion in 'Unity IAP' started by Robert_231Play, Oct 12, 2017 at 1:24 PM.

  1. Robert_231Play


    Jun 13, 2016
    Hey guys,

    first a few information:
    so we are using unity IAP on Android (Google Play & Amazon), iOS and now also on facebook (WebGL).
    We are using Unity 5.6.3p1, IAP 1.13.1 and FB SDK (7.9.4 from facebook sdk page, not the unity-built in, cause it is not working on non-facebook platforms).

    what is the issue?
    In general unity iap is working great, even on WebGl. The user does a purchase, and the receipt of this product looks like this:
    Code (JavaScript):
    1. const receipt = {
    2.     "productID": "storeGoldPack200-4.0.1",
    3.     "transactionID": "1301665869944306",
    4.     "payload": "{\"json\":{\"purchaseToken\":\"1301665869944306\",\"paymentId\":\"1122371451226681\",\"purchaseTime\":1507732476,\"appId\":\"1458572774214371\",\"signedRequest\":\"kXt_VvZqfBf2nAdNqvKyvQ7SYPUG-jJ-8vorGsg2U84.eyJhbGdvcml0aG0iOiJITUFDLVNIQTI1NiIsImFtb3VudCI6IjIuMDkiLCJhcHBfaWQiOiIxNDU4NTcyNzc0MjE0MzcxIiwiY3VycmVuY3kiOiJFVVIiLCJpc3N1ZWRfYXQiOjE1MDc3MzI0NzgsInBheW1lbnRfaWQiOiIxMTIyMzcxNDUxMjI2NjgxIiwicHJvZHVjdF9pZCI6ImNvbS50d28zMS5tYWhqb25nY2l0eS5nb2xkcGFja18yMDAiLCJwdXJjaGFzZV90aW1lIjoxNTA3NzMyNDc2LCJwdXJjaGFzZV90b2tlbiI6IjEzMDE2NjU4Njk5NDQzMDYiLCJxdWFudGl0eSI6IjEiLCJzdGF0dXMiOiJjb21wbGV0ZWQifQ\"}}"
    5. };
    But if we now, for whatever reason, do not complete the purchase, the purchase will be handled again after the application gets started again and purchasing has been initialized.
    But this time the receipt looks different, with a malformed payload:
    Code (JavaScript):
    1. const receipt = {
    2.         "productID": "storeGoldPack200-4.0.1",
    3.         "transactionID": "1301665869944306",
    4.         "payload": "System.Collections.Generic.Dictionary`2[System.String,System.Object]"
    5. };
    It is easily to see that some json thing inside unity's purchasing went wrong, cause it seems like the original payload, which was a Dictionary<string, object> was simple called .ToString().
    Now we thought, well maybe our unity IAP is too old, cause their is IAP 1.14.0 out. But after we update the unity IAP to 1.14.0 the webgl application is not even working anymore.
    The webgl application is throwing the following exception with the new IAP:
    Code (JavaScript):
    1. blob: Uncaught TypeError: Module.asm is not a function
    2.     at Object.UnityLoader.23e47c3ec6d8ffe482cea20b3a8268c4 (blob:
    3.     at UnityLoader.loadCode.Module (UnityLoader.js:95)
    4.     at HTMLScriptElement.script.onload (UnityLoader.js:26)
    Now here is the question:
    a) can the issue be fixed without unity iap update or is not even related to it?
    b) why the applcation crashes after the update?