Search code examples
iossandboxreceipt-validation

Auto-renewable subscriptions expiration date off Apple specification


I am trying to validate auto-renewable subscriptions on iOS. More specifically I want to:

1) Verify that the signature is correct [ √ ]

2) Verify that the subscription has not expired [ X ]

When I hand the receipt of to the server I get validation status 0, which is exactly what I expect, nothing wrong with that.

However, when I try to read the expiration date of the receipt in the sandbox environment, the expiration dates drift off of the specified expiration dates for subscriptions from the Apple documentation, meaning, instead of having the subscription expire after 5 minutes in the case of our 1 month subscription, we get expiration times of several hours!

{
    "quantity": "1",
    "product_id": "{PRODUCT_IDENTIFIER}",
    "transaction_id": "1000000182307463",
    "original_transaction_id": "1000000182307463",
    "purchase_date": "2015-11-27 23:47:06 Etc/GMT",
    "purchase_date_ms": "1448668026000",
    "purchase_date_pst": "2015-11-27 15:47:06 America/Los_Angeles",
    "original_purchase_date": "2015-11-27 23:47:07 Etc/GMT",
    "original_purchase_date_ms": "1448668027000",
    "original_purchase_date_pst": "2015-11-27 15:47:07 America/Los_Angeles",
    "expires_date": "2015-11-28 02:35:06 Etc/GMT", // ---> expires_date - purchase_date => ~ 3 hrs
    "expires_date_ms": "1448678106000",
    "expires_date_pst": "2015-11-27 18:35:06 America/Los_Angeles",
    "web_order_line_item_id": "1000000031037801",
    "is_trial_period": "true"
}

If you look at the purchase_date and expiration_date fields you will quickly notice that they are almost 3hrs apart! (It is not even an even number, which also adds to the confusion...).

I haven't seen anybody else having this issue, which is why I am basically pulling my hair out over this.


Solution

  • The problem was that we didn't create sandbox accounts and used our iTunes Connect ones. After we created and used those it suddenly worked perfectly!