-
Notifications
You must be signed in to change notification settings - Fork 192
restored purchases on Android have an undefined purchase.date field #145
Comments
Try the following.
|
That is a useful workaround - thanks. |
I would argue this issue should not be closed - a workaround is not the same as a fix. As the situation currently stands, the plugin offers a broken API which the docs claim works. The fact that someone found a usable workaround does not mean this issue is resolved. |
@NateEag If you send us a pull request we can merge your fix. |
@moritzgloeckl Okay, thanks. I'll look for some time to do that. |
there is already #123 but its still unmerged. Yet another dead cordova plugin :( |
@hirbod It's unmerged because it breaks the build. If you fix it and the CI runs clean I can merge it! |
its a one-liner. You leave this Plugin broken because of this? You just need to change a single word |
PR has landed (for src and www) |
@hirbod Why did you send two PRs? You can include both changes into one. Have you tested your changes? Can you please add them to the tests as well? I'm going to delete your PRs, so you can send me one PR with all three files edited. Thanks. |
Cmon dude, I did a quick fix inside of githubs editor. I'm not going to repeat everything. Merge it or leave it |
I deleted the second one, as this was for "www" but I guess this will be generate anyway automatically when bundling up a release. |
@hirbod Well I know your changes are probably not breaking any existing code but nonetheless they should be tested and merged properly. "Merge it or leave it" is not an option because it's not just us two using this plugin. Feel free to fork the project, implement and test your changes, then send us a PR. Thanks. |
They are already tested locally and working fine. Before I just had an "undefined" state. |
When I restore purchases on a Galaxy Tab S2 (running Android version 6.0.1), the
date
field for each item isundefined
.Example Code
which, when run in my project (which uses Crosswalk, and thus Chromium), results in this (redacted) output:
Type of product you are working with consumable/non-consumable/subscription
I noticed this working with subscriptions, where I actually need the subscription's start date, but it seems to apply to both subscriptions and consumable products.
Version of cordova
cordova --version
says6.3.1
.Version of iOS/Android
As mentioned above, this is on an Android device running 6.0.1.
Proposed Fix
Adding some
console.log()
s to therestorePurchases
method helped me discover that the Google API response does not havestate
ordate
fields (as that code currently assumes), but instead haspurchaseState
andpurchaseTime
fields. This table in the Android docs appears to confirm that.Updating purchase construction as follows seems to do the job in my sandbox:
Note that this change would also fix issue #112 .
If a PR implementing this fix would be accepted, I can submit one.
The text was updated successfully, but these errors were encountered: