-
Notifications
You must be signed in to change notification settings - Fork 20
Ssarkisyan/dev 33 purchase result #730
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
base: develop
Are you sure you want to change the base?
Conversation
| }) | ||
| } | ||
|
|
||
| private fun handlePurchaseResult(result: QPurchaseResult) { |
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.
Let's rename to "handlePurchaseError"
|
|
||
| /** | ||
| * Purchase a product and validate it through server-to-server using Qonversion's Backend. | ||
| * This is the new recommended method that returns a single PurchaseResult object containing |
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.
Here and below let's use linking syntax for class name
| * all relevant information about the purchase outcome. | ||
| * @param context current activity context | ||
| * @param product product for purchase | ||
| * @param options optional purchase options (can be null) |
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.
I think there is no need to add (can be null) after optional
| package com.qonversion.android.sdk.dto | ||
|
|
||
| /** | ||
| * Enum representing the type of purchase completion callback. | ||
| * Used to distinguish between legacy callback methods and new result-based methods. | ||
| */ | ||
| enum class QPurchaseCompletionType { | ||
| /** | ||
| * Legacy callback type with separate parameters for entitlements, error, and cancellation status | ||
| */ | ||
| LEGACY, | ||
|
|
||
| /** | ||
| * New result-based callback type with a single PurchaseResult object | ||
| */ | ||
| RESULT | ||
| } |
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.
I don't really like this approach with having multiple callback types. I think the best option is to wrap each type of callbacks into internal callback that will be used in the internal logic and will prepare results depending on which callback it was initialized with. This way we will avoid the necessity of this class and all the corresponding spaghetti with lots of ifs, arrays and method duplications
| /** | ||
| * Called when the purchase operation completes successfully | ||
| * @param result PurchaseResult containing entitlements and purchase details | ||
| */ | ||
| fun onSuccess(result: QPurchaseResult) | ||
|
|
||
| /** | ||
| * Called when the purchase operation fails | ||
| * @param result PurchaseResult containing error information | ||
| */ | ||
| fun onError(result: QPurchaseResult) |
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.
I think we don't need two methods here. Single onResult is enough as the provided object contains all the necessary information about both success and error states. What is crucial is can there be both error and entitlements? If so, then we need sort of description about the source of entitlements. I think, it would be useful to specify if we've received the entitlements from the API, created them manually locally, or didn't get because of error. Sort of enum with these three values that will be included in result. Or two boolean fields: isSuccessful, isFallbackGenerated. Or even both approaches together - enum with two utility properties.
Because we can't just refer to the error field to decide if it was successful purchase or not. As in fallback scenario there can be both error and entitlements.
No description provided.