Custom Entitlement Computation: avoid getCustomerInfo requests for cancelled purchases#2449
Merged
NachoSoto merged 2 commits intoApr 26, 2023
Conversation
…PurchasesOrchestrator` for cancelled purchases Fixes SDK-3088 Supersedes #2447 Note that it's currently impossible to test this for SK2, so we only have SK1 tests (we have a Radar for that). The next step will be to deprecate the current API to remove the `userCancelled` property and make this the new behavior. See also #1910 for an explanation of the different return values of the purchase APIs.
getCustomerInfo requests in PurchasesOrchestrator for cancelled purchasesgetCustomerInfo requests for cancelled purchases
tonidero
approved these changes
Apr 26, 2023
tonidero
left a comment
Contributor
There was a problem hiding this comment.
LGTM! Planning to test this a bit more to make sure we didn't leave any edge cases
Contributor
|
Actually should we also update the sample app so users of this mode can see how they should check if purchases were cancelled? So we can ask them to simply check out the sample code @NachoSoto |
Contributor
Author
|
Great point!! |
Contributor
Author
|
Done. |
NachoSoto
added a commit
that referenced
this pull request
Apr 26, 2023
…d` as `unavailable` Follow up to #2449. This is step 2 of 3 towards getting rid of `userCancelled` in purchase results. After #2449, `ENABLE_CUSTOM_ENTITLEMENT_COMPUTATION` builds no longer send `userCancelled` `true` for cancellations, and instead throw `ErrorCode.purchaseCancelledError`. To avoid users detecting cancellations looking at this property, it's not deprecated. To achieve that, I converted the `tuple` into a `struct`. This also required moving the affected `purchase` methods from `PurchasesType` to `PurchasesSwiftType`, but that's an implementation detail. The public API remains _mostly_ unchanged, with the only caveat that it's no longer possible to destructure the result tuple, so: ```swift let (transaction, customerInfo, cancelled) = Purchases.shared.purchase(...) ``` Needs to become: ```swift let result = Purchases.shared.purchase(...) ``` I updated the API tester to reflect that, as well as checking the properties of `PurchaseResultData`. As it's documented in #1910, completion block APIs already did send both `userCancelled` and the `error`, so we don't need to change those. This paves the future for a full deprecation, where we mark it `deprecated` for normal builds as well, and change the behavior regardless of the `DangerousSettings`.
NachoSoto
added a commit
that referenced
this pull request
Apr 26, 2023
…cancelled purchases (#2449) Fixes SDK-3088 Supersedes #2447 Thanks to @tonidero for doing most of this. Note that it's currently impossible to test this for SK2, so we only have SK1 tests (we have a Radar for that). The next step will be to deprecate the current API to remove the `userCancelled` property and make this the new behavior. See also #1910 for an explanation of the different return values of the purchase APIs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes SDK-3088
Supersedes #2447
Thanks to @tonidero for doing most of this.
Note that it's currently impossible to test this for SK2, so we only have SK1 tests (we have a Radar for that).
The next step will be to deprecate the current API to remove the
userCancelledproperty and make this the new behavior.See also #1910 for an explanation of the different return values of the purchase APIs.