4

The Apple documentation for server to server notifications does not specify what data format will come in the cancellation_date field. I'm trying to setup some unit tests for my notification handler but I'm not sure what data to put in my mock response.

I would assume that it is milliseconds since epoch but where other fields are noted in the documentation as being that, the cancellation_date field just reads, "The time and date that a transaction was cancelled by Apple customer support."

Can anyone confirm the date format that is in the cancellation_date field?

jmichas
  • 1,139
  • 1
  • 10
  • 21

1 Answers1

4

I did find this today:

if the receipt status is 21006 and there is a key named cancellation_date, then it’s a cancellation, you can find the new expiration date in that key but it’s a formatted date, if you need a better value to parse check for receipt['latest_expired_receipt_info']['cancellation_date_ms'] same as expires_date

Notification of cancellation of auto-renewal for an in-app purchase

I've also now confirmed this in production. There's a cancellation_date_ms property of latest_expired_receipt_info and also in the root of the notification itself. cancellation_date is a formatted date string.

Here's a partial production notification:

{ "environment": "PROD", "auto_renew_status": "false", "latest_expired_receipt_info": { "original_purchase_date_pst": "2018-01-25 11:59:25 America/Los_Angeles", "cancellation_date_ms": "1517150504000", "cancellation_reason": "0", "original_purchase_date_ms": "1516910365000", "expires_date_formatted": "2019-01-25 19:59:23 Etc/GMT", "is_in_intro_offer_period": "false", "purchase_date_ms": "1516910363000", "expires_date_formatted_pst": "2019-01-25 11:59:23 America/Los_Angeles", "is_trial_period": "false", "expires_date": "1548446363000", "cancellation_date": "2018-01-28 14:41:44 Etc/GMT", "purchase_date": "2018-01-25 19:59:23 Etc/GMT", "cancellation_date_pst": "2018-01-28 06:41:44 America/Los_Angeles", "purchase_date_pst": "2018-01-25 11:59:23 America/Los_Angeles", "original_purchase_date": "2018-01-25 19:59:25 Etc/GMT" }, "cancellation_date_ms": "1517150504000" }

siburb
  • 4,880
  • 1
  • 25
  • 34
  • Thanks. I have not found an answer to this yet and have not been able to capture it in the real world yet. This seems like good info and I will have to check my code to see if I'm handling things as you have described. – jmichas Jan 29 '18 at 13:48
  • I tweaked our server and have now received the "CANCEL" notification properly. See updated answer. – siburb Jan 29 '18 at 15:07
  • any reason why auto_renew_status is outside of your latest info? the document says that field should be inside the receipt info. – kevinl Aug 20 '18 at 16:28
  • According to [Apple Developer Documentation](https://developer.apple.com/documentation/appstorereceipts/status): The value for status is 0 if the receipt is valid, or a status code if there is an error. The status code reflects the status of the app receipt as a whole. For example, if you send a valid app receipt that contains an expired subscription, the response is 0 because the receipt is valid. – Gürol Canbek Jun 15 '20 at 20:59