`cancellation_date` attribute for changing a plan of Auto Renewable Swift
Asked Answered
R

0

0

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?

Roughandready answered 16/2, 2022 at 9:6 Comment(3)
No, you won't get a cancellation date, because the user isn't cancelling their subscription. Only Apple can cancel a subscription after a support request from the user. If they upgrade to a higher plan then they are refunded the pro-rata amount and a new purchase is performed for the higher plan. If they choose a lower plan then a new purchase is processed after the current, higher, plan expires. Your code needs to look for the highest level subscription that is active (hasn't expired).Sadducee
I was literally waiting for your reply. Thanks. Right now I am checking only the latest_receipt_info attributes. Can you please explain a bit what do you mean by Your code needs to look for the highest level subscription that is active (hasn't expired).?Roughandready
Did you mean iteration through all receipt in the response? In my understanding I am thinking like this: If user is already in a plan which hasn't expired yet and buy a down graded plan, then it will be activated from the next cycle right? And it also the same for upgrade or if he buy more plan one after another. So in that case It will be ok If I just check the last object of latest receipt info. Correct me if I am wrong.Roughandready

© 2022 - 2024 — McMap. All rights reserved.