Add QDeferredPurchasesListener with QDeferredTransaction model#785
Add QDeferredPurchasesListener with QDeferredTransaction model#785
Conversation
- New QDeferredPurchasesListener interface with deferredPurchaseCompleted callback - New QDeferredTransaction data class with productId, transactionId, originalTransactionId, type, value, currency - Deprecated QEntitlementsUpdateListener (interface + config builder + setter) - Both listeners fire in deferred purchase paths (API success + fallback) - Public API on Qonversion + QonversionConfig.Builder - 6 unit tests DEV-643 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
LEVER Self-ReviewLogic
Edge Cases
Verify
Risks
Linear: DEV-665 |
…back) - Create EntitlementsUpdateListenerAdapter that wraps QEntitlementsUpdateListener as QDeferredPurchasesListener, extracting entitlements from purchaseResult - Change deferredPurchaseCompleted signature to include QPurchaseResult (a deferred purchase is a purchase, so the callback provides both transaction details and the purchase result with entitlements) - Remove entitlementsUpdateListener from InternalConfig - only deferredPurchasesListener remains - Delete unused EntitlementsUpdateListenerProvider interface - Deprecated setters now wrap legacy listener via adapter - Both deferred call sites in QProductCenterManager use single deferredPurchasesListener invocation (no more dual listener logic) - Update tests for adapter behavior and removed properties Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
| callback.onSuccess(user) | ||
| } | ||
|
|
||
| // Review feedback (Task 6): deprecated setter wraps legacy listener in adapter. |
There was a problem hiding this comment.
No need to mention review feedback in comments
There was a problem hiding this comment.
Removed. Also cleaned up the other review-feedback comments throughout the PR.
| * including product ID, transaction ID, type, value, and currency. | ||
| * @param purchaseResult the purchase result containing entitlements granted by this purchase. | ||
| */ | ||
| fun deferredPurchaseCompleted(transaction: QDeferredTransaction, purchaseResult: QPurchaseResult) |
There was a problem hiding this comment.
What is the necessity of the DeferredTransaction here, if there is the PurchaseResult? I think all the information about the purchase can be taken from there
There was a problem hiding this comment.
Good point. Removed QDeferredTransaction entirely. The listener now takes just QPurchaseResult:
interface QDeferredPurchasesListener {
fun deferredPurchaseCompleted(purchaseResult: QPurchaseResult)
}QPurchaseResult.purchase already has productId, purchaseToken, orderId, and the result itself has entitlements, status, source. No need for a separate model.
Also updated the Sandwich SDK Android mapper to use purchaseResult.toMap() directly.
| internal val primaryConfig: PrimaryConfig, | ||
| internal val cacheConfig: CacheConfig, | ||
| internal val entitlementsUpdateListener: QEntitlementsUpdateListener? | ||
| // Review feedback (Task 6): removed entitlementsUpdateListener from config. |
Purchase.productId returns String? (via products.firstOrNull()) but QDeferredTransaction.productId expects non-nullable String. Use the same `?: ""` convention as PurchaseRecord.kt. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…er review Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
@SpertsyanKM Привет! |
d9da704 to
3320845
Compare
deferredPurchaseCompleted is only ever called with successful QPurchaseResult (via success() or successFromFallback()). All call sites guard with null-callback checks. Document this explicitly so the adapter contract is clear. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Summary
QDeferredPurchasesListenerinterface withdeferredPurchaseCompleted(transaction)callbackQDeferredTransactiondata class with productId, transactionId, originalTransactionId, type, value, currencyQEntitlementsUpdateListenerinterface, config builder method, and Qonversion setterQonversioninterface +QonversionConfig.BuilderArchitecture
Files changed
QDeferredPurchasesListener.kt- new interfaceQDeferredTransaction.kt- new data classQEntitlementsUpdateListener.kt- deprecatedQonversion.kt- new setter + deprecated oldQonversionConfig.kt- new builder method + deprecated oldInternalConfig.kt- new propertyQProductCenterManager.kt- new setter + callback invocation at both deferred pathsQonversionInternal.kt- delegates to product center managerDeferredPurchasesListenerTest.kt- 6 unit testsTest plan
Note
valueandcurrencyare 0.0/null for Android because Google PlayPurchaseobject doesn't expose price. These fields will be populated at the Sandwich/cross-platform layer using product catalog data.DEV-643
Generated with Claude Code