gabrielgarza/monza

Handling cancellation_date

Closed this issue · 8 comments

Thanks for making this awesome gem!

Question: does the gem handle cancellation_date from the apple response?
https://developer.apple.com/library/prerelease/content/releasenotes/General/ValidateAppStoreReceipt/Chapters/ReceiptFields.html#//apple_ref/doc/uid/TP40010573-CH106-SW1

Seems like response.is_subscription_active? might do it, but I can't find any reference to cancellation_date in the code.

Thanks again!

No problem!

I hadn't seen that attribute before, at least in my testing I've never seen it in a response. From the docs cancellation_date is "For a transaction that was canceled by Apple customer support, the time and date of the cancellation.". It might be that this field only appears if an Apple customer support rep cancels a transaction, so it would be unreliable to use that field for checking if a subscription is active or not. Apple never tells us when a user performs a cancellation. The only way to know is to see if their latest transaction receipt is still valid.

r-a-o commented

If the customer contacts Apple for a refund on a recent subscription renewal, Apple might cancel the transaction and refund the amount to the customer. (usually if the cancel request is within 24-36 hrs)
In such cases, Apple sets the cancellation_date, so if you have this field set on the latest receipt, you can assume that the user received the refund and is no longer subscribed. Hence its necessary to have a Cron job on the server which checks all receipts which are active to see if any of the receipts were cancelled by Apple Support.

r-a-o commented

I would expect response.is_subscription_active? to return false if the latest receipt's cancellation_date is set.

Does anyone have an example JSON response for a cancelled receipt? I'd be happy to make a PR to implement this but I'm a little unclear of where it is in the nesting.

@r-a-o good point, and thanks again @tsabend for surfacing the issue

Let's make the change, I'm also unclear about the JSON response for a cancelled receipt. lmk if you find an example. One idea is to just check if the attribute cancellation_date is present

zxr90 commented

Any updates on this?

No updates yet. If you happen to have an example response with the cancellation_date would be greatly appreciated :)

Just merged a PR for handling cancellation date #13