Change user cancelled behavior in custom entitlement computation mode#2447
Conversation
|
Awesome 👍🏻 I'll add tests for this. |
|
TODO: add an assertion to ensure there's no customer info request in this case. |
| error: error | ||
| )) | ||
| let publicError = ErrorUtils.purchasesError(withUntypedError: error).asPublicError | ||
| let userCancelled = publicError.code == ErrorCode.purchaseCancelledError.rawValue |
There was a problem hiding this comment.
Oh I see why you needed this now. We need to compare the error domain too though, I'll fix that.
There was a problem hiding this comment.
I'm changing it to this:
| let userCancelled = publicError.code == ErrorCode.purchaseCancelledError.rawValue | |
| let userCancelled = publicError.isCancelledError |
| // This detects if `Product.PurchaseResult.userCancelled` is true. | ||
| let (userCancelled, sk2Transaction) = try await self.storeKit2TransactionListener | ||
| .handle(purchaseResult: result) | ||
| if self.systemInfo.dangerousSettings.customEntitlementComputation { |
There was a problem hiding this comment.
I think this was missing also checking userCancelled.
There was a problem hiding this comment.
Ah yes you're completely right. Didn't have time to test this 👍
| } catch StoreKitError.userCancelled { | ||
| if self.systemInfo.dangerousSettings.customEntitlementComputation { | ||
| throw ErrorUtils.purchaseCancelledError() | ||
| } |
There was a problem hiding this comment.
I'm not sure if this error would be catched by the following catches... Still had to test each of these cases to make sure it behaved as I expected
| // This detects if `Product.PurchaseResult.userCancelled` is true. | ||
| let (userCancelled, sk2Transaction) = try await self.storeKit2TransactionListener | ||
| .handle(purchaseResult: result) | ||
| if self.systemInfo.dangerousSettings.customEntitlementComputation { |
There was a problem hiding this comment.
Ah yes you're completely right. Didn't have time to test this 👍
…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.
|
Closing in favor of #2449 |
…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.
…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.
Description
Change user cancelled behavior in custom entitlement mode. Now for