ios - How to detect and verify a renewal for an auto-renewable subscription? -


so have setup auto-renewable subscription app period of 1 month, equals 5 minutes or in sandbox. in client app subscribe, send receipt server, gets verified , put record in database user has subscription.

my question how check if subscription has been renewed? have read docs , can't figure out should do.

here far:

  1. the initial receipt gets sent server verified status 0, great. latest_receipt, replace in database oldest receipt.
  2. after 6 minutes when try verify latest_receipt, status 21006 (expired receipt) , this:
   { receipt:         { original_purchase_date_pst: '2013-08-06 11:58:04 america/los_angeles',          unique_identifier: '------------',          original_transaction_id: '----------',          expires_date: '1376129825000',          transaction_id: '------------',          quantity: '1',          product_id: 'subscription',          item_id: '--------',          bid: 'com.--------',          unique_vendor_identifier: '---------',          web_order_line_item_id: '---------',          bvrs: '2.0',          expires_date_formatted: '2013-08-10 10:17:05 etc/gmt',          purchase_date: '2013-08-10 10:12:05 etc/gmt',          purchase_date_ms: '1376129525000',          expires_date_formatted_pst: '2013-08-10 03:17:05 america/los_angeles',          purchase_date_pst: '2013-08-10 03:12:05 america/los_angeles',          original_purchase_date: '2013-08-06 18:58:04 etc/gmt',          original_purchase_date_ms: '1375815484000' },       latest_expired_receipt_info:         { original_purchase_date_pst: '2013-08-06 11:58:04 america/los_angeles',          unique_identifier: '-------',          original_transaction_id: '-',          expires_date: '1376129825000',          transaction_id: '-',          quantity: '1',          product_id: 'subscription',          item_id: '-',          bid: 'com.-',          unique_vendor_identifier: '--',          web_order_line_item_id: '-',          bvrs: '2.0',          expires_date_formatted: '2013-08-10 10:17:05 etc/gmt',          purchase_date: '2013-08-10 10:12:05 etc/gmt',          purchase_date_ms: '1376129525000',          expires_date_formatted_pst: '2013-08-10 03:17:05 america/los_angeles',          purchase_date_pst: '2013-08-10 03:12:05 america/los_angeles',          original_purchase_date: '2013-08-06 18:58:04 etc/gmt',          original_purchase_date_ms: '1375815484000' },       status: 21006 } 

the second element in array used latest_receipt_info, it's latest_expired_receipt_info. here docs say:

in addition receipt_data field, response may include 2 new fields. if user’s subscription active , renewed transaction took place after receipt server sent app store, the latest_receipt field includes base-64 encoded receipt last renewal subscription. the decoded data new receipt provided in latest_expired_receipt_info field. server can use new receipt maintain record of recent renewal.

so if sub has been renewed since server last checked, decoded receipt renewal should in latest_expired_receipt_info. in object expires_date same original receipt's expires_date.

what hell? want check if sub active. can explain in simple words how do that?

thank you!

my experience. let's assume, send initial receipt apple's server.

in case, you'll json @ least 2 fields: status (no comments) , receipt (information receipt you've send).

additionally that:

1) if subscription still active, you'll additionally latest_receipt (base64-encoded string) , latest_receipt_info (information receipt).

2) if subscription already expired, you'll additionally latest_expired_receipt_info (information last renewing receipt). yes, information it, no base64-encoded string.

and yes, afaik, that's not documented anywhere. hope helps.


Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

Function that returns a formatted array in VBA -