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
Improve the way to handle the error if purchase(sk2Product)
fails due to an error when posting the receipt
#1177
Improve the way to handle the error if purchase(sk2Product)
fails due to an error when posting the receipt
#1177
Conversation
@@ -215,7 +243,7 @@ class PurchasesOrchestratorTests: StoreKitConfigTestCase { | |||
expect(self.backend.invokedPostReceiptDataParameters?.isRestore).to(beFalse()) | |||
} | |||
|
|||
func testStoreKit2TransactionListenerDelegateWithObesrverMode() async throws { | |||
func testStoreKit2TransactionListenerDelegateWithObserverMode() async throws { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fix a typo 🙂
expect(userCancelled) == false | ||
expect(customerInfo).to(beNil()) | ||
expect(error).toNot(beNil()) | ||
expect(error?.localizedDescription).to(equal(expectedError.localizedDescription)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe check the domain and code too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It makes sense.
Finally, I used the matchError
, a predicate provided by Nimble to compare errors. Both the code and the domain are internally validated 👍🏼
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome! Thanks for taking care of this @Juanpe! 🔥
Checklist
purchases-android
and hybridsMotivation
Resolves #1114
Now, if
purchase(sk2Product:)
fails because of an error when posting the receipt, the method returnsErrorCode.unknownError
because it assumes it always receives aStoreKitError
. The goal of this PR is to improve the way to handle the error.Description
where
condition to know if the error type isStoreKitError
, if not the method returns the error received.