Subscription: Getting expiration date from receipt

Hello everyone,

For a subscription, in order to get the last expiration date from receipt, tutorials on internet recommend to get the "last object" of the receipt:

let lastReceipt = receiptInfo.lastObject as! NSDictionary let expiresDate = lastReceipt["expires_date"]

But during my tests in sandbox environment, I found out there is no ["expires_date"] in the receipt "last object". Actually, the last subscription info was always in the "first object", so I have to write:

let lastReceipt = receiptInfo.firstObject as! NSDictionary

Does anyone else notice that? Are these tutorials out of date? Or did I miss something? I am quite new with subscriptions, so thank you for any insights.

Internet tutorials are risky. If you have questions about specific instructions, it would be best to post a link to them.

Generally speaking, you shouldn't be doing any of that. That is Swift code. You should parse the receipt information using something like node or Python on your server, as instructed here.

The recommended means to obtain the most current record for an auto-renewing subscription is to validate the appStoreReceipt and include the "exclude-old-transactions":true key in the outbound JSON request - along with the base64 encoded appStoreReceipt and the shared-secret. If the response status is 0, then access the items in the "latest_receipt_info" section of the receipt. Only the most recent auto-renewing subscription item will be returned (or most current items is the user is subscribed to multiple subscription group items).

rich kubota developer technical support CoreOS/Hardware/MFI

Subscription: Getting expiration date from receipt
 
 
Q