{"action":"created","issue":{"url":"https://api.github.com/repos/j3k0/cordova-plugin-purchase/issues/155","labels_url":"https://api.github.com/repos/j3k0/cordova-plugin-purchase/issues/155/labels{/name}","comments_url":"https://api.github.com/repos/j3k0/cordova-plugin-purchase/issues/155/comments","events_url":"https://api.github.com/repos/j3k0/cordova-plugin-purchase/issues/155/events","html_url":"https://github.com/j3k0/cordova-plugin-purchase/issues/155","id":65214097,"number":155,"title":"Android - tryValidation never calls my validator - crashes after first purchase","user":{"login":"JackNova","id":1033219,"avatar_url":"https://avatars.githubusercontent.com/u/1033219?v=3","gravatar_id":"","url":"https://api.github.com/users/JackNova","html_url":"https://github.com/JackNova","followers_url":"https://api.github.com/users/JackNova/followers","following_url":"https://api.github.com/users/JackNova/following{/other_user}","gists_url":"https://api.github.com/users/JackNova/gists{/gist_id}","starred_url":"https://api.github.com/users/JackNova/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JackNova/subscriptions","organizations_url":"https://api.github.com/users/JackNova/orgs","repos_url":"https://api.github.com/users/JackNova/repos","events_url":"https://api.github.com/users/JackNova/events{/privacy}","received_events_url":"https://api.github.com/users/JackNova/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-03-30T13:36:19Z","updated_at":"2015-03-31T12:46:22Z","closed_at":null,"body":"I'm debugging my application in Android, something weird happens.\r\n\r\nIf it is the first time I buy a product, the app never calls my validation function and crashes.\r\n\r\nIf I already bought a product on the store, this is relevant initialisation code:\r\n\r\n        store.register({\r\n              id:    rgConfig.getStoreId('Statistics'),\r\n              alias: 'Statistics',\r\n              type:   store.NON_CONSUMABLE\r\n          });\r\n\r\n\r\n        store.when(\"Statistics\").approved(function(product) {\r\n              product.verify();\r\n          });\r\n\r\n        store.when(\"Statistics\").verified(function(product) {\r\n              product.finish();\r\n              ...\r\n          });\r\n\r\n          store.refresh();\r\n\r\n\r\n.approved() gets called before the .ready() event.\r\n\r\n![upload_2015-03-30_at_2 43 54_pm](https://cloud.githubusercontent.com/assets/1033219/6896979/be88d134-d6f0-11e4-86c7-80214723b0a6.png)\r\n\r\nthis triggers execution of verify(), in this moment state is 'approved'\r\n\r\n![upload_2015-03-30_at_2 45 59_pm](https://cloud.githubusercontent.com/assets/1033219/6896985/c860fe20-d6f0-11e4-87d6-4722ae085544.png)\r\n\r\nwhen tryValidation is actually called the state is not 'approved' anymore but 'valid'\r\nso my validator is never called.\r\n\r\n![upload_2015-03-30_at_2 48 49_pm](https://cloud.githubusercontent.com/assets/1033219/6896987/cc56f28c-d6f0-11e4-8859-78e5dab1c969.png)\r\n\r\nIf I force the state to be 'approved' my validator gets called\r\n\r\n![upload_2015-03-30_at_2 51 24_pm](https://cloud.githubusercontent.com/assets/1033219/6896991/d2988a48-d6f0-11e4-8916-22581f435f36.png)\r\n"},"comment":{"url":"https://api.github.com/repos/j3k0/cordova-plugin-purchase/issues/comments/88070944","html_url":"https://github.com/j3k0/cordova-plugin-purchase/issues/155#issuecomment-88070944","issue_url":"https://api.github.com/repos/j3k0/cordova-plugin-purchase/issues/155","id":88070944,"user":{"login":"JackNova","id":1033219,"avatar_url":"https://avatars.githubusercontent.com/u/1033219?v=3","gravatar_id":"","url":"https://api.github.com/users/JackNova","html_url":"https://github.com/JackNova","followers_url":"https://api.github.com/users/JackNova/followers","following_url":"https://api.github.com/users/JackNova/following{/other_user}","gists_url":"https://api.github.com/users/JackNova/gists{/gist_id}","starred_url":"https://api.github.com/users/JackNova/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JackNova/subscriptions","organizations_url":"https://api.github.com/users/JackNova/orgs","repos_url":"https://api.github.com/users/JackNova/repos","events_url":"https://api.github.com/users/JackNova/events{/privacy}","received_events_url":"https://api.github.com/users/JackNova/received_events","type":"User","site_admin":false},"created_at":"2015-03-31T12:46:21Z","updated_at":"2015-03-31T12:46:21Z","body":"I agree 100%, could it be that when approved() gets called before the .ready() event the state is updated?\r\nBy the way, one side effect I'm aware of is that validation is invoked multiple times but to me this is not a problem (for how my app is designed)"}}