Invalid expire date after subscription purchase

本秂侑毒 提交于 2019-12-06 06:37:58

问题


i've got an android app with in-app subscriptions. After the user has purchased a subscription, i request the "validUntilTimestampMsec" and "initiationTimestampMsec" through our backend by the Google API.

The returning timestamp "initiationTimestamp" is correct and represents the time the user has made the purchase, but the returning timestamp "validUntilTimestamp" has always a difference of +12 hours to the real valid-until time i need. The function i use to retrieve the date is simmilar to both timestamps.

Where does the 12 hours come from and how can i get the correct time. The expire date will also be displayed wrong for the user inside Google Play.

Example for a monthly subscription:

Is:
initiationTimestamp: 1374433559436 (7:05pm)
validUntilTimestamp: 1377155159436 (7:05am) -> init-time + 1 month + 12 hours

Needed:
initiationTimestamp: 1374433559436 (7:05pm)
validUntilTimestamp: 1377111959 (7:05pm) -> init-time + 1 month without the 12 hours


回答1:


I dont see this anywhere mentioned, but I think Google maintains the 6 hours in v1 from Shrinath's example and 12 hours now in v1_1(looks like from your example) to basically to keep a time buffer to withdraw funds from the account of the client(a really important transaction that google is accountable for), and for cancellations and retry requests. I dont see a way around it, other than showing a warning saying it may take upto 12 hours to see new stuff or something like that.




回答2:


Write a function which calculates the validity time that "is right". If Google's reply doesn't match, use the one you calculated, otherwise, use the one that Google gave.

Also, observe that Google always adds additional time, not other way. So if your function returns "greater than" Google's then consider Google's time, else your function's time.

Thats how I solved it in app's backend.



来源:https://stackoverflow.com/questions/17919332/invalid-expire-date-after-subscription-purchase

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!