12

I am working on adding subscription to my iOS app and I came across some very annoying inconsistencies:

My server is listening for the DID_CHANGE_RENEWAL_STATUS notification from Apple:

{
    "auto_renew_status_change_date": "2019-06-05 13:42:43 Etc/GMT",
    "environment": "Sandbox",
    "auto_renew_status": "false",
    "auto_renew_status_change_date_pst": "2019-06-05 06:42:43 America/Los_Angeles",
    "latest_expired_receipt": "ewoJIn...",
    "latest_expired_receipt_info": ⊖{
        "original_transaction_id": "10000001010101010",
        "expires_date_formatted": "2019-06-05 13:43:13 Etc/GMT",
        ...
    },
    "password": "xxxxxxxxx",
    "auto_renew_status_change_date_ms": "1559742163000",
    "auto_renew_product_id": "com.my.product",
    "notification_type": "DID_CHANGE_RENEWAL_STATUS"
}

During my tests the notification contained in almost all cases a latest_expired_receipt and a latest_expired_receipt_info.

BUT some message contained latest_receipt and a latest_receipt_info instead. Beside this difference the structure of the messages was identical ("auto_renew_status": "false", auto_renew_status_change_date before the expires_date_formatted, etc.)

Does Apple change the structure randomly to make implementing subscription even more enjoyable or is there any logic on when which structure is used?

Of course I can simply adapt my server code to check if latest_receipt OR latest_expired_receipt is available but this would be a quick and dirty solution. I would prefer to understand when to expect which content/structure...

luke77
  • 2,255
  • 2
  • 18
  • 30
Andrei Herford
  • 17,570
  • 19
  • 91
  • 225
  • Hi, did you find the solution? if yes, please share – Tamil Selvan C Aug 06 '19 at 05:38
  • Not really. My solution is to check for both fields and use the one which is available. I found no information on when which field is used but it seems the they are not used both at the same time... – Andrei Herford Aug 07 '19 at 07:49

2 Answers2

3

Apple constantly make developer's life harder.

As stated in App Store Server Notifications documentation, top-level objects latest_receipt, latest_receipt_info, latest_expired_receipt, and latest_expired_receipt_info are scheduled for deprecation. This could be the reason for the notification to behave differently.

You should update your code to rely on latest_receipt & latest_receipt_info in unified_receipt object instead. test Source: https://developer.apple.com/documentation/appstoreservernotifications/responsebody

luke77
  • 2,255
  • 2
  • 18
  • 30
  • Thanks for this important hin! Always fun to work with Apple APIs and services...... However, so far I not could find a `unified_receipt` field in any received transactions?! It seems that one has to make a good guess how a receipt should look like, and which field could have which meaning... – Andrei Herford Oct 20 '20 at 07:51
0

If the order is expired when autorenew status is changes you are going to get latest_expired_receipt_info and latest_expired_receipt ( this cases include orders that are in billing retry and app store could not renew them during billing retry period, or the order was refunded), for other cases when subscription is still valid you will get latest_receipt and latest_receipt_info

vasmarg
  • 101
  • 5