Why doesn't this work? (IAP / Play Store / Local Storage )

  • I want players to be able to purchase the product 'pro', have a localstorage value 'IsPro' set to '1' and set the global variable 'IsPro' to 1 also. When the layout starts it will check the localstorage value, and check the store at the same time. This way the player will also be able to use Pro features when the store listing is not accessible if they've previously purchased.

    So... why doesn't it work? And I mean none of it - people can purchase, but the localstorage and global variables never set

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Hi. I think that you need to set the local.storage (isPro key) value to the variable (isPro).

  • set the local.storage (isPro key) value to the variable (isPro).

    Can you explain? That doesn't actually change anything I/O as far as I can tell....

    I'd love to take it on faith but the only way of testing this is a 3-hour round-trip uploading and downloading to Intel/Google

  • Potential solution - I'd missed 'Getting' the value after checking if it exists. Extra step provided by Ciprian Amarendei on facebook.

    Still waiting for the upload/build/download/upload/process saga to finish - but potentially could be the fix. It's been days puzzling over it now! Will mark solved if solved.

  • To check if product has been purchased in the past you need to call "Restore puchases". With "Request store listing" you grab only products data, like product name, price etc.

    However in my case "Has product" action did not work with C2 IAP plugin at all. Normally you would expect "On restore purchases complete" condition, but there is no such in C2 IAP plugin. I've switched to Cordova IAP plugin and everything worked like a charm.

  • To check if product has been purchased in the past you need to call "Restore puchases". With "Request store listing" you grab only products data

    Frustrating to learn this, as this isn't how the manual describes its usage:

    "When On store listing success triggers, the product names and prices are available, and purchases can start being made or checked with the Has product condition."

    I've switched to Cordova IAP plugin and everything worked like a charm.

    Can you provide a link to the Cordova IAP plugin? Or do you mean the Cranberrygame IAP plugin?

  • You can see I had similar problem recently: viewtopic.php?f=147&t=168431

    Phonegap IAP is deprecated now and no longer supported by cranberrygame. Instead he provides Cordova IAP. I don't know where can it be found for free. I have bought all his plugins here https://www.scirra.com/store/construct2 ... ugins-1662

  • Yeah I just found them on the asset store when I went looking for alternate sources (I don't have paypal so the developer's website's direct channel to the plugins is a no go for me )

    Thanks so much for all your help - I'll report on progress...

  • So far, switching to Cranberry's CordovaIAP plugin and using restore purchases hasn't worked.

    Glad to finally find a place to put my app key though, as that part is entirely missing from the official plugin.

    It shouldn't be this difficult. IAP is the de rigeur for paying for apps.

  • Here you go. This is how I've implemented it and it works.

  • IAP processes now cause game-killing bug with no error reports! Hope your suggestion works - I see you've got your 'restore purchases' triggered by store listing succeeded, maybe that's part of where I'm going wrong.

    Here I am now:

    I honestly think my brain's half-fried. The other half's scrambled.

  • As above works perfectly. Thanks so much Backend, Ciprian on facebook, and everyone else who helped

  • I know your pain. It took me 2 weeks before I managed to set IAP correctly for a first time. I was very close to just give up that time. Anyways... glad I could help. GL with your game

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)