-
Notifications
You must be signed in to change notification settings - Fork 50
Getting the receipt with the latest expiration date
Pablo Rivera edited this page Jul 9, 2016
·
5 revisions
You might have an issue where the receipt you get by using receipt.last_in_app
is not the one with the latest expiration date. To solve that, simply iterate over the receipts and get the one with the latest expiration date like so:
newest_receipt = None
for receipt in response.receipt.in_app:
if not newest_receipt:
#this makes sure we get a receipt that has an expires_date property
if receipt._.get('expires_date'):
newest_receipt = receipt
if receipt._.get('expires_date'):
#check which expires last
if receipt.expires_date > newest_receipt.expires_date:
newest_receipt = receipt
Read this if the use of properties and keys confuses you.