Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Note: Always set ignoreCanceled: true for Apple, otherwise you might reject valid purchases (this is not obvious from current documentation!) #342

Open
tkafka opened this issue May 22, 2021 · 2 comments

Comments

@tkafka
Copy link

tkafka commented May 22, 2021

For Apple, purchases are sorted by purchase_date (latest one goes first) (here), and then deduplicated by original_transaction_id (here).

This might seem innocent enough, but when the user upgrades eg. from monthly subscription to yearly, Apple might add an extra cancelled monthly transaction (probably to end prematurely the line of monthly subscriptions), which happens after the just activated yearly subscription. In the end, the sorted list of purchases looks like this:

  • purchase date = 2021-02-17 09:55:00 monthly subscription, cancelled (newest, few hours after previous)
  • purchase date = 2021-02-17 07:12:00 yearly subscription, valid
  • purchase date = 2021-02-03 15:34:00 previous month's monthly subscription, valid

As these transactions have a same original_transaction_id, the first one will overwrite the following one's if you set ignoreCanceled: false.
As a result, your user with yearly subscription will appear to have just one cancelled monthly transaction!

The fix? Set ignoreCanceled: true, so that cancelled transactions are filtered out before the deduplication. You will lose an evidence of cancelled payments, though.

@tkafka tkafka changed the title Note: Always set ignoreCanceled: true for Apple, otherwise you might reject valid purchases (this is not obvious from current documentation)! Note: Always set ignoreCanceled: true for Apple, otherwise you might reject valid purchases (this is not obvious from current documentation!) May 22, 2021
@dataxpress
Copy link

Thank you for posting this and your analysis! I'm running into this issue as well - lots of users who switch from monthly to annual complaining of their subscription not working. However, I am setting ignoreCanceled: true:

let purchaseData = iap.getPurchaseData(validatedData, { ignoreCanceled: true, ignoreExpired: true });

I am continuing to dig into this, as I think there might be something else going on with the ordering / sorting / filtering of the transactions. Have you had yours continue to work with ignoreCanceled: true or was there another workaround you needed? I'm also wondering if ignoreExpired is somehow causing a problem. Will post more if I come across anything.

@pierroo
Copy link

pierroo commented Feb 18, 2023

More than a year later, but did you guys manage to find a solution?
@dataxpress @tkafka

That would be super helpful, for managing subscriptions with ios and their ordering in the "in_app" array is a complete nightmare.
For consumable one time purchase it's always the first item of this array that gives the right info,
but when it comes to subscription it keeps being messed up...

Your help would be super appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants