Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

expires_date field is invalid for auto-renewable subscriptions #17

Open
gmcnaughton opened this issue Aug 24, 2015 · 2 comments
Open

expires_date field is invalid for auto-renewable subscriptions #17

gmcnaughton opened this issue Aug 24, 2015 · 2 comments

Comments

@gmcnaughton
Copy link

When I verify receipts for auto-renewable subscriptions, the value for expires_date is wrong:

receipt_data = "..." # receipt for auto-renewable subscription
receipt = Itunes::Receipt.verify!(receipt_data, true)
receipt.expires_date
# => "1969-12-31 16:00:02.000000000 -08:00" (UTC epoch + 2 seconds?)

I think Receipt#initialize is parsing expires_date as milliseconds, but Apple's validator returns it as three fields (date, date_ms, and date_pst), similar to how it returns purchase_date. Snippet of a raw response from the validator:

{
  "receipt": {
    "in_app": [
      {
        ...,
        "purchase_date": "2015-08-01 11:47:43 Etc/GMT",
        "purchase_date_ms": "1438429663000",
        "purchase_date_pst": "2015-08-01 04:47:43 America/Los_Angeles",
        "expires_date": "2015-09-01 11:47:43 Etc/GMT",
        "expires_date_ms": "1441108063000",
        "expires_date_pst": "2015-09-01 04:47:43 America/Los_Angeles",

It looks like at some point Apple standardized how they return their date fields, but expires_date is being parsed as ms instead of a date string.

gmcnaughton pushed a commit to curious/itunes-receipt that referenced this issue Aug 24, 2015
Value used to be return as milliseconds, now it's returned as a formatted date
string (with extra fields for milliseconds and PST-formatted date).

Closes nov#17
@svendvd
Copy link

svendvd commented Sep 30, 2015

Works perfekt, Thx! Please merge it!

gem 'itunes-receipt', :git => 'https://github.com/curious/itunes-receipt.git', :branch => 'autorenew-cancellation_date'

@Paludis
Copy link

Paludis commented Oct 27, 2015

+1 merge please

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants