{"action":"created","issue":{"url":"https://api.github.com/repos/libgdx/gdx-pay/issues/62","labels_url":"https://api.github.com/repos/libgdx/gdx-pay/issues/62/labels{/name}","comments_url":"https://api.github.com/repos/libgdx/gdx-pay/issues/62/comments","events_url":"https://api.github.com/repos/libgdx/gdx-pay/issues/62/events","html_url":"https://github.com/libgdx/gdx-pay/issues/62","id":107551269,"number":62,"title":"Unfinished transactions are not restored on iOS","user":{"login":"alex-dorokhov","id":788340,"avatar_url":"https://avatars.githubusercontent.com/u/788340?v=3","gravatar_id":"","url":"https://api.github.com/users/alex-dorokhov","html_url":"https://github.com/alex-dorokhov","followers_url":"https://api.github.com/users/alex-dorokhov/followers","following_url":"https://api.github.com/users/alex-dorokhov/following{/other_user}","gists_url":"https://api.github.com/users/alex-dorokhov/gists{/gist_id}","starred_url":"https://api.github.com/users/alex-dorokhov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alex-dorokhov/subscriptions","organizations_url":"https://api.github.com/users/alex-dorokhov/orgs","repos_url":"https://api.github.com/users/alex-dorokhov/repos","events_url":"https://api.github.com/users/alex-dorokhov/events{/privacy}","received_events_url":"https://api.github.com/users/alex-dorokhov/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-09-21T16:38:47Z","updated_at":"2015-09-22T03:35:55Z","closed_at":null,"body":"If anything bad is occurred during handling transaction in observer (like NPE, out of memory, shutdown of the device, or any other unexpected exit from the app), then transaction is not marked as finished. The consequences are:\r\n1. You spent your money and gets nothing back\r\n2. If you try to buy the same item (in hope it will be bought this time), you gets the message: \"This item is already bought, you will get it for free.\", then you press OK and nothing happens. If you press again to buy the item, it shows the same message. Even if you reinstall the app, it will not help. \r\n\r\nIt is written in the [Apple docs] (https://developer.apple.com/library/ios/documentation/StoreKit/Reference/SKPaymentQueue_Class/#//apple_ref/occ/instm/SKPaymentQueue/addTransactionObserver:), SQPaymentQueue should be called right at the app start, before any other action is performed with the queue. In the current version the transaction observer is set up after product information is fetched. I have tried to change gdx-pay to setup observer right inside PurchaseManager.install method and this helped to finish the transaction and get my gems, which I have paid for.\r\n\r\nBut the problem is SKPaymentQueue restores unfinished transactions before we have any information about products (like price and currency), which is required to fill gdxpay.Transaction object (see PurchaseManageriOSApple.transaction(SKPaymentTransaction)). So, seems it is kind of a dead loop.\r\n\r\nSeems to fix this bug, we need an architectural change. Or do you have any other ideas?\r\n "},"comment":{"url":"https://api.github.com/repos/libgdx/gdx-pay/issues/comments/142170528","html_url":"https://github.com/libgdx/gdx-pay/issues/62#issuecomment-142170528","issue_url":"https://api.github.com/repos/libgdx/gdx-pay/issues/62","id":142170528,"user":{"login":"noblemaster","id":2363626,"avatar_url":"https://avatars.githubusercontent.com/u/2363626?v=3","gravatar_id":"","url":"https://api.github.com/users/noblemaster","html_url":"https://github.com/noblemaster","followers_url":"https://api.github.com/users/noblemaster/followers","following_url":"https://api.github.com/users/noblemaster/following{/other_user}","gists_url":"https://api.github.com/users/noblemaster/gists{/gist_id}","starred_url":"https://api.github.com/users/noblemaster/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/noblemaster/subscriptions","organizations_url":"https://api.github.com/users/noblemaster/orgs","repos_url":"https://api.github.com/users/noblemaster/repos","events_url":"https://api.github.com/users/noblemaster/events{/privacy}","received_events_url":"https://api.github.com/users/noblemaster/received_events","type":"User","site_admin":false},"created_at":"2015-09-22T03:35:55Z","updated_at":"2015-09-22T03:35:55Z","body":"I would generally think we should not do architectural changes unless it makes things either easier for the end-user (developer's that use gdx-pay) or we identify a problem that cannot be solved otherwise (bad architecture). \r\n\r\nI have to admit I haven't looked much at the iOS backend. \r\n\r\n> But the problem is SKPaymentQueue restores unfinished transactions before we have any information about products (like price and currency), which is required to fill gdxpay.Transaction object (see PurchaseManageriOSApple.transaction(SKPaymentTransaction)). So, seems it is kind of a dead loop.\r\n\r\n> Seems to fix this bug, we need an architectural change. Or do you have any other ideas?\r\n\r\nCould we just cache the unfinished transactions that are returned via SKPaymentQueue whenever our product information such as price & currencies are not available (yet)? Once we have the information available that's when we build our transaction object and finally notify about it/confirm delivery. I believe that should work?"}}