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

fix(storeapi): Expiration date never found on a subscribed product #327

Merged
merged 2 commits into from
Oct 11, 2023

Conversation

CarlosNihelton
Copy link
Contributor

@CarlosNihelton CarlosNihelton commented Oct 10, 2023

We observed during the attempt to integration testing with the WSL SAAS backend that we could never find the current subscription expiration date, even though we could clearly see that the user was subscribed to the product under test.

It turns out that, when iterating over the product SKUs, we had the broken assumption IsSubscription() && IsInUserCollection().
In this particular example the only SKU under user's possession doesn't show IsSubscription as true.

image

Pre iteration loop (product is in user collection)
image

First SKU ( is subscription but not owned by the current user)
image

Second SKU (is owned by this user, but it's not a subscription 🙃 )
image

So with this PR I'm relaxing on checking whether the SKU IsSubscription when querying the expiration date.

Also, this test raised the concern that it might be possible that a user may hold several SKUs of the same product (most likely one SKU will still be valid while others will be expired). Thus, I also changed the iteration to go over all SKUs found and return the greatest expiration date (the one most towards the future) instead of stopping the iteration on the first item found in user's collection.

The product SKUs seen in debug show either
`IsSubscription` or `IsInUserCollection` properties ON.
Never both.
So, I'm relaxing the first property in favor of the second,
when computing the expiration date.
The previous fix raised a concern on whether the user will
endup having multiple SKUs of the same product.
If so, multiple end dates would be found,
but the iteration stopped on the first collected SKU.
This ensures we go over them all,
returning the last end date found.
@CarlosNihelton CarlosNihelton marked this pull request as ready for review October 11, 2023 01:30
Copy link
Contributor

@EduardGomezEscandell EduardGomezEscandell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was fast!

@CarlosNihelton CarlosNihelton merged commit 589caa0 into main Oct 11, 2023
26 checks passed
@CarlosNihelton CarlosNihelton deleted the fix-no-expiration-date branch October 11, 2023 12:07
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

Successfully merging this pull request may close these issues.

2 participants