This question is in accordance with the details provided about user subscriptions in the Microsoft Store's Get subscriptions for User API.
Referring to the image above, the user purchases a
monthly auto renewing
subscription plan on Day 0 which is expected to be renewed by the store on Day 30. We have renewal jobs running every six hours that pick the candidates nearing expiration in the next 6 hours or so.
So, somewhere on the 29th day our renewal job will run to check if the store has already charged the user for renewal. Different scenario states may occur at the time the job runs:
- User's subscription had been already renewed for the next cycle.
- User's subscription is yet to be attempted for renewal by the Store (unlikely).
- User has opted to turn off the renewal for the next cycle.
- Store was unable to charge the user and is retrying the billing.
- User's subscription was canceled by the developer (with or without refund).
Based on the documentation, there are two properties of interest which can help us identifying the scenarios above:
- recurrenceState
- expirationTime
Based on our understanding we have come up with this table for the above scenarios:
Case # Recurrence State Expiration Time
1 Active Day 60
2 Active Day 30
3 Active Day 30
4 InDunning Day 30
5 Canceled Less than day 30
Questions
Is there a way we can distinguish between case 2 and 3?
Also, we may choose to ignore case 2 because it is highly unlikely. But we would still require date calculations to be done to distinguish between Case 1 and 3, since both dates are future dates from the current date. Is there a better way for that rather than relying on date calculations?
Case 2 is unlikely because Microsoft Store starts charging the user 14 days in advance of the renewal date. If the billing fails, it falls into state 4. Now let's say Store charges the user on day 14 and he turns off the subscription on Day 20 (for the next cycle), will the user be refunded by Microsoft and how would that state reflect in the API response.
P.S:
We are still good if we have to check date is past or future from the current date.
It wouldn't be possible for the renewal job running after the 30th day to pick the candidates since our downstream system would automatically cancel the subscription if it is not renewed till day 30 and we do not have the control to change that logic in the downstream system.