`cancellation_date` attribute for changing a plan of Auto Renewable Swift

232 views Asked by At

I have two questions. Let me describe the scenario with questions. I have 3 auto renewable plans in my app and they are in the same subscription group:

1 week
1 month
1 year

Suppose user buys 1 month subscription and then change it to 1 week or 1 year later. I saw in a post that in this case I would get the cancellation_date attribute in my latest_receipt_info as well.

"latest_receipt_info": [
    {
        "quantity": "1",
        "product_id": "XXX",
        "transaction_id": "150000567873035",
        "original_transaction_id": "150000567873035",
        "purchase_date": "2019-11-10 17:37:05 Etc/GMT",
        "purchase_date_ms": "1573407425000",
        "purchase_date_pst": "2019-11-10 09:37:05 America/Los_Angeles",
        "original_purchase_date": "2019-11-10 17:37:06 Etc/GMT",
        "original_purchase_date_ms": "1573407426000",
        "original_purchase_date_pst": "2019-11-10 09:37:06 America/Los_Angeles",
        "expires_date": "2019-12-10 17:37:05 Etc/GMT",
        "expires_date_ms": "1575999425000",
        "expires_date_pst": "2019-12-10 09:37:05 America/Los_Angeles",
        "cancellation_date": "2019-12-05 19:14:48 Etc/GMT",
        "cancellation_date_ms": "1575573288000",
        "cancellation_date_pst": "2019-12-05 11:14:48 America/Los_Angeles",
        "web_order_line_item_id": "150000194283402",
        "is_trial_period": "false",
        "is_in_intro_offer_period": "false",
        "cancellation_reason": "0",
        "subscription_group_identifier": "20502261"
    }
]

They set it as the date when user change the plan. cancellation_date usually tells the cancel date (through apple support) of a particular plan so I am not sure why apple send it for changing plan as well. So my first question is "Is it true, can someone confirm that?

Because right now I am comparing my current date with expiration date first. If my expiration date is bigger or equal than my current date then first I am setting my purchase status bool as true. Then I am comparing current date with cancellation_date and if cancellation_date is bigger than my current date I am setting my purchase status bool as false.

if currentDate!.compare(expireDate) == .orderedAscending {
    isSubsActive = true
} else if currentDate!.compare(expireDate) == .orderedDescending {
    isSubsActive = false
} else if currentDate!.compare(expireDate) == .orderedSame {
    isSubsActive = true
}

if isSubsActive == true {
    if currentDate!.compare(cancelDate) == .orderedAscending {
        isSubsActive = false
    } else if currentDate!.compare(cancelDate) == .orderedDescending {
        isSubsActive = true
    } else if currentDate!.compare(cancelDate) == .orderedSame {
        isSubsActive = false
    }
}

But If apple does send cancellation_date for changing plan, the upper condition checking needs to be modified. So my second question is How can I differentiate that cancellation_date with the cancellation_date apple send when someone just upgrade or downgrade the plan?

0

There are 0 answers