Skip to content

Custom Entitlement Computation: avoid getCustomerInfo requests for cancelled purchases#2449

Merged
NachoSoto merged 2 commits into
mainfrom
nacho/change-user-cancelled-behavior-in-custom-entitlements-mode
Apr 26, 2023
Merged

Custom Entitlement Computation: avoid getCustomerInfo requests for cancelled purchases#2449
NachoSoto merged 2 commits into
mainfrom
nacho/change-user-cancelled-behavior-in-custom-entitlements-mode

Conversation

@NachoSoto

@NachoSoto NachoSoto commented Apr 26, 2023

Copy link
Copy Markdown
Contributor

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.

…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.
@NachoSoto NachoSoto added the perf label Apr 26, 2023
@NachoSoto NachoSoto requested a review from a team April 26, 2023 16:09
@NachoSoto NachoSoto changed the title Custom Entitlement Computation: avoid getCustomerInfo requests in PurchasesOrchestrator for cancelled purchases Custom Entitlement Computation: avoid getCustomerInfo requests for cancelled purchases Apr 26, 2023

@tonidero tonidero left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM! Planning to test this a bit more to make sure we didn't leave any edge cases

@tonidero

Copy link
Copy Markdown
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

@NachoSoto

Copy link
Copy Markdown
Contributor Author

Great point!!

@NachoSoto

Copy link
Copy Markdown
Contributor Author

Done.

@tonidero tonidero left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

❤️

@NachoSoto NachoSoto merged commit d65caf7 into main Apr 26, 2023
@NachoSoto NachoSoto deleted the nacho/change-user-cancelled-behavior-in-custom-entitlements-mode branch April 26, 2023 16:53
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.
NachoSoto added a commit that referenced this pull request Jul 20, 2023
Follow up to #2597.
When we implemented #2449 we couldn't add tests for that different in behavior. This can be reflected with this test now.
NachoSoto added a commit that referenced this pull request Jul 21, 2023
…ons (#2849)

Follow up to #2597.

When we implemented #2449 we couldn't add tests for that difference in
behavior. This can be reflected with this test now.
@vegaro vegaro added pr:other and removed pr:perf labels Sep 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants